This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author barneygale
Recipients barneygale
Date 2020-02-19.02:10:35
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
`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)
>>> 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/", line 1028, in __enter__
  File "/home/barney/.pyenv/versions/3.7.3/lib/python3.7/", 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:35barneygalesetrecipients: + barneygale
2020-02-19 02:10:35barneygalesetmessageid: <>
2020-02-19 02:10:35barneygalelinkissue39682 messages
2020-02-19 02:10:35barneygalecreate