Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

zipfile.Path.read_text &.open methods with a positionalencoding arg causes a TypeError #101144

Closed
Assignees
jaraco
Labels
3.10only security fixes3.11only security fixestriagedThe issue has been accepted as valid by a triager.type-bugAn unexpected behavior, bug, or error
@gpshead

Description

@gpshead

This is a regression from 3.9 behavior seen in Python 3.10.

zipfile.Path.read_text passes *args and **kwargs to it's ownopen() method, but in 3.10+ is also blindly setskwargs["encodings"] to a value. So code that was previously passing an encoding as a positional argument now sees:

  File "/<stdlib>/zipfile.py", line 2362, in read_text    with self.open('r', *args, **kwargs) as strm:  File "/<stdlib>/zipfile.py", line 2350, in open    return io.TextIOWrapper(stream, *args, **kwargs)TypeError: Failed to construct dataset imagenet2012: argument for TextIOWrapper() given by name ('encoding') and position (2)

3.10's Lib/zipfile.py (and main's Lib/zipfile/_path.py) contain:

    def read_text(self, *args, **kwargs):        kwargs["encoding"] = io.text_encoding(kwargs.get("encoding"))  # <-- new in 3.10, source of bug        with self.open('r', *args, **kwargs) as strm:            return strm.read()

As this is a regression, we should avoid setting that value in kwargs when"encodings" not in kwargs to match 3.9 and earlier behavior.

TODO list:

Linked PRs

Metadata

Metadata

Assignees

Labels

3.10only security fixes3.11only security fixestriagedThe issue has been accepted as valid by a triager.type-bugAn unexpected behavior, bug, or error

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions


    [8]ページ先頭

    ©2009-2025 Movatter.jp