Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gh-99155: Fix NormalDist pickle with 0 and 1 protocols #99156

Merged
merged 4 commits into from
Nov 7, 2022

Conversation

sobolevn
Copy link
Member

@sobolevn sobolevn commented Nov 6, 2022

With new tests, but before my Lib/statistics.py change:

======================================================================
ERROR: test_pickle (test.test_statistics.TestNormalDistC.test_pickle) (proto=0)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/sobolev/Desktop/cpython/Lib/test/test_statistics.py", line 3017, in test_pickle
    pickled = pickle.loads(pickle.dumps(nd, protocol=proto))
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/sobolev/Desktop/cpython/Lib/copyreg.py", line 94, in _reduce_ex
    raise TypeError("a class that defines __slots__ without "
TypeError: a class that defines __slots__ without defining __getstate__ cannot be pickled

======================================================================
ERROR: test_pickle (test.test_statistics.TestNormalDistC.test_pickle) (proto=1)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/sobolev/Desktop/cpython/Lib/test/test_statistics.py", line 3017, in test_pickle
    pickled = pickle.loads(pickle.dumps(nd, protocol=proto))
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/sobolev/Desktop/cpython/Lib/copyreg.py", line 94, in _reduce_ex
    raise TypeError("a class that defines __slots__ without "
TypeError: a class that defines __slots__ without defining __getstate__ cannot be pickled

======================================================================
ERROR: test_pickle (test.test_statistics.TestNormalDistPython.test_pickle) (proto=0)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/sobolev/Desktop/cpython/Lib/test/test_statistics.py", line 3017, in test_pickle
    pickled = pickle.loads(pickle.dumps(nd, protocol=proto))
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/sobolev/Desktop/cpython/Lib/copyreg.py", line 94, in _reduce_ex
    raise TypeError("a class that defines __slots__ without "
TypeError: a class that defines __slots__ without defining __getstate__ cannot be pickled

======================================================================
ERROR: test_pickle (test.test_statistics.TestNormalDistPython.test_pickle) (proto=1)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/sobolev/Desktop/cpython/Lib/test/test_statistics.py", line 3017, in test_pickle
    pickled = pickle.loads(pickle.dumps(nd, protocol=proto))
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/sobolev/Desktop/cpython/Lib/copyreg.py", line 94, in _reduce_ex
    raise TypeError("a class that defines __slots__ without "
TypeError: a class that defines __slots__ without defining __getstate__ cannot be pickled

----------------------------------------------------------------------
Ran 2 tests in 0.007s

We don't usually put docstrings on these two methods.
@rhettinger rhettinger added needs backport to 3.10 only security fixes needs backport to 3.11 only security fixes labels Nov 6, 2022
@rhettinger rhettinger merged commit d7a00f1 into python:main Nov 7, 2022
@miss-islington
Copy link
Contributor

Thanks @sobolevn for the PR, and @rhettinger for merging it 🌮🎉.. I'm working now to backport this PR to: 3.10, 3.11.
🐍🍒⛏🤖

@miss-islington
Copy link
Contributor

Sorry, @sobolevn and @rhettinger, I could not cleanly backport this to 3.11 due to a conflict.
Please backport using cherry_picker on command line.
cherry_picker d7a00f1e8eee05fc5ae97ea1ef0615feefce887b 3.11

@miss-islington
Copy link
Contributor

Sorry, @sobolevn and @rhettinger, I could not cleanly backport this to 3.10 due to a conflict.
Please backport using cherry_picker on command line.
cherry_picker d7a00f1e8eee05fc5ae97ea1ef0615feefce887b 3.10

@bedevere-bot
Copy link

GH-99188 is a backport of this pull request to the 3.11 branch.

@bedevere-bot bedevere-bot removed the needs backport to 3.11 only security fixes label Nov 7, 2022
sobolevn added a commit to sobolevn/cpython that referenced this pull request Nov 7, 2022
…cols (pythonGH-99156).

(cherry picked from commit d7a00f1)

Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
sobolevn added a commit to sobolevn/cpython that referenced this pull request Nov 7, 2022
…cols (pythonGH-99156).

(cherry picked from commit d7a00f1)

Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
miss-islington pushed a commit that referenced this pull request Nov 7, 2022
…H-99156). (GH-99188)

(cherry picked from commit d7a00f1)

Co-authored-by: Nikita Sobolev <mail@sobolevn.me>

Automerge-Triggered-By: GH:rhettinger
miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Nov 7, 2022
…cols (pythonGH-99156). (pythonGH-99188)

(cherry picked from commit d7a00f1)

Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
(cherry picked from commit 263e983)

Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
Automerge-Triggered-By: GH:rhettinger
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs backport to 3.10 only security fixes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants