gh-101144: Allow open and read_text encoding to be positional. (#101145)

The zipfile.Path open() and read_text() encoding parameter can be supplied as a positional argument without causing a TypeError again. 3.10.0b1 included a regression that made it keyword only.

Documentation update included as users writing code to be compatible with a wide range of versions will need to consider this for some time.
This commit is contained in:
Gregory P. Smith 2023-01-19 23:04:30 -08:00 committed by GitHub
parent 9e025d305f
commit 5927013e47
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 95 additions and 10 deletions

View file

@ -551,6 +551,12 @@ Path objects are traversable using the ``/`` operator or ``joinpath``.
Added support for text and binary modes for open. Default
mode is now text.
.. versionchanged:: 3.11.2
The ``encoding`` parameter can be supplied as a positional argument
without causing a :exc:`TypeError`. As it could in 3.9. Code needing to
be compatible with unpatched 3.10 and 3.11 versions must pass all
:class:`io.TextIOWrapper` arguments, ``encoding`` included, as keywords.
.. method:: Path.iterdir()
Enumerate the children of the current directory.
@ -596,6 +602,12 @@ Path objects are traversable using the ``/`` operator or ``joinpath``.
:class:`io.TextIOWrapper` (except ``buffer``, which is
implied by the context).
.. versionchanged:: 3.11.2
The ``encoding`` parameter can be supplied as a positional argument
without causing a :exc:`TypeError`. As it could in 3.9. Code needing to
be compatible with unpatched 3.10 and 3.11 versions must pass all
:class:`io.TextIOWrapper` arguments, ``encoding`` included, as keywords.
.. method:: Path.read_bytes()
Read the current file as bytes.