mirror of
https://github.com/python/cpython.git
synced 2025-08-04 08:59:19 +00:00
[3.11] gh-79325: Fix recursion error in TemporaryDirectory cleanup on Windows (GH-112762) (GH-112848)
(cherry picked from commit b2923a61a1
)
This commit is contained in:
parent
5585334d77
commit
a18201bff1
3 changed files with 21 additions and 2 deletions
|
@ -1543,6 +1543,17 @@ class TestTemporaryDirectory(BaseTestCase):
|
|||
with self.assertRaises(PermissionError):
|
||||
temp_dir.cleanup()
|
||||
|
||||
@unittest.skipUnless(os.name == "nt", "Only on Windows.")
|
||||
def test_cleanup_with_used_directory(self):
|
||||
with tempfile.TemporaryDirectory() as working_dir:
|
||||
temp_dir = self.do_create(dir=working_dir)
|
||||
subdir = os.path.join(temp_dir.name, "subdir")
|
||||
os.mkdir(subdir)
|
||||
with os_helper.change_cwd(subdir):
|
||||
# Previously raised RecursionError on some OSes
|
||||
# (e.g. Windows). See bpo-35144.
|
||||
with self.assertRaises(PermissionError):
|
||||
temp_dir.cleanup()
|
||||
|
||||
@os_helper.skip_unless_symlink
|
||||
def test_cleanup_with_symlink_to_a_directory(self):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue