Skip to content

bpo-45545: chdir __exit__ is not safe #29218

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

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Merge with cpython/main
  • Loading branch information
ucodery committed May 5, 2022
commit aca60ad4ac72de495a32a72b10f647be6328b83c
7 changes: 4 additions & 3 deletions Lib/test/test_contextlib.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import sys
import tempfile
import threading
import traceback
import unittest
from contextlib import * # Tests __all__
from test import support
Expand Down Expand Up @@ -1221,9 +1222,9 @@ def test_exception(self):
try:
with chdir(target):
self.assertEqual(os.getcwd(), target)
raise RuntimeError('boom')
raise RuntimeError("boom")
except RuntimeError as re:
self.assertEqual(str(re), 'boom')
self.assertEqual(str(re), "boom")
self.assertEqual(os.getcwd(), old_cwd)

def test_with_os_chdir(self):
Expand Down Expand Up @@ -1257,7 +1258,7 @@ def test_long_path(self):
try:
os.getcwd()
except OSError as exc:
if exc.errno == errno.FILENOTFOUND:
if exc.errno == errno.ENOENT:
# This will rais an exception in __enter__ when we are
# testing for an exception in __exit__
self.skipTest('Cannot retrieve cwd that is longer than '
Expand Down