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

3.0 pickle docs -- what about old-style classes? #46824

Closed
birkenfeld opened this issue Apr 7, 2008 · 7 comments
Closed

3.0 pickle docs -- what about old-style classes? #46824

birkenfeld opened this issue Apr 7, 2008 · 7 comments
Assignees
Labels
docs Documentation in the Doc dir

Comments

@birkenfeld
Copy link
Member

BPO 2572
Nosy @birkenfeld, @rhettinger, @avassalotti, @benjaminp, @ashemedai

Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

Show more details

GitHub fields:

assignee = 'https://github.com/avassalotti'
closed_at = <Date 2009-04-27.16:22:13.794>
created_at = <Date 2008-04-07.19:18:19.566>
labels = ['docs']
title = '3.0 pickle docs -- what about old-style classes?'
updated_at = <Date 2009-04-27.16:22:13.793>
user = 'https://github.com/birkenfeld'

bugs.python.org fields:

activity = <Date 2009-04-27.16:22:13.793>
actor = 'georg.brandl'
assignee = 'alexandre.vassalotti'
closed = True
closed_date = <Date 2009-04-27.16:22:13.794>
closer = 'georg.brandl'
components = ['Documentation']
creation = <Date 2008-04-07.19:18:19.566>
creator = 'georg.brandl'
dependencies = []
files = []
hgrepos = []
issue_num = 2572
keywords = []
message_count = 7.0
messages = ['65098', '65126', '67354', '86493', '86521', '86604', '86674']
nosy_count = 5.0
nosy_names = ['georg.brandl', 'rhettinger', 'alexandre.vassalotti', 'benjamin.peterson', 'asmodai']
pr_nums = []
priority = 'normal'
resolution = 'rejected'
stage = None
status = 'closed'
superseder = None
type = None
url = 'https://bugs.python.org/issue2572'
versions = ['Python 3.0']

@birkenfeld
Copy link
Member Author

Can 3.0 unpickle pickled old-style classes? Which pickling methods are
supported? Etc.

@birkenfeld birkenfeld added the docs Documentation in the Doc dir label Apr 7, 2008
@avassalotti
Copy link
Member

Python 3.0 shouldn't have any problem unpickling old-style classes.
However, they will be unpickled as new-style classes. Therefore, there
might be a few corner-cases that might cause some problems. For example,
if an old-style class contains a __slots__:

Python 2.5.1 (r251:54863, Mar  7 2008, 04:10:12) 
>>> import pickle
>>> class A:
...   __slots__ = []
... 
>>> pickle.dumps(A())
'(i__main__\nA\np0\n(dp1\nb.'

Python 3.0a3+ (py3k:62050M, Mar 30 2008, 17:29:33) 
>>> class A:
...   __slots__ = []
... 
>>> pickle.loads(b'(i__main__\nA\np0\n(dp1\nb.')
Traceback (most recent call last):
  ...
TypeError: __class__ assignment: '_EmptyClass' deallocator differs from 'A'

@benjaminp
Copy link
Contributor

Alexandre, would you mind fixing up the docs?

@ashemedai
Copy link
Mannequin

ashemedai mannequin commented Apr 25, 2009

We want to document that old-style classes get converted into new-style
classes and that in general this goes without problems, except for some
corner cases such as containing a __slots__ directive? Or did I miss
anything else?

@birkenfeld
Copy link
Member Author

Sounds like this is the best that we without intimate pickle knowledge
can do :)

@rhettinger
Copy link
Contributor

Recommend that this be closed with no action taken. It is an important
step for Py3.x that old style classes be left behind and that no mention
of them occur in the 3.x docs. Let's not carry 2.x with us into the 3.x
world. The whole point was to leave the old world behind.

Also, the issue is not new in the sense that any cross-version pickling
may exercise functions or classes that did not exist in other versions
or whose meaning changed over time. This is the nature of cross-version
pickling.

If someone wants to make pickling notes on the Python wiki, that would
be fine. The pickling docs are already somewhat lengthy and complex,
yet will never cover every issue someone could think up.

@birkenfeld
Copy link
Member Author

Okay, as the original submitter I withdraw this request.

@ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs Documentation in the Doc dir
Projects
None yet
Development

No branches or pull requests

4 participants