Message362244
`pathlib.Path` objects can be used as context managers, but this functionality is undocumented and makes little sense. Example:
>>> import pathlib
>>> root = pathlib.Path("/")
>>> with root:
... print(1)
...
1
>>> with root:
... print(2)
...
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/barney/.pyenv/versions/3.7.3/lib/python3.7/pathlib.py", line 1028, in __enter__
self._raise_closed()
File "/home/barney/.pyenv/versions/3.7.3/lib/python3.7/pathlib.py", line 1035, in _raise_closed
raise ValueError("I/O operation on closed path")
ValueError: I/O operation on closed path
`Path` objects don't acquire any resources on __new__/__init__/__enter__, nor do they release any resources on __exit__. The whole notion of the path being `_closed` seems to exist purely to make impure `Path` methods unusable after exiting from the context manager. I can't personally think of a compelling use case for this, and suggest that it be removed. |
|
Date |
User |
Action |
Args |
2020-02-19 02:10:35 | barneygale | set | recipients:
+ barneygale |
2020-02-19 02:10:35 | barneygale | set | messageid: <1582078235.85.0.126538415089.issue39682@roundup.psfhosted.org> |
2020-02-19 02:10:35 | barneygale | link | issue39682 messages |
2020-02-19 02:10:35 | barneygale | create | |
|