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

2022-01-27 Thread Barney Gale
Change by Barney Gale : -- pull_requests: +29150 pull_request: https://github.com/python/cpython/pull/30971 ___ Python tracker ___ _

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

2020-04-01 Thread Antony Lee
Change by Antony Lee : -- nosy: -Antony.Lee ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.pyt

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

2020-04-01 Thread Antoine Pitrou
Change by Antoine Pitrou : -- versions: +Python 3.9 -Python 3.8 ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe

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

2020-04-01 Thread Antoine Pitrou
Change by Antoine Pitrou : -- resolution: -> fixed stage: patch review -> resolved status: open -> closed type: -> behavior ___ Python tracker ___ ___

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

2020-04-01 Thread Antoine Pitrou
Antoine Pitrou added the comment: New changeset 2e6d8b0ccdb6e0d9e98a9a7f9c9edfdf1311 by Barney Gale in branch 'master': bpo-39682: make `pathlib.Path` immutable by removing (undocumented) support for "closing" a path by using it as a context manager (GH-18846) https://github.com/python/c

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

2020-03-08 Thread Barney Gale
Change by Barney Gale : -- keywords: +patch pull_requests: +18203 stage: -> patch review pull_request: https://github.com/python/cpython/pull/18846 ___ Python tracker ___

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

2020-03-05 Thread Isaac Muse
Isaac Muse added the comment: Wrong thread sorry -- ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: https://

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

2020-03-05 Thread Isaac Muse
Isaac Muse added the comment: Brace expansion does not currently exist in Python's glob. You'd have to use a third party module to expand the braces and then run glob on each returned pattern, or use a third party module that implements a glob that does it for you. Shameless plug: Brace ex

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

2020-03-04 Thread Brett Cannon
Brett Cannon added the comment: @Antoine I just quite follow what you mean. Are you saying ditch _closed and just leave the context manager to be a no-op? -- ___ Python tracker _

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

2020-03-03 Thread Antoine Pitrou
Antoine Pitrou added the comment: Note you could simply remove the "closed" flag and the context manager live. That way, you don't have to deprecate anything. -- ___ Python tracker _

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

2020-03-03 Thread Brett Cannon
Brett Cannon added the comment: > Can I ask what sort of backwards-compatibility guarantees Python provides for > these cases? A deprecation warning for two releases (i.e. two years). Then it can be removed. So if people want to move forward with removing this then a DeprecationWarning woul

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

2020-03-03 Thread Barney Gale
Barney Gale added the comment: Also, thank you Antoine for your explanation :-) -- ___ Python tracker ___ ___ Python-bugs-list mail

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

2020-03-03 Thread Barney Gale
Barney Gale added the comment: Can I ask what sort of backwards-compatibility guarantees Python provides for these cases? In the case of using a Path object as a context manager, I think we can say: - It's easy to do - there's no need to call any underscore-prefixed methods for example - It

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

2020-03-02 Thread Antoine Pitrou
Antoine Pitrou added the comment: As with the Accessor abstraction, the original idea was to support Path objects backed by a directory file descriptor (for use with openat() and friends). That idea was abandoned but it looks like the context manager stayed. It's certainly not useful curre

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

2020-03-02 Thread Antony Lee
Antony Lee 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

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

2020-03-02 Thread Brett Cannon
Brett Cannon added the comment: I guess a question is whether we want immutability guarantees (I for one didn't even know you could hash Path objects until now). I'm personally fine with that idea as it mentally makes sense to not need paths to be mutable. But as I said, someone needs to tak

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

2020-02-28 Thread Antony Lee
Antony Lee added the comment: A problem of having this bit of state in paths is that it violates assumptions based on immutability/hashability, e.g. with from pathlib import Path p = Path("foo") q = Path("foo") with p: pass unique_paths = {p, q} print(len(unique_pa

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

2020-02-27 Thread Brett Cannon
Brett Cannon added the comment: A use-case of "closing" a path is to cheaply flag that a path object is no longer valid, e.g. you deleted the underlying file and so you don't want others using the object anymore without paying the penalty of having to do the I/O to trigger the failure due to

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

2020-02-18 Thread Karthikeyan Singaravelan
Change by Karthikeyan Singaravelan : -- nosy: +brett.cannon, pitrou ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubsc

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

2020-02-18 Thread Barney Gale
New submission from Barney Gale : `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) ... Tracebac