mirror of
https://github.com/psycopg/psycopg2.git
synced 2024-11-22 08:56:34 +03:00
Avoid installing Error.__reduce_ex__ on Python 2.4
It is not used by the pickle protocol, and if called manually fails in an unsettling way, probably because the exceptions were old-style classes.
This commit is contained in:
parent
43daba38e7
commit
db987250c8
|
@ -478,7 +478,12 @@ psyco_errors_init(void)
|
|||
PyObject_SetAttrString(Error, "pgcode", Py_None);
|
||||
PyObject_SetAttrString(Error, "cursor", Py_None);
|
||||
|
||||
/* install __reduce_ex__ on Error to make all the subclasses picklable */
|
||||
/* install __reduce_ex__ on Error to make all the subclasses picklable.
|
||||
*
|
||||
* Don't install it on Py 2.4: it is not used by the pickle
|
||||
* protocol, and if called manually fails in an unsettling way,
|
||||
* probably because the exceptions were old-style classes. */
|
||||
#if PY_VERSION_HEX >= 0x02050000
|
||||
if (!(descr = PyDescr_NewMethod((PyTypeObject *)Error,
|
||||
&psyco_error_reduce_ex_def))) {
|
||||
goto exit;
|
||||
|
@ -488,6 +493,7 @@ psyco_errors_init(void)
|
|||
goto exit;
|
||||
}
|
||||
Py_DECREF(descr);
|
||||
#endif
|
||||
|
||||
rv = 0;
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user