Issue 17296: Cannot unpickle classes derived from 'Exception'
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) * ![]() |
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) * ![]() |
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) * ![]() |
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) * ![]() |
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) ![]() |
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) * ![]() |
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:42 | admin | set | github: 61498 |
| 2020-03-06 20:04:29 | brett.cannon | set | status: open -> closed resolution: fixed messages: + msg363539 stage: resolved |
| 2014-02-04 12:11:49 | taleinat | set | nosy:
- taleinat |
| 2013-11-11 11:39:25 | sbt | link | issue15440 superseder |
| 2013-03-11 18:25:01 | gvanrossum | set | nosy:
- gvanrossum |
| 2013-03-11 17:34:39 | Aman.Shah | set | files:
+ issue_17296v2.patch messages: + msg183982 |
| 2013-03-11 12:48:47 | tseaver | set | messages: + msg183955 |
| 2013-03-11 08:27:55 | Aman.Shah | set | files:
+ issue_17296.patch nosy: + Aman.Shah messages: + msg183944 |
| 2013-02-27 14:04:39 | python-dev | set | messages: + msg183152 |
| 2013-02-27 13:54:09 | r.david.murray | set | files:
+ exception_pickling.patch keywords: + patch messages: + msg183151 |
| 2013-02-26 09:56:54 | Andreas.Hausmann | set | messages: + msg183038 |
| 2013-02-26 09:52:42 | Andreas.Hausmann | set | messages: + msg183037 |
| 2013-02-25 17:36:21 | r.david.murray | set | files:
+ bug_cpickle.py messages: + msg182964 |
| 2013-02-25 17:23:05 | r.david.murray | set | messages: + msg182963 |
| 2013-02-25 17:14:40 | Andreas.Hausmann | set | messages: + msg182962 |
| 2013-02-25 17:04:34 | r.david.murray | set | nosy:
+ r.david.murray messages: + msg182961 |
| 2013-02-25 17:00:16 | Andreas.Hausmann | create | |

