-
-
Notifications
You must be signed in to change notification settings - Fork 31.4k
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
bpo-45545: chdir __exit__ is not safe #29218
base: main
Are you sure you want to change the base?
Conversation
6d5fc98
to
d520427
Compare
Lib/test/test_contextlib.py
Outdated
try: | ||
os.getcwd() | ||
except OSError as exc: | ||
if exc.errno == errno.FILENOTFOUND: |
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.
FILENOTFOUND
does not exist, what is it meant to be? ENOENT
?
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.
Whoops, yes you are right. The joys of fixing CI.
This PR is stale because it has been open for 30 days with no activity. |
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.
Ran 86 tests in 0.284s
OK
Looks ok.
Even with these changes to
__exit__
there are still some uses of chdir that are unsafe, and will not return to the old cwd after the with block is exited. But for use-cases where returning the old cwd is more of a nicety and not required for the rest of the program, the new keyword argument will allow execution to always continue.https://bugs.python.org/issue45545