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
os.makedirs' mode argument has bad default value #49470
Comments
os.makedirs' mode argument defaults to a hardcoded value of 511 (0777 in
Preferred behavior would be to have the mode default to the value which N.B. I'm guessing the above workaround won't work on Windows (please excuse |
I don't understand the problem. The directory creation *does* take the Closing the report as invalid. |
Ah, I was misunderstanding the behavior of mkdir, thank you for the My misunderstanding stemmed from recently coming across two widely-used Could the __doc__ for os.mkdir and os.makedirs be expanded to make this |
You use such a mode if you want the resulting directory definitely not A common case is installation programs, where the installer wants to
My suspicion is that people setting explicit file permissions typically
I'm skeptical that this should be necessary. Whoever explained umask to By the same pattern, the doc string of mkdir should also explain what |
For what it's worth, I asked Mike Bayer (author of Beaker and Mako, the For what else it's worth, I've run this by a few other programmers I I agree that knowledge of relative paths should be assumed, but I'm |
I have to agree with jab. While the way relative paths works are more or less common knowledge, the way umask does and does not work in relation to python isn't. It is however given a short description at http://docs.python.org/library/os.html#os.makedirs: And as it is documented (briefly) online that the umask *is* used, perhaps it is not necessary to add it to the doc-string? |
I don't understand what you mean when you say "how umask works in relation to Python". How it works in relation to Python isn't different from how it works for any other Unix program. Consider, for example, the unix man page for 'open'. I don't think a docstring change is called for; the docstrings are brief summaries to act as memory aids, the real docs are the docs. If someone does want to propose such a change they should open a new issue. |
This is what I mean. So we see that new folder created with the --mode parameter to gnu's mkdir does not get the umask masked out. The following code in python gives:
I (as a programmer) have never seen the specific code for python's mkdir function, And I have no way to know whether I should presume that mkdir in python works the same way as the gnu command or not. Unless it is documented that is. Cheers :) |
*Sorry.. A bit quick there. The line
|
You should assume that Python's mkdir does the same as Linux' mkdir |
Thank you very much for the clarification :) |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: