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

statistics.NormalDist fails to be pickled with0 and1 protocols #99155

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

Description

@sobolevn

Repro:

» ./python.exePython3.12.0a1+ (heads/cover-pysequence-slice-dirty:04cb2ecd5d,Nov52022,16:01:29) [Clang11.0.0 (clang-1100.0.33.16)]ondarwinType"help","copyright","credits"or"license"formoreinformation.>>>importpickle,statistics>>>n=statistics.NormalDist(37.5,5.625)>>>pickle.dumps(n,protocol=0)# or `1`Traceback (mostrecentcalllast):File"<stdin>",line1,in<module>File"/Users/sobolev/Desktop/cpython/Lib/copyreg.py",line94,in_reduce_exraiseTypeError("a class that defines __slots__ without "TypeError:aclassthatdefines__slots__withoutdefining__getstate__cannotbepickled

This is actually tested intest_statistics like this:

nd3=pickle.loads(pickle.dumps(nd))
self.assertEqual(nd,nd3)

But, it is only testing default protocol and is missingfor proto in range(pickle.HIGHEST_PROTOCOL + 1): part.Note: this is the only place in all of the CPython tests, whereprotocol= is not passed. All other places do have the full check.

It looks like a bug to me and I will send a PR with the fix.
CC@rhettinger

Metadata

Metadata

Labels

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