Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.debian.maint.python > #14810
| From | Andrius Merkys <merkys@debian.org> |
|---|---|
| Newsgroups | linux.debian.maint.python, linux.debian.bugs.dist |
| Subject | Re: Python 3.11 for bookworm? |
| Date | 2023-01-09 16:50 +0100 |
| Message-ID | <FM2zn-gIzg-1@gated-at.bofh.it> (permalink) |
| References | (4 earlier) <FIjSa-eivi-11@gated-at.bofh.it> <FKy0F-fKED-3@gated-at.bofh.it> <FLcr7-gaK4-5@gated-at.bofh.it> <FLcKt-gaQU-3@gated-at.bofh.it> <FLfyF-gcFn-1@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
Cross-posted to 2 groups.
Hi Simon,
On 2023-01-07 13:24, Simon McVittie wrote:
> On Sat, 07 Jan 2023 at 10:23:19 +0200, Andrius Merkys wrote:
>> If I may, I would as well be grateful if someone could give a look at:
>>
>> #1023972 [src:python-ase] FTBFS with Python 3.11 due to
>> pathlib.Path.__enter__() deprecation
>>
>> I have no idea how to fix this and the upstream is silent.
> My first thought on seeing this was: why were Path objects a context
> manager in the first place? What would that mean?
>
> Looking at the code in python3.10 and python3.11 pathlib, it seems the
> reason this is deprecated is indeed that it didn't make sense:
>
> def __enter__(self):
> # In previous versions of pathlib, __exit__() marked this path as
> # closed; subsequent attempts to perform I/O would raise an IOError.
> # This functionality was never documented, and had the effect of
> # making Path objects mutable, contrary to PEP 428.
> # In Python 3.9 __exit__() was made a no-op.
> # In Python 3.11 __enter__() began emitting DeprecationWarning.
> # In Python 3.13 __enter__() and __exit__() should be removed.
> warnings.warn("pathlib.Path.__enter__() is deprecated and scheduled "
> "for removal in Python 3.13; Path objects as a context "
> "manager is a no-op",
> DeprecationWarning, stacklevel=2)
> return self
>
> def __exit__(self, t, v, tb):
> pass
>
> So the solution seems to be that if your package contains this:
>
> with some_path_object:
> do_stuff(some_path_object)
>
> replace it with:
>
> do_stuff(some_path_object)
>
> and if it contains:
>
> with Path(...) as my_path:
> do_stuff(my_path)
>
> replace with:
>
> my_path = Path(...)
> do_stuff(my_path)
>
> I hope that should be a relatively straightforward change.
Thanks a lot for the hint, this indeed worked. Failure in __enter__()
threw me off tracks, but now I recall how it is related to 'with'
construction.
Best wishes,
Andrius
Back to linux.debian.maint.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Re: Python 3.11 for bookworm? Matthias Klose <doko@ubuntu.com> - 2022-12-21 19:30 +0100
Re: Python 3.11 for bookworm? Sandro Tosi <morph@debian.org> - 2022-12-22 01:20 +0100
Re: Python 3.11 for bookworm? Nicholas D Steeves <sten@debian.org> - 2022-12-22 02:30 +0100
Re: Python 3.11 for bookworm? "M. Zhou" <lumin@debian.org> - 2022-12-22 06:10 +0100
Re: Python 3.11 for bookworm? Thomas Goirand <zigo@debian.org> - 2022-12-28 02:00 +0100
Re: Python 3.11 for bookworm? Andreas Tille <andreas@an3as.eu> - 2022-12-30 10:30 +0100
Re: Python 3.11 for bookworm? Thomas Goirand <zigo@debian.org> - 2023-01-05 14:00 +0100
Re: Python 3.11 for bookworm? Andreas Tille <andreas@an3as.eu> - 2023-01-07 09:10 +0100
Re: Python 3.11 for bookworm? Andrius Merkys <merkys@debian.org> - 2023-01-07 09:30 +0100
Re: Python 3.11 for bookworm? Andrius Merkys <merkys@debian.org> - 2023-01-09 16:50 +0100
Re: Python 3.11 for bookworm? Andreas Tille <andreas@an3as.eu> - 2023-01-16 17:30 +0100
Re: Python 3.11 for bookworm? Thomas Goirand <zigo@debian.org> - 2023-01-17 01:10 +0100
Re: Python 3.11 for bookworm? Andreas Tille <tille@debian.org> - 2023-01-17 07:50 +0100
Re: Python 3.11 for bookworm? Étienne Mollier <emollier@emlwks999.eu> - 2023-01-10 22:50 +0100
Re: Python 3.11 for bookworm? Stefano Rivera <stefanor@debian.org> - 2022-12-22 13:50 +0100
Re: Python 3.11 for bookworm? Timo Röhling <roehling@debian.org> - 2022-12-22 14:00 +0100
Re: Python 3.11 for bookworm? Stefano Rivera <stefanor@debian.org> - 2022-12-22 19:50 +0100
Re: Python 3.11 for bookworm? "M. Zhou" <lumin@debian.org> - 2022-12-23 00:30 +0100
Re: Python 3.11 for bookworm? "M. Zhou" <lumin@debian.org> - 2022-12-23 00:40 +0100
Re: Python 3.11 for bookworm? Graham Inggs <ginggs@debian.org> - 2022-12-26 21:30 +0100
Re: Python 3.11 for bookworm? Graham Inggs <ginggs@debian.org> - 2022-12-26 21:50 +0100
csiph-web