bpo-39682: make `pathlib.Path` immutable by removing (undocumented) support for "closing" a path by using it as a context manager (GH-18846)
Support for using a path as a context manager remains, and is now a no-op.
diff --git a/Lib/test/test_pathlib.py b/Lib/test/test_pathlib.py
index 5b362a0..8b19cff 100644
--- a/Lib/test/test_pathlib.py
+++ b/Lib/test/test_pathlib.py
@@ -1720,13 +1720,15 @@
next(it2)
with p:
pass
- # I/O operation on closed path.
- self.assertRaises(ValueError, next, it)
- self.assertRaises(ValueError, next, it2)
- self.assertRaises(ValueError, p.open)
- self.assertRaises(ValueError, p.resolve)
- self.assertRaises(ValueError, p.absolute)
- self.assertRaises(ValueError, p.__enter__)
+ # 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 p:
+ pass
def test_chmod(self):
p = self.cls(BASE) / 'fileA'