This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Title: Pickle of memoryview not raising error
Type: behavior Stage: resolved
Components: Extension Modules Versions: Python 3.5
Status: closed Resolution: out of date
Dependencies: Superseder:
Assigned To: Nosy List: memeplex, serhiy.storchaka, xiang.zhang
Priority: normal Keywords:

Created on 2016-05-24 01:37 by memeplex, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Messages (3)
msg266212 - (view) Author: Memeplex (memeplex) Date: 2016-05-24 01:37
In [1]: mv = memoryview(b'123')
In [2]: mv.__reduce__()
    TypeError: can't pickle memoryview objects

But then:

In [3]: pickle.dumps(mv)

Even worse:

In [4]: pickle.loads(pickle.dumps(mv))
    TypeError: Required argument 'object' (pos 1) not found

According to the module documentation: Attempts to pickle unpicklable objects will raise the PicklingError exception.
msg266218 - (view) Author: Xiang Zhang (xiang.zhang) * (Python committer) Date: 2016-05-24 03:10
I cannot reproduce this. Pickling memoryview objects works well on my OS.

Python 3.5.1+ (default, Mar 30 2016, 22:46:26) 
[GCC 5.3.1 20160330] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import pickle
>>> mv = memoryview(b'123')
>>> mv.__reduce__()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python3.5/", line 65, in _reduce_ex
    raise TypeError("can't pickle %s objects" % base.__name__)
TypeError: can't pickle memoryview objects
>>> pickle.dumps(mv)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: can't pickle memoryview objects
msg266228 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2016-05-24 05:47
This was fixed in issue22995. Please wait 3.5.2.
Date User Action Args
2022-04-11 14:58:31adminsetgithub: 71285
2016-05-24 05:47:03serhiy.storchakasetstatus: open -> closed

nosy: + serhiy.storchaka
messages: + msg266228

resolution: out of date
stage: resolved
2016-05-24 03:10:23xiang.zhangsetnosy: + xiang.zhang
messages: + msg266218
2016-05-24 01:37:55memeplexcreate