[issue39682] pathlib.Path objects can be used as context managers

Antony Lee report at bugs.python.org
Mon Mar 2 15:30:05 EST 2020


Antony Lee <anntzer.lee at gmail.com> added the comment:

Immutability and hashability are listed first among "general properties" of paths (https://docs.python.org/3/library/pathlib.html#general-properties), and in the PEP proposing pathlib (https://www.python.org/dev/peps/pep-0428/#immutability).  Looking at it again I *guess* the docs version could be read as only guaranteeing this for PurePaths (because that's in the PurePath section) rather than Path, but the PEP version clearly implies that this is true for both PurePaths and concrete Paths.

It may be tricky to check usage in third-party packages, given that one would need to look for `with <path-object>: ...` rather than, say, a method name which can be grepped.  Do you have any suggestions here?

----------

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue39682>
_______________________________________


More information about the Python-bugs-list mailing list