homepage

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: Cannot unpickle classes derived from 'Exception'
Type: behavior Stage: resolved
Components: Interpreter Core Versions: Python 3.2, Python 2.7
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: Aman.Shah, Andreas.Hausmann, alexandre.vassalotti, belopolsky, benjamin.peterson, bpb, brett.cannon, ehuss, facundobatista, fmitha, georg.brandl, jafo, jaraco, jarpa, kylev, loewis, lukasz.langa, nnorwitz, pitrou, python-dev, r.david.murray, sbt, tseaver, vstinner, zbysz, zseil
Priority: normal Keywords: patch

Created on 2013年02月25日 17:00 by Andreas.Hausmann, last changed 2022年04月11日 14:57 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
bug_cpickle.py Andreas.Hausmann, 2013年02月25日 17:00
bug_cpickle.py r.david.murray, 2013年02月25日 17:36
exception_pickling.patch r.david.murray, 2013年02月27日 13:54
issue_17296.patch Aman.Shah, 2013年03月11日 08:27 review
issue_17296v2.patch Aman.Shah, 2013年03月11日 17:34 Version 2 review
Messages (13)
msg182960 - (view) Author: Andreas Hausmann (Andreas.Hausmann) Date: 2013年02月25日 17:00
When pickling/unpickling a class that derives from the builtin class Exception, unpickling results in a
TypeError: ('__init__() takes at least 2 arguments (1 given)', <class '__main__.TestException'>, ())
A standard exception like ValueError can be pickled/unpickled without any problem.
This was observed for versions 2.7.3 and 3.2.3. for both pickle and cPickle.
A script (cpickle) that shows that behavior is included.
This is related (but I do not quite understand how) to the closed Issue1692335.
msg182961 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2013年02月25日 17:04
That issue was only fixed in 3.3. Does your code work in 3.3?
msg182962 - (view) Author: Andreas Hausmann (Andreas.Hausmann) Date: 2013年02月25日 17:14
I have not tried in 3.3. I have no running installation of 3.3.
I need a solution for 2.7 for a Zope project that was just ported to 2.7. My test for Python3 was halfheartedly on my standard Python3 installation (3.2) after reading Issue1692335.
msg182963 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2013年02月25日 17:23
The reason I ask is because that issue ends with "reopen if you think this should be backported", so a backport is at least within the real of possibility :)
msg182964 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2013年02月25日 17:36
I modified your script to run under both python2 and python3. I get the error for 2.5, 2.6, and 2.7. The script produces the same output (without the EXCEPTION ## EXCEPTION) under 2.4 and 3.3.
msg183037 - (view) Author: Andreas Hausmann (Andreas.Hausmann) Date: 2013年02月26日 09:52
That is correct.
Under 2.4 and 3.3 it should show neither the line "EXCEPTION ## EXCEPTION" nor the following line "TypeError: ('__init__() takes at least 2 arguments....."
That means, that in version 2.4 and 3.3 that unpickling problem doesn't exist. In version 2.4 I tested it myself; exactly, there is no problem. In version 3.3 I simply take your word, that the bug is fixed.
msg183038 - (view) Author: Andreas Hausmann (Andreas.Hausmann) Date: 2013年02月26日 09:56
A backport to 2.7 would be in the interest of the Zope community (I dare say ;)), at least in ours.
In our project, after having migrated to Zope 2.13/Python2.7 we found this bug and now we are quite worried what else might happen with our huge pickled database.
msg183151 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2013年02月27日 13:54
I don't have the expertise required to do the 2.7 backport. My naive attempt is attached, but the message attribute is not preserved (test failure). If someone can fix the patch, I'll commit it.
msg183152 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2013年02月27日 14:04
New changeset 2c9f7ed28384 by R David Murray in branch '3.2':
#17296: backport fix for issue 1692335, naive exception pickling.
http://hg.python.org/cpython/rev/2c9f7ed28384 
msg183944 - (view) Author: Aman Shah (Aman.Shah) * Date: 2013年03月11日 08:27
Fixed the patch for 2.7
msg183955 - (view) Author: Tres Seaver (tseaver) * Date: 2013年03月11日 12:48
The latest 2.7 patch does not cause the following tests (from
issue 1692335) to pass:
 http://bugs.python.org/file17509/issue1692335-tests.patch 
msg183982 - (view) Author: Aman Shah (Aman.Shah) * Date: 2013年03月11日 17:34
I think it works with the other test also now. Have also included the failed test mentioned by Tres in the patch since it wasn't present in the python2.7 test suite.
msg363539 - (view) Author: Brett Cannon (brett.cannon) * (Python committer) Date: 2020年03月06日 20:04
As this was fixed in 3.3 that means all actively maintained versions have the fix, and so closing as fixed.
History
Date User Action Args
2022年04月11日 14:57:42adminsetgithub: 61498
2020年03月06日 20:04:29brett.cannonsetstatus: open -> closed
resolution: fixed
messages: + msg363539

stage: resolved
2014年02月04日 12:11:49taleinatsetnosy: - taleinat
2013年11月11日 11:39:25sbtlinkissue15440 superseder
2013年03月11日 18:25:01gvanrossumsetnosy: - gvanrossum
2013年03月11日 17:34:39Aman.Shahsetfiles: + issue_17296v2.patch

messages: + msg183982
2013年03月11日 12:48:47tseaversetmessages: + msg183955
2013年03月11日 08:27:55Aman.Shahsetfiles: + issue_17296.patch
nosy: + Aman.Shah
messages: + msg183944

2013年02月27日 14:04:39python-devsetmessages: + msg183152
2013年02月27日 13:54:09r.david.murraysetfiles: + exception_pickling.patch
keywords: + patch
messages: + msg183151
2013年02月26日 09:56:54Andreas.Hausmannsetmessages: + msg183038
2013年02月26日 09:52:42Andreas.Hausmannsetmessages: + msg183037
2013年02月25日 17:36:21r.david.murraysetfiles: + bug_cpickle.py

messages: + msg182964
2013年02月25日 17:23:05r.david.murraysetmessages: + msg182963
2013年02月25日 17:14:40Andreas.Hausmannsetmessages: + msg182962
2013年02月25日 17:04:34r.david.murraysetnosy: + r.david.murray
messages: + msg182961
2013年02月25日 17:00:16Andreas.Hausmanncreate

AltStyle によって変換されたページ (->オリジナル) /