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

Objects of uname_result Class Cannot be Successfully Pickled #86825

Closed
CrocoDuck mannequin opened this issue Dec 16, 2020 · 6 comments
Closed

Objects of uname_result Class Cannot be Successfully Pickled #86825

CrocoDuck mannequin opened this issue Dec 16, 2020 · 6 comments
Labels
3.9 only security fixes 3.10 only security fixes stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error

Comments

@CrocoDuck
Copy link
Mannequin

CrocoDuck mannequin commented Dec 16, 2020

BPO 42659
Nosy @jaraco, @serhiy-storchaka
PRs
  • bpo-42163, bpo-42189, bpo-42659: Support uname_tuple._replace (for all but processor) #23010
  • [3.9] bpo-42163, bpo-42189, bpo-42659: Support uname_tuple._replace (GH-23010) #24232
  • Files
  • pickles.zip: Zip archive containing files created with Python 3.9.0 and Python 3.8.5.
  • 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 = <Date 2021-01-16.19:47:09.524>
    created_at = <Date 2020-12-16.15:12:58.765>
    labels = ['type-bug', 'library', '3.9', '3.10']
    title = 'Objects of uname_result Class Cannot be Successfully Pickled'
    updated_at = <Date 2021-01-16.19:47:09.523>
    user = 'https://bugs.python.org/CrocoDuck'

    bugs.python.org fields:

    activity = <Date 2021-01-16.19:47:09.523>
    actor = 'jaraco'
    assignee = 'none'
    closed = True
    closed_date = <Date 2021-01-16.19:47:09.524>
    closer = 'jaraco'
    components = ['Library (Lib)']
    creation = <Date 2020-12-16.15:12:58.765>
    creator = 'CrocoDuck'
    dependencies = []
    files = ['49688']
    hgrepos = []
    issue_num = 42659
    keywords = ['patch']
    message_count = 6.0
    messages = ['383174', '383183', '383214', '383215', '384131', '385148']
    nosy_count = 3.0
    nosy_names = ['jaraco', 'serhiy.storchaka', 'CrocoDuck']
    pr_nums = ['23010', '24232']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue42659'
    versions = ['Python 3.9', 'Python 3.10']

    @CrocoDuck
    Copy link
    Mannequin Author

    CrocoDuck mannequin commented Dec 16, 2020

    See the code example below.

    import platform
    import pickle
    
    pack = {
        'uname_result': platform.uname()
    }
    
    with open('test.pickle', 'wb') as f:
        pickle.dump(pack, f, protocol=pickle.HIGHEST_PROTOCOL)
    
    with open('test.pickle', 'rb') as f:
        data = pickle.load(f)

    It works smoothly on Python 3.8.5. However, on Python 3.9.0, the last line produces this error:

    Traceback (most recent call last):
      File "/Users/crocoduck/pickle/3.9.0/make_pickle.py", line 12, in <module>
        data = pickle.load(f)
    TypeError: <lambda>() takes 6 positional arguments but 7 were given
    

    The files produced by the code snipped above are attached for reference.

    This was observed in macOS Catalina 10.15.7.

    @CrocoDuck CrocoDuck mannequin added 3.9 only security fixes type-bug An unexpected behavior, bug, or error labels Dec 16, 2020
    @serhiy-storchaka
    Copy link
    Member

    See also bpo-42189.

    @serhiy-storchaka serhiy-storchaka added stdlib Python modules in the Lib dir labels Dec 16, 2020
    @jaraco
    Copy link
    Member

    jaraco commented Dec 16, 2020

    The PR for the related issue does address pickling. Do you expect pickles to work across Python versions?

    @CrocoDuck
    Copy link
    Mannequin Author

    CrocoDuck mannequin commented Dec 16, 2020

    Hi, I somehow missed the other issue while searching for something
    similar to this, sorry about that.

    The main issue is that files pickled with python 3.9.0 cannot be read
    back by using python 3.9.0 if they contain a uname_result object.

    As for expecting pickle to work across different versions: I did not
    actually think about that. In the original message I mentioned python
    3.8.5 as I noticed this issue did not happen in python 3.8.5, so I
    though it was useful information. To my (hopefully correct)
    understanding if a python version supports the same protocol that was
    used to create the pickle file then it is expected to work. For example
    I have observed that files containing uname_result objects pickled
    with python 3.7.6 are still readable with python 3.8.5. As far as I
    understand this is the expected behavior.

    On 16/12/2020 22:08, Jason R. Coombs wrote:

    Jason R. Coombs <jaraco@jaraco.com> added the comment:

    The PR for the related issue does address pickling. Do you expect pickles to work across Python versions?

    ----------


    Python tracker <report@bugs.python.org>
    <https://bugs.python.org/issue42659\>


    @jaraco
    Copy link
    Member

    jaraco commented Dec 31, 2020

    New changeset a6fd0f4 by Jason R. Coombs in branch 'master':
    bpo-42163, bpo-42189, bpo-42659: Support uname_tuple._replace (for all but processor) (bpo-23010)
    a6fd0f4

    @jaraco
    Copy link
    Member

    jaraco commented Jan 16, 2021

    New changeset 799722c by Jason R. Coombs in branch '3.9':
    [3.9] bpo-42163, bpo-42189, bpo-42659: Support uname_tuple._replace (for all but processor) (GH-23010) (bpo-24232)
    799722c

    @jaraco jaraco added the 3.10 only security fixes label Jan 16, 2021
    @jaraco jaraco closed this as completed Jan 16, 2021
    @jaraco jaraco added the 3.10 only security fixes label Jan 16, 2021
    @jaraco jaraco closed this as completed Jan 16, 2021
    @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
    3.9 only security fixes 3.10 only security fixes stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error
    Projects
    None yet
    Development

    No branches or pull requests

    2 participants