-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
makedirs: fix mode flag is being ignored starting from Python 3.7 #2790
Conversation
|
One comment, also test for 2.7 fails. I tried to reproduce it on my computer, and it seems to fail only for first test run. Maybe something is not unset? Though its done in finally, so I am confused. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One comment
π |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks good to me; just adding that mode
flag still works on >=3.7 but it doesn't affect anymore intermediate directories.
@MrOutis yep! thanks
yep, #2789 (comment) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please see two comments up above.
@@ -152,9 +152,9 @@ def makedirs(path, exist_ok=False, mode=None): | |||
_makedirs(path, exist_ok=exist_ok) | |||
return | |||
|
|||
umask = os.umask(0) | |||
umask = os.umask(0o777 - mode) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's put a comment explaining what is going on :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
π
def test_makedirs_permissions(): | ||
dir_mode = 0o755 | ||
intermediate_dir = "ΡΠ΅ΡΡΠΎΠ²Π°Ρ-Π΄ΠΈΡΠ΅ΠΊΡΠΎΡΠΈΡ" | ||
test_dir = os.path.join(intermediate_dir, "data") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are creating this directory in the project's root, which is not nice. Please use tmpdir
fixture or something like that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good point, simplified using tmpdir
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
Fixes #2789
β Have you followed the guidelines in the Contributing to DVC list?
π Check this box if this PR does not require documentation updates, or if it does and you have created a separate PR in dvc.org with such updates (or at least opened an issue about it in that repo). Please link below to your PR (or issue) in the dvc.org repo.
β Have you checked DeepSource, CodeClimate, and other sanity checks below? We consider their findings recommendatory and don't expect everything to be addresses. Please review them carefully and fix those that actually improve code or fix bugs.
Thank you for the contribution - we'll try to review it as soon as possible. π