-
-
Notifications
You must be signed in to change notification settings - Fork 30.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add umask
context manager to shutil
#128432
Comments
Based on the discussion over at DPO, I'm suggesting to close this. cc. @ncoghlan |
Unfortunately, despite my initial enthusiasm for the idea, I'm coming to the same conclusion as @erlend-aasland. Any addition to the standard library needs to address the mantra of "not every 3 line function needs to be a builtin" (or its far less snappy corollary, "not every 6 line class needs to be in the standard library"). My initial enthusiasm was based on considering this as a way to influence the file creation of libraries and subprocesses where it isn't feasible to alter their file creation mode directly, and it instead needs to be done indirectly. However:
This makes the proposed context manager far more use case specific than I originally thought it would be, which means it more appropriately belongs in an application or domain specific utility library than it does in the generally cross-platform and cross-domain standard library. I did find the discussion valuable (and I genuinely appreciate your patience @jb2170), but I think the only lasting stdlib impact is going to be the pattern extraction exercise that resulted in #128574. |
Cancelled after realisation in the discussion that two separate, non-beginner-friendly, context managers would be required: one to restrict / increase the umask, and one to absolutely set it. |
Feature or enhancement
Proposal:
PR Incoming. As discussed earlier.
We add a context manager which sets the process's
umask
to a specified value on entry, and resets to the old one on exit. It is reentrant safe.We have discussed and chosen
shutil
as the module to add this to, notcontextlib
.Has this already been discussed elsewhere?
I have already discussed this feature proposal on Discourse
Links to previous discussion of this feature:
https://discuss.python.org/t/add-umask-to-contextlib/75809/21
Linked PRs
umask
context manager toshutil
#128433The text was updated successfully, but these errors were encountered: