classification
Title: Objects of uname_result Class Cannot be Successfully Pickled
Type: behavior Stage: resolved
Components: Library (Lib) Versions: Python 3.10, Python 3.9
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: CrocoDuck, jaraco, serhiy.storchaka
Priority: normal Keywords: patch

Created on 2020-12-16 15:12 by CrocoDuck, last changed 2021-01-16 19:47 by jaraco. This issue is now closed.

Files
File name Uploaded Description Edit
pickles.zip CrocoDuck, 2020-12-16 15:12 Zip archive containing files created with Python 3.9.0 and Python 3.8.5.
Pull Requests
URL Status Linked Edit
PR 23010 merged jaraco, 2020-12-17 01:57
PR 24232 merged jaraco, 2021-01-16 19:22
Messages (6)
msg383174 - (view) Author: CrocoDuck (CrocoDuck) Date: 2020-12-16 15:12
See the code example below.

```python
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.
msg383183 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2020-12-16 16:31
See also issue42189.
msg383214 - (view) Author: Jason R. Coombs (jaraco) * (Python committer) Date: 2020-12-16 22:08
The PR for the related issue does address pickling. Do you expect pickles to work across Python versions?
msg383215 - (view) Author: CrocoDuck (CrocoDuck) Date: 2020-12-16 22:45
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>
> _______________________________________
msg384131 - (view) Author: Jason R. Coombs (jaraco) * (Python committer) Date: 2020-12-31 19:08
New changeset a6fd0f414c0cb4cd5cc20eb2df3340b31c6f7743 by Jason R. Coombs in branch 'master':
bpo-42163, bpo-42189, bpo-42659: Support uname_tuple._replace (for all but processor) (#23010)
https://github.com/python/cpython/commit/a6fd0f414c0cb4cd5cc20eb2df3340b31c6f7743
msg385148 - (view) Author: Jason R. Coombs (jaraco) * (Python committer) Date: 2021-01-16 19:45
New changeset 799722cb0ddb90752cde7798cab543f30623ebf2 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) (#24232)
https://github.com/python/cpython/commit/799722cb0ddb90752cde7798cab543f30623ebf2
History
Date User Action Args
2021-01-16 19:47:09jaracosetstatus: open -> closed
stage: patch review -> resolved
resolution: fixed
versions: + Python 3.10
2021-01-16 19:45:51jaracosetmessages: + msg385148
2021-01-16 19:22:28jaracosetpull_requests: + pull_request23057
2020-12-31 19:08:11jaracosetmessages: + msg384131
2020-12-17 01:57:33jaracosetkeywords: + patch
stage: patch review
pull_requests: + pull_request22672
2020-12-16 22:45:14CrocoDucksetmessages: + msg383215
2020-12-16 22:08:27jaracosetmessages: + msg383214
2020-12-16 16:31:07serhiy.storchakasetnosy: + jaraco, serhiy.storchaka
messages: + msg383183
components: + Library (Lib)
2020-12-16 15:12:58CrocoDuckcreate