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

Pickle ignores custom getstate methods on TextIOWrapper in Python 3.12 #122559

Closed
Assignees
serhiy-storchaka
Labels
topic-IOtype-bugAn unexpected behavior, bug, or error
@SimonSorgQC

Description

@SimonSorgQC

Bug report

Bug description:

So I am not entirely sure whether this is unintended behaviour, but it is definitely a noticeable change between 3.11 and 3.12 that is rather unintuitive

importpicklefromioimportBytesIO,TextIOWrapperclassEncodedFile(TextIOWrapper):def__getstate__(self):return"string"def__setstate__(self,state):passfile=EncodedFile(BytesIO(b"string"))pickle.dumps(file)

This works in Python 3.11 and 3.10, but fails in 3.12 with

pickle.dumps(file)TypeError:cannotpickle'EncodedFile'instances

CPython versions tested on:

3.10, 3.11, 3.12

Operating systems tested on:

macOS

Linked PRs

Metadata

Metadata

Labels

topic-IOtype-bugAn unexpected behavior, bug, or error

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions


    [8]ページ先頭

    ©2009-2025 Movatter.jp