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 <1582078235.85.0.126538415089.issue39682@roundup.psfhosted.org>
In-reply-to
Content
`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.
History
Date User Action Args
2020-02-19 02:10:35barneygalesetrecipients: + barneygale
2020-02-19 02:10:35barneygalesetmessageid: <1582078235.85.0.126538415089.issue39682@roundup.psfhosted.org>
2020-02-19 02:10:35barneygalelinkissue39682 messages
2020-02-19 02:10:35barneygalecreate