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.

classification
Title: Unpickling of range objects fail in Py3k
Type: Stage:
Components: Interpreter Core, Library (Lib) Versions: Python 3.0, Python 2.6, Python 2.5
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: alexandre.vassalotti Nosy List: alexandre.vassalotti, pythonhacker
Priority: critical Keywords: patch

Created on 2008-04-08 12:39 by pythonhacker, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
bugdemo.py pythonhacker, 2008-04-08 12:39 Demonstrates the bug
fix_range_pickling.patch alexandre.vassalotti, 2008-06-05 22:53
fix_range_pickling-2.patch alexandre.vassalotti, 2008-06-05 22:54
fix_xrange_pickling.patch alexandre.vassalotti, 2008-06-05 23:16 for Python 2.x
Messages (6)
msg65157 - (view) Author: Anand B Pillai (pythonhacker) * Date: 2008-04-08 12:38
Unpickling of range objects is throwing an exception in Python 3.0
msg67736 - (view) Author: Alexandre Vassalotti (alexandre.vassalotti) * (Python committer) Date: 2008-06-05 22:53
Weird. I wonder why it succeeds to pickle to range object at all. It
seems the __reduce_ex__ method emits bogus value.

  >>> r.__reduce_ex__(2)
  (<function __newobj__ at 0xb7bfdc94>, (<class 'range'>,), None, None,
None)

Anyway, that is easy to fix when you know the trick. So, here is the fix.
msg67737 - (view) Author: Alexandre Vassalotti (alexandre.vassalotti) * (Python committer) Date: 2008-06-05 22:54
Oh, here is a slightly more efficient version.
msg67739 - (view) Author: Alexandre Vassalotti (alexandre.vassalotti) * (Python committer) Date: 2008-06-05 23:16
xrange() in Python 2.x is also affected by this bug. So, here is the fix.
msg67891 - (view) Author: Alexandre Vassalotti (alexandre.vassalotti) * (Python committer) Date: 2008-06-10 04:05
Fixed in r64059 for Python 3.0
Fixed in r64056 and r64057 for Python 2.6
msg67892 - (view) Author: Alexandre Vassalotti (alexandre.vassalotti) * (Python committer) Date: 2008-06-10 04:06
> Fixed in r64056 and r64057 for Python 2.6

Oops, I meant r64057 and r64058.
History
Date User Action Args
2022-04-11 14:56:33adminsetgithub: 46834
2008-06-10 04:06:54alexandre.vassalottisetmessages: + msg67892
2008-06-10 04:05:51alexandre.vassalottisetstatus: open -> closed
resolution: fixed
messages: + msg67891
2008-06-05 23:16:23alexandre.vassalottisetfiles: + fix_xrange_pickling.patch
messages: + msg67739
versions: + Python 2.6, Python 2.5
2008-06-05 22:54:59alexandre.vassalottisetfiles: + fix_range_pickling-2.patch
messages: + msg67737
2008-06-05 22:53:15alexandre.vassalottisetfiles: + fix_range_pickling.patch
assignee: alexandre.vassalotti
messages: + msg67736
keywords: + patch
nosy: + alexandre.vassalotti
2008-05-03 21:02:37benjamin.petersonsetpriority: critical
2008-04-08 12:39:01pythonhackercreate