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

[doc] Clarify copyreg.pickle() documentation #65022

Closed
peterotten mannequin opened this issue Mar 2, 2014 · 12 comments
Closed

[doc] Clarify copyreg.pickle() documentation #65022

peterotten mannequin opened this issue Mar 2, 2014 · 12 comments
Labels
3.9 only security fixes 3.10 only security fixes 3.11 only security fixes docs Documentation in the Doc dir easy type-bug An unexpected behavior, bug, or error

Comments

@peterotten
Copy link
Mannequin

peterotten mannequin commented Mar 2, 2014

BPO 20823
Nosy @serhiy-storchaka, @miss-islington, @kumaraditya303
PRs
  • bpo-20823: Clarify copyreg.pickle() documentation #30230
  • [3.10] bpo-20823: Clarify copyreg.pickle() documentation (GH-30230) #30669
  • [3.9] bpo-20823: Clarify copyreg.pickle() documentation (GH-30230) #30670
  • Files
  • copyreg.patch
  • 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 = None
    closed_at = None
    created_at = <Date 2014-03-02.08:46:06.048>
    labels = ['easy', 'type-bug', '3.9', '3.10', '3.11', 'docs']
    title = '[doc] Clarify copyreg.pickle() documentation'
    updated_at = <Date 2022-01-18.20:17:10.000>
    user = 'https://bugs.python.org/peterotten'

    bugs.python.org fields:

    activity = <Date 2022-01-18.20:17:10.000>
    actor = 'miss-islington'
    assignee = 'docs@python'
    closed = False
    closed_date = None
    closer = None
    components = ['Documentation']
    creation = <Date 2014-03-02.08:46:06.048>
    creator = 'peter.otten'
    dependencies = []
    files = ['34263']
    hgrepos = []
    issue_num = 20823
    keywords = ['patch', 'easy']
    message_count = 6.0
    messages = ['212541', '288092', '296271', '410883', '410884', '410885']
    nosy_count = 5.0
    nosy_names = ['peter.otten', 'docs@python', 'serhiy.storchaka', 'miss-islington', 'kumaraditya']
    pr_nums = ['30230', '30669', '30670']
    priority = 'normal'
    resolution = None
    stage = 'patch review'
    status = 'open'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue20823'
    versions = ['Python 3.9', 'Python 3.10', 'Python 3.11']

    Linked PRs

    @peterotten
    Copy link
    Mannequin Author

    peterotten mannequin commented Mar 2, 2014

    The documentation for

    copyreg.pickle(type, function, constructor=None)

    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

    def pickle(ob_type, pickle_function, constructor_ob=None):
        if type(ob_type) is _ClassType:
            raise TypeError("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.

    @peterotten peterotten mannequin assigned docspython Mar 2, 2014
    @peterotten peterotten mannequin added the docs Documentation in the Doc dir label Mar 2, 2014
    @serhiy-storchaka
    Copy link
    Member

    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 serhiy-storchaka added 3.7 (EOL) end of life type-bug An unexpected behavior, bug, or error labels Feb 18, 2017
    @serhiy-storchaka
    Copy link
    Member

    Could you update your patch Peter, and since CPython development is moved to GitHub, create a pull request?

    @iritkatriel iritkatriel added easy 3.9 only security fixes 3.10 only security fixes 3.11 only security fixes and removed 3.7 (EOL) end of life labels Dec 9, 2021
    @iritkatriel iritkatriel changed the title Clarify copyreg.pickle() documentation [doc] Clarify copyreg.pickle() documentation Dec 9, 2021
    @serhiy-storchaka
    Copy link
    Member

    New changeset 65940fa by Kumar Aditya in branch 'main':
    bpo-20823: Clarify copyreg.pickle() documentation (GH-30230)
    65940fa

    @miss-islington
    Copy link
    Contributor

    New changeset 9238a52 by Miss Islington (bot) in branch '3.10':
    bpo-20823: Clarify copyreg.pickle() documentation (GH-30230)
    9238a52

    @miss-islington
    Copy link
    Contributor

    New changeset 8527f7a by Miss Islington (bot) in branch '3.9':
    bpo-20823: Clarify copyreg.pickle() documentation (GH-30230)
    8527f7a

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    @slateny
    Copy link
    Contributor

    slateny commented Jul 14, 2022

    The PR updated the wording on TypeError for constructor, but it looks like the wording on the 2/3 elements still needs an update.

    @furkanonder
    Copy link
    Contributor

    @slateny What exactly do you mean by wording on the 2/3 elements?

    @slateny
    Copy link
    Contributor

    slateny commented Mar 8, 2023

    I was referring to Serhiy's comment above regarding the wording of copyreg.pickle.

    @furkanonder
    Copy link
    Contributor

    @serhiy-storchaka I updated the copyreg.pickle function description as;

    function must return either a string or a tuple containing two or five elements. 
    

    nanjekyejoannah pushed a commit that referenced this issue Apr 24, 2023
    Fix description of copyreg.pickle function
    @nanjekyejoannah
    Copy link
    Contributor

    @serhiy-storchaka can decide when to close this, @furkanonder the doc update is merged.

    carljm added a commit to carljm/cpython that referenced this issue Apr 24, 2023
    * main: (53 commits)
      pythongh-102498 Clean up unused variables and imports in the email module  (python#102482)
      pythongh-99184: Bypass instance attribute access in `repr` of `weakref.ref` (python#99244)
      pythongh-99032: datetime docs: Encoding is no longer relevant (python#93365)
      pythongh-94300: Update datetime.strptime documentation (python#95318)
      pythongh-103776: Remove explicit uses of $(SHELL) from Makefile (pythonGH-103778)
      pythongh-87092: fix a few cases of incorrect error handling in compiler (python#103456)
      pythonGH-103727: Avoid advancing tokenizer too far in f-string mode (pythonGH-103775)
      Revert "Add tests for empty range equality (python#103751)" (python#103770)
      pythongh-94518: Port 23-argument `_posixsubprocess.fork_exec` to Argument Clinic (python#94519)
      pythonGH-65022: Fix description of copyreg.pickle function (python#102656)
      pythongh-103323: Get the "Current" Thread State from a Thread-Local Variable (pythongh-103324)
      pythongh-91687: modernize dataclass example typing (python#103773)
      pythongh-103746: Test `types.UnionType` and `Literal` types together (python#103747)
      pythongh-103765: Fix 'Warning: py:class reference target not found: ModuleSpec' (pythonGH-103769)
      pythongh-87452: Improve the Popen.returncode docs
      Removed unnecessary escaping of asterisks (python#103714)
      pythonGH-102973: Slim down Fedora packages in the dev container (python#103283)
      pythongh-103091: Add PyUnstable_Type_AssignVersionTag (python#103095)
      Add tests for empty range equality (python#103751)
      pythongh-103712: Increase the length of the type name in AttributeError messages (python#103713)
      ...
    carljm added a commit to carljm/cpython that referenced this issue Apr 24, 2023
    * superopt: (82 commits)
      pythongh-101517: fix line number propagation in code generated for except* (python#103550)
      pythongh-103780: Use patch instead of mock in asyncio unix events test (python#103782)
      pythongh-102498 Clean up unused variables and imports in the email module  (python#102482)
      pythongh-99184: Bypass instance attribute access in `repr` of `weakref.ref` (python#99244)
      pythongh-99032: datetime docs: Encoding is no longer relevant (python#93365)
      pythongh-94300: Update datetime.strptime documentation (python#95318)
      pythongh-103776: Remove explicit uses of $(SHELL) from Makefile (pythonGH-103778)
      pythongh-87092: fix a few cases of incorrect error handling in compiler (python#103456)
      pythonGH-103727: Avoid advancing tokenizer too far in f-string mode (pythonGH-103775)
      Revert "Add tests for empty range equality (python#103751)" (python#103770)
      pythongh-94518: Port 23-argument `_posixsubprocess.fork_exec` to Argument Clinic (python#94519)
      pythonGH-65022: Fix description of copyreg.pickle function (python#102656)
      pythongh-103323: Get the "Current" Thread State from a Thread-Local Variable (pythongh-103324)
      pythongh-91687: modernize dataclass example typing (python#103773)
      pythongh-103746: Test `types.UnionType` and `Literal` types together (python#103747)
      pythongh-103765: Fix 'Warning: py:class reference target not found: ModuleSpec' (pythonGH-103769)
      pythongh-87452: Improve the Popen.returncode docs
      Removed unnecessary escaping of asterisks (python#103714)
      pythonGH-102973: Slim down Fedora packages in the dev container (python#103283)
      pythongh-103091: Add PyUnstable_Type_AssignVersionTag (python#103095)
      ...
    @hauntsaninja
    Copy link
    Contributor

    hauntsaninja commented 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

    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:

    Opened a PR for this in #103892

    hauntsaninja added a commit to hauntsaninja/cpython that referenced this issue May 2, 2023
    hauntsaninja added a commit to hauntsaninja/cpython that referenced this issue May 2, 2023
    …eg (pythonGH-103892)
    
    (cherry picked from commit 587f2f0)
    
    Co-authored-by: Shantanu <12621235+hauntsaninja@users.noreply.github.com>
    hauntsaninja added a commit to hauntsaninja/cpython that referenced this issue May 2, 2023
    carljm added a commit to carljm/cpython that referenced this issue May 2, 2023
    * main:
      pythongh-103822: [Calendar] change return value to enum for day and month APIs (pythonGH-103827)
      pythongh-65022: Fix description of tuple return value in copyreg (python#103892)
      pythonGH-103525: Improve exception message from `pathlib.PurePath()` (pythonGH-103526)
      pythongh-84436: Add integration C API tests for immortal objects (pythongh-103962)
      pythongh-103743: Add PyUnstable_Object_GC_NewWithExtraData (pythonGH-103744)
      pythongh-102997: Update Windows installer to SQLite 3.41.2. (python#102999)
      pythonGH-103484: Fix redirected permanently URLs (python#104001)
      Improve assert_type phrasing (python#104081)
      pythongh-102997: Update macOS installer to SQLite 3.41.2. (pythonGH-102998)
      pythonGH-103472: close response in HTTPConnection._tunnel (python#103473)
      pythongh-88496: IDLE - fix another test on macOS (python#104075)
      pythongh-94673: Hide Objects in PyTypeObject Behind Accessors (pythongh-104074)
      pythongh-94673: Properly Initialize and Finalize Static Builtin Types for Each Interpreter (pythongh-104072)
      pythongh-104016: Skip test for deeply neste f-strings on wasi (python#104071)
    carljm added a commit to carljm/cpython that referenced this issue May 2, 2023
    * main: (760 commits)
      pythonGH-104102: Optimize `pathlib.Path.glob()` handling of `../` pattern segments (pythonGH-104103)
      pythonGH-104104: Optimize `pathlib.Path.glob()` by avoiding repeated calls to `os.path.normcase()` (pythonGH-104105)
      pythongh-103822: [Calendar] change return value to enum for day and month APIs (pythonGH-103827)
      pythongh-65022: Fix description of tuple return value in copyreg (python#103892)
      pythonGH-103525: Improve exception message from `pathlib.PurePath()` (pythonGH-103526)
      pythongh-84436: Add integration C API tests for immortal objects (pythongh-103962)
      pythongh-103743: Add PyUnstable_Object_GC_NewWithExtraData (pythonGH-103744)
      pythongh-102997: Update Windows installer to SQLite 3.41.2. (python#102999)
      pythonGH-103484: Fix redirected permanently URLs (python#104001)
      Improve assert_type phrasing (python#104081)
      pythongh-102997: Update macOS installer to SQLite 3.41.2. (pythonGH-102998)
      pythonGH-103472: close response in HTTPConnection._tunnel (python#103473)
      pythongh-88496: IDLE - fix another test on macOS (python#104075)
      pythongh-94673: Hide Objects in PyTypeObject Behind Accessors (pythongh-104074)
      pythongh-94673: Properly Initialize and Finalize Static Builtin Types for Each Interpreter (pythongh-104072)
      pythongh-104016: Skip test for deeply neste f-strings on wasi (python#104071)
      pythongh-104057: Fix direct invocation of test_super (python#104064)
      pythongh-87092: Expose assembler to unit tests (python#103988)
      pythongh-97696: asyncio eager tasks factory (python#102853)
      pythongh-84436: Immortalize in _PyStructSequence_InitBuiltinWithFlags() (pythongh-104054)
      ...
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    3.9 only security fixes 3.10 only security fixes 3.11 only security fixes docs Documentation in the Doc dir easy type-bug An unexpected behavior, bug, or error
    Projects
    Status: Done
    Development

    No branches or pull requests

    7 participants