diff options
Diffstat (limited to 'Lib')
| -rw-r--r-- | Lib/pathlib.py | 19 | ||||
| -rw-r--r-- | Lib/test/test_pathlib.py | 20 |
2 files changed, 0 insertions, 39 deletions
diff --git a/Lib/pathlib.py b/Lib/pathlib.py index 3d68c16..3a7a124 100644 --- a/Lib/pathlib.py +++ b/Lib/pathlib.py @@ -1080,25 +1080,6 @@ class Path(PurePath): cls = WindowsPath if os.name == 'nt' else PosixPath return object.__new__(cls) - def __enter__(self): - # In previous versions of pathlib, __exit__() marked this path as - # closed; subsequent attempts to perform I/O would raise an IOError. - # This functionality was never documented, and had the effect of - # making Path objects mutable, contrary to PEP 428. - # In Python 3.9 __exit__() was made a no-op. - # In Python 3.11 __enter__() began emitting DeprecationWarning. - # In Python 3.13 __enter__() and __exit__() should be removed. - warnings.warn("pathlib.Path.__enter__() is deprecated and scheduled " - "for removal in Python 3.13; Path objects as a context " - "manager is a no-op", - DeprecationWarning, stacklevel=2) - return self - - def __exit__(self, t, v, tb): - pass - - # Public API - @classmethod def cwd(cls): """Return a new path pointing to the current working directory.""" diff --git a/Lib/test/test_pathlib.py b/Lib/test/test_pathlib.py index ab2c2b2..8b68cdc 100644 --- a/Lib/test/test_pathlib.py +++ b/Lib/test/test_pathlib.py @@ -2080,26 +2080,6 @@ class _BasePathTest(object): finally: os.chdir(old_cwd) - def test_with(self): - p = self.cls(BASE) - it = p.iterdir() - it2 = p.iterdir() - next(it2) - # bpo-46556: path context managers are deprecated in Python 3.11. - with self.assertWarns(DeprecationWarning): - with p: - pass - # Using a path as a context manager is a no-op, thus the following - # operations should still succeed after the context manage exits. - next(it) - next(it2) - p.exists() - p.resolve() - p.absolute() - with self.assertWarns(DeprecationWarning): - with p: - pass - @os_helper.skip_unless_working_chmod def test_chmod(self): p = self.cls(BASE) / 'fileA' |
