Skip to content
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

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open

Conversation

ucodery
Copy link
Contributor

@ucodery ucodery commented Oct 25, 2021

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

try:
os.getcwd()
except OSError as exc:
if exc.errno == errno.FILENOTFOUND:
Copy link
Member

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?

Copy link
Contributor Author

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.

@github-actions
Copy link

This PR is stale because it has been open for 30 days with no activity.

@github-actions github-actions bot added the stale Stale PR or inactive for long period of time. label Nov 26, 2021
Copy link
Contributor

@MaxwellDupre MaxwellDupre left a 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.

@cpython-cla-bot
Copy link

cpython-cla-bot bot commented May 5, 2022

All commit authors signed the Contributor License Agreement.
CLA signed

@iritkatriel iritkatriel added the stdlib Python modules in the Lib dir label Nov 29, 2023
@ucodery ucodery mannequin mentioned this pull request Nov 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
awaiting core review stale Stale PR or inactive for long period of time. stdlib Python modules in the Lib dir
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants