mirror of
https://github.com/python/cpython.git
synced 2026-01-06 15:32:22 +00:00
gh-105375: Improve errnomodule error handling (#105590)
Bail immediately if an exception is set, to prevent exceptions from being overwritten.
This commit is contained in:
parent
89aac6f6b7
commit
eede1d2f48
2 changed files with 6 additions and 3 deletions
|
|
@ -0,0 +1 @@
|
|||
Fix bugs in :mod:`pickle` where exceptions could be overwritten.
|
||||
|
|
@ -81,10 +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) {
|
||||
Py_XDECREF(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