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

bpo-26579: Add object.__getstate__(). #2821

Merged
merged 23 commits into from
Apr 6, 2022

Conversation

serhiy-storchaka
Copy link
Member

@serhiy-storchaka serhiy-storchaka commented Jul 23, 2017

Copying and pickling instances of subclasses of builtin types
bytearray, set, frozenset, collections.OrderedDict, collections.deque,
weakref.WeakSet, and datetime.tzinfo now copies and pickles instance attributes
implemented as slots.

https://bugs.python.org/issue26579

Copying and pickling instances of subclasses of builtin types
bytearray, set, frozenset, collections.OrderedDict, collections.deque,
weakref.WeakSet, and datetime.tzinfo now copies and pickles instance attributes
implemented as slots.
@serhiy-storchaka serhiy-storchaka added the type-feature A feature request or enhancement label Jul 23, 2017
@mention-bot
Copy link

@serhiy-storchaka, thanks for your PR! By analyzing the history of the files in this pull request, we identified @pitrou, @rhettinger and @tim-one to be potential reviewers.

Doc/library/pickle.rst Outdated Show resolved Hide resolved
Doc/whatsnew/3.7.rst Outdated Show resolved Hide resolved
Doc/whatsnew/3.7.rst Outdated Show resolved Hide resolved
Added ``object.__getstate__`` which provides the default implementation of
the ``__getstate__()`` method.

Copying and pickling instances of subclasses of builtin types bytearray,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interpreted text roles could be used here.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, but I afraid that it would add too much noise. All links are added in What's New.

@youkaichao
Copy link

Any progress? I opened a similar issue about object.__getstate__. Looking forward to this PR being merged!

@github-actions
Copy link

This PR is stale because it has been open for 30 days with no activity.

@github-actions github-actions bot added the stale Stale PR or inactive for long period of time. label Feb 20, 2022
Copy link
Contributor

@MaxwellDupre MaxwellDupre left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm impressed this is a big change, but unfortunately I couldn't run the full test suite. So starting off with
test_divide_and_round fails with Issue45229 outstanding

Then
test_bad_getattr (Lib.test.pickletester.AbstractPickleTests) ... ERROR

With so many failures:
Test suite interrupted by signal SIGINT.
4 tests omitted:
test_multiprocessing_fork test_multiprocessing_forkserver
test_multiprocessing_spawn test_poplib
378 tests OK.
15 tests failed:
test_asyncio test_dbm test_float test_ftplib test_httplib
test_imaplib test_logging test_nntplib test_ossaudiodev
test_shutil test_ssl test_tk test_ttk_guionly
test_urllib2_localnet test_xmlrpc_net
9 tests skipped:
test_devpoll test_kqueue test_msilib test_nis test_startfile
test_winconsoleio test_winreg test_winsound test_zipfile64
Total duration: 69 min 27 sec
Tests result: FAILURE
cpython on  object-getstate [$?] via 🐍 v3.11.0a3+ took 1h9m27s

Just makes testing a nightmare!

@tacaswell
Copy link
Contributor

This has broken cython (see cython/cython#4730).

@da-woods
Copy link
Contributor

This has broken cython (see cython/cython#4730).

I'm fairly sure the break to Cython is understood and easy to fix in Cython (cython/cython#4730 (comment)) so please don't revert this on Cython's behalf!

@encukou
Copy link
Member

encukou commented Jun 22, 2022

This has also broken jsonpickle: jsonpickle/jsonpickle#395

@AdamWill
Copy link
Contributor

AdamWill commented Jun 22, 2022

edit: never mind, was looking at the 3.10 docs not the 3.11 docs. 3.11 docs cover what defaultdict does.

@gpshead
Copy link
Member

gpshead commented Jul 13, 2023

As another bread crumb: object.__getstate__ existing is also causing problems for CLIF generated C extensions as well. See https://github.com/google/clif/pull/64/files#diff-de65cd2a0ef58411075450cf769b38dd6d53803108d536309289cda5810a379aR23 for an example of the type of workaround we're likely to make.

rwgk pushed a commit to google/clif that referenced this pull request Jul 13, 2023
Ignore the `object.__getstate__()` added with python/cpython#2821 because it is not suitable for extension types.

GitHub testing: #64

TGP testing is not needed:

* This CL only changes a .cc file.

* The change is a no-op for Python <= 3.10.

PiperOrigin-RevId: 547855607
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stale Stale PR or inactive for long period of time. type-feature A feature request or enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.