Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork33.7k
Closed
Description
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:
cpython/Lib/test/test_statistics.py
Lines 3012 to 3013 in8feb7ab
| 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