You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
"TypeError will be raised if *object* is a class or *constructor* is not callable."
It's not clear to me what "object" refers to. I believe it refers to the first arg (called ob_type in 2.x) and classic classes which were handled with
defpickle(ob_type, pickle_function, constructor_ob=None):
iftype(ob_type) is_ClassType:
raiseTypeError("copy_reg is not intended for use with classes")
in 2.x If I'm right the above sentence should become.
"A TypeError will be raised if *constructor* is not callable."
in 3.x. If I'm wrong please think of way to express the intended meaning more clearly.
Another minor change: class C need not inherit from object explicitly in 3.x.
The phrase "*function* should return either a string or a tuple containing two or three elements." de-facto is outdated too. Since Python 2.3 a tuple returned by the function must have two to five elements.
copyreg.constructor() no longer does anything useful, and the constructor parameter of copyreg.pickle() is virtually ignored.
@nanjekyejoannah@furkanonder I don't think the change in #102656 is correct. The tuple can also be three, four, or six elements, not just "two or five"
When a tuple is returned, it must be between two and six items long. Optional items can either be omitted, or None can be provided as their value. The semantics of each item are in order:
Activity
peterotten commentedon Mar 2, 2014
The documentation for
has the sentence
"TypeError will be raised if *object* is a class or *constructor* is not callable."
It's not clear to me what "object" refers to. I believe it refers to the first arg (called ob_type in 2.x) and classic classes which were handled with
in 2.x If I'm right the above sentence should become.
"A TypeError will be raised if *constructor* is not callable."
in 3.x. If I'm wrong please think of way to express the intended meaning more clearly.
Another minor change: class C need not inherit from object explicitly in 3.x.
serhiy-storchaka commentedon Feb 18, 2017
The phrase "*function* should return either a string or a tuple containing two or three elements." de-facto is outdated too. Since Python 2.3 a tuple returned by the function must have two to five elements.
copyreg.constructor() no longer does anything useful, and the constructor parameter of copyreg.pickle() is virtually ignored.
serhiy-storchaka commentedon Jun 18, 2017
Could you update your patch Peter, and since CPython development is moved to GitHub, create a pull request?
[-]Clarify copyreg.pickle() documentation[/-][+][doc] Clarify copyreg.pickle() documentation[/+]serhiy-storchaka commentedon Jan 18, 2022
New changeset 65940fa by Kumar Aditya in branch 'main':
bpo-20823: Clarify copyreg.pickle() documentation (GH-30230)
65940fa
miss-islington commentedon Jan 18, 2022
New changeset 9238a52 by Miss Islington (bot) in branch '3.10':
bpo-20823: Clarify copyreg.pickle() documentation (GH-30230)
9238a52
7 remaining items
GH-65022: Fix description of copyreg.pickle function (#102656)
nanjekyejoannah commentedon Apr 24, 2023
@serhiy-storchaka can decide when to close this, @furkanonder the doc update is merged.
Merge branch 'main' into superopt
Merge branch 'superopt' into superopt_spec
hauntsaninja commentedon Apr 26, 2023
@nanjekyejoannah @furkanonder I don't think the change in #102656 is correct. The tuple can also be three, four, or six elements, not just "two or five"
From https://docs.python.org/3/library/pickle.html
Opened a PR for this in #103892
pythongh-65022: Fix description of tuple return value in copyreg
gh-65022: Fix description of tuple return value in copyreg (#103892)
pythongh-65022: Fix description of tuple return value in copyreg (pyt…
[3.11] pythongh-65022: Fix description of tuple return value in copyr…
[3.11] pythongh-65022: Fix description of tuple return value in copyr…
[3.11] gh-65022: Fix description of tuple return value in copyreg (GH…
Merge branch 'main' into inlinecomp2
Merge branch 'main' into cached_property_docs