FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

gh-129824: Fix data race in _PyBuiltins_AddExceptions with subinterpreters by colesbury · Pull Request #143446 · python/cpython · GitHub

/ cpython Public
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .c  (1) All 1 file type selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
39 changes: 16 additions & 23 deletions Objects/exceptions.c
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,6 @@ class BaseExceptionGroup "PyBaseExceptionGroupObject *" "&PyExc_BaseExceptionGro
/*[clinic end generated code: output=da39a3ee5e6b4b0d input=b7c45e78cff8edc3]*/


/* Compatibility aliases */
PyObject *PyExc_EnvironmentError = NULL; // borrowed ref
PyObject *PyExc_IOError = NULL; // borrowed ref
#ifdef MS_WINDOWS
PyObject *PyExc_WindowsError = NULL; // borrowed ref
#endif


static struct _Py_exc_state*
get_exc_state(void)
{
Expand Down Expand Up @@ -2528,6 +2520,13 @@ MiddlingExtendsException(PyExc_OSError, ProcessLookupError, OSError,
MiddlingExtendsException(PyExc_OSError, TimeoutError, OSError,
"Timeout expired.");

/* Compatibility aliases */
PyObject *PyExc_EnvironmentError = (PyObject *)&_PyExc_OSError; // borrowed ref
PyObject *PyExc_IOError = (PyObject *)&_PyExc_OSError; // borrowed ref
#ifdef MS_WINDOWS
PyObject *PyExc_WindowsError = (PyObject *)&_PyExc_OSError; // borrowed ref
#endif

/*
* EOFError extends Exception
*/
Expand Down Expand Up @@ -4599,23 +4598,17 @@ _PyBuiltins_AddExceptions(PyObject *bltinmod)
if (PyDict_SetItemString(mod_dict, "ExceptionGroup", PyExc_ExceptionGroup)) {
return -1;
}

#define INIT_ALIAS(NAME, TYPE) \
do { \
PyExc_ ## NAME = PyExc_ ## TYPE; \
if (PyDict_SetItemString(mod_dict, # NAME, PyExc_ ## TYPE)) { \
return -1; \
} \
} while (0)

INIT_ALIAS(EnvironmentError, OSError);
INIT_ALIAS(IOError, OSError);
if (PyDict_SetItemString(mod_dict, "EnvironmentError", PyExc_OSError)) {
return -1;
}
if (PyDict_SetItemString(mod_dict, "IOError", PyExc_OSError)) {
return -1;
}
#ifdef MS_WINDOWS
INIT_ALIAS(WindowsError, OSError);
if (PyDict_SetItemString(mod_dict, "WindowsError", PyExc_OSError)) {
return -1;
}
#endif

#undef INIT_ALIAS

return 0;
}

Expand Down
Loading

Back | FazBrowse Home | New Git URL