Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
85ac8508
Commit
85ac8508
authored
Jun 01, 2006
by
Georg Brandl
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Correctly unpickle 2.4 exceptions via __setstate__ (patch #1498571)
parent
b16e4e78
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
24 additions
and
0 deletions
+24
-0
Objects/exceptions.c
Objects/exceptions.c
+24
-0
No files found.
Objects/exceptions.c
View file @
85ac8508
...
...
@@ -150,6 +150,29 @@ BaseException_reduce(PyBaseExceptionObject *self)
return
PyTuple_Pack
(
2
,
self
->
ob_type
,
self
->
args
);
}
/*
* Needed for backward compatibility, since exceptions used to store
* all their attributes in the __dict__. Code is taken from cPickle's
* load_build function.
*/
static
PyObject
*
BaseException_setstate
(
PyObject
*
self
,
PyObject
*
state
)
{
PyObject
*
d_key
,
*
d_value
;
Py_ssize_t
i
=
0
;
if
(
state
!=
Py_None
)
{
if
(
!
PyDict_Check
(
state
))
{
PyErr_SetString
(
PyExc_TypeError
,
"state is not a dictionary"
);
return
NULL
;
}
while
(
PyDict_Next
(
state
,
&
i
,
&
d_key
,
&
d_value
))
{
if
(
PyObject_SetAttr
(
self
,
d_key
,
d_value
)
<
0
)
return
NULL
;
}
}
Py_RETURN_NONE
;
}
#ifdef Py_USING_UNICODE
/* while this method generates fairly uninspired output, it a least
...
...
@@ -168,6 +191,7 @@ BaseException_unicode(PyBaseExceptionObject *self)
static
PyMethodDef
BaseException_methods
[]
=
{
{
"__reduce__"
,
(
PyCFunction
)
BaseException_reduce
,
METH_NOARGS
},
{
"__setstate__"
,
(
PyCFunction
)
BaseException_setstate
,
METH_O
},
#ifdef Py_USING_UNICODE
{
"__unicode__"
,
(
PyCFunction
)
BaseException_unicode
,
METH_NOARGS
},
#endif
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment