We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents 778b42f + 256af8f commit 2144008Copy full SHA for 2144008
news/11920.bugfix.rst
@@ -0,0 +1 @@
1
+Add permission check before configuration
src/pip/_internal/configuration.py
@@ -210,8 +210,15 @@ def save(self) -> None:
210
# Ensure directory exists.
211
ensure_dir(os.path.dirname(fname))
212
213
- with open(fname, "w") as f:
214
- parser.write(f)
+ # Ensure directory's permission(need to be writeable)
+ try:
215
+ with open(fname, "w") as f:
216
+ parser.write(f)
217
+ except OSError as error:
218
+ raise ConfigurationError(
219
+ f"An error occurred while writing to the configuration file "
220
+ f"{fname}: {error}"
221
+ )
222
223
#
224
# Private routines
0 commit comments