diff options
| author | Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> | 2023-12-07 17:36:29 (GMT) |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-12-07 17:36:29 (GMT) |
| commit | 34e9e20cf20647d62d7639241af7c0d4e34fb04f (patch) | |
| tree | 0f58d861e1415e23998c702b58e66beea042216d /Lib/test/test_tempfile.py | |
| parent | 418adf687ff1ccdd56cbc0f91d03936f57bf4c77 (diff) | |
| download | cpython-34e9e20cf20647d62d7639241af7c0d4e34fb04f.zip cpython-34e9e20cf20647d62d7639241af7c0d4e34fb04f.tar.gz cpython-34e9e20cf20647d62d7639241af7c0d4e34fb04f.tar.bz2 | |
[3.12] gh-79325: Fix recursion error in TemporaryDirectory cleanup on Windows (GH-112762) (GH-112847)
(cherry picked from commit b2923a61a10dc2717f4662b590cc9f6d181c6983)
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
Diffstat (limited to 'Lib/test/test_tempfile.py')
| -rw-r--r-- | Lib/test/test_tempfile.py | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/Lib/test/test_tempfile.py b/Lib/test/test_tempfile.py index 2729bec..b64b6a4 100644 --- a/Lib/test/test_tempfile.py +++ b/Lib/test/test_tempfile.py @@ -1651,6 +1651,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): |
