mirror of
https://github.com/python/cpython.git
synced 2025-08-31 05:58:33 +00:00
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.
This commit is contained in:
parent
975ac326ff
commit
00002e6d8b
3 changed files with 21 additions and 49 deletions
|
@ -1720,13 +1720,15 @@ class _BasePathTest(object):
|
|||
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'
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue