mirror of
https://github.com/python/cpython.git
synced 2026-01-06 23:42:34 +00:00
(cherry picked from commit eede1d2f48)
Bail immediately if an exception is set, to prevent exceptions from
being overwritten.
This commit is contained in:
parent
04b76ece7f
commit
e0087df65d
2 changed files with 6 additions and 2 deletions
|
|
@ -0,0 +1 @@
|
|||
Fix bugs in :mod:`pickle` where exceptions could be overwritten.
|
||||
|
|
@ -81,9 +81,12 @@ _add_errcode(PyObject *module_dict, PyObject *error_dict, const char *name_str,
|
|||
static int
|
||||
errno_exec(PyObject *module)
|
||||
{
|
||||
PyObject *module_dict = PyModule_GetDict(module);
|
||||
PyObject *module_dict = PyModule_GetDict(module); // Borrowed ref.
|
||||
if (module_dict == NULL) {
|
||||
return -1;
|
||||
}
|
||||
PyObject *error_dict = PyDict_New();
|
||||
if (!module_dict || !error_dict) {
|
||||
if (error_dict == NULL) {
|
||||
return -1;
|
||||
}
|
||||
if (PyDict_SetItemString(module_dict, "errorcode", error_dict) < 0) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue