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

Python pickler unable to pickle object the native pickler can #120380

Closed
Labels
stdlibStandard Library Python modules in the Lib/ directorytype-bugAn unexpected behavior, bug, or error
@apmorton

Description

@apmorton

Bug report

Bug description:

importioimportpickleclassZeroCopyByteArray(bytearray):def__reduce_ex__(self,protocol):returntype(self), (pickle.PickleBuffer(self),),Nonedata= [ZeroCopyByteArray(),ZeroCopyByteArray(),]# this worksf=io.BytesIO()pickler=pickle.Pickler(f,protocol=5)pickler.dump(data)# this hits memo assertionf=io.BytesIO()pickler=pickle._Pickler(f,protocol=5)pickler.dump(data)
Traceback (most recent call last):  File"bug.py", line24, in<module>    pickler.dump(data)  File"/pickle.py", line487, indumpself.save(obj)  File"/pickle.py", line560, insave    f(self, obj)# Call unbound method with explicit self^^^^^^^^^^^^  File"/pickle.py", line932, insave_listself._batch_appends(obj)  File"/pickle.py", line956, in_batch_appends    save(x)  File"/pickle.py", line603, insaveself.save_reduce(obj=obj,*rv)  File"/pickle.py", line692, insave_reduce    save(args)  File"/pickle.py", line560, insave    f(self, obj)# Call unbound method with explicit self^^^^^^^^^^^^  File"/pickle.py", line887, insave_tuple    save(element)  File"/pickle.py", line560, insave    f(self, obj)# Call unbound method with explicit self^^^^^^^^^^^^  File"/pickle.py", line842, insave_picklebufferself.save_bytearray(m.tobytes())  File"/pickle.py", line821, insave_bytearrayself.memoize(obj)  File"/pickle.py", line508, inmemoizeassertid(obj)notinself.memo^^^^^^^^^^^^^^^^^^^^^^^^AssertionError

CPython versions tested on:

3.11

Operating systems tested on:

Linux

Linked PRs

Metadata

Metadata

Assignees

No one assigned

    Labels

    stdlibStandard Library Python modules in the Lib/ directorytype-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