Skip to content

Commit 5986dd2

Browse files
committed
Add permission check before configuration
1 parent 17147b8 commit 5986dd2

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/pip/_internal/configuration.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -211,10 +211,10 @@ def save(self) -> None:
211211
ensure_dir(os.path.dirname(fname))
212212

213213
# Ensure directory's permission(need to be writeable)
214-
try:
214+
if os.access(fname, os.W_OK):
215215
with open(fname, "w") as f:
216216
parser.write(f)
217-
except:
217+
else:
218218
raise ConfigurationError(
219219
"Configuation file not writeable {}".format(': '.join(fname))
220220
)

0 commit comments

Comments
 (0)