mirror of
https://github.com/python/cpython.git
synced 2025-08-23 02:04:56 +00:00
bpo-46417: Factorize _PyExc_InitTypes() code (GH-30804)
Add 'static_exceptions' list to factorize code between _PyExc_InitTypes() and _PyBuiltins_AddExceptions(). _PyExc_InitTypes() does nothing if it's not the main interpreter. Sort exceptions in Lib/test/exception_hierarchy.txt.
This commit is contained in:
parent
a941e5927f
commit
f1bcdeaca6
5 changed files with 151 additions and 191 deletions
|
@ -740,9 +740,8 @@ pycore_init_types(PyInterpreterState *interp)
|
|||
return status;
|
||||
}
|
||||
|
||||
status = _PyExc_InitTypes(interp);
|
||||
if (_PyStatus_EXCEPTION(status)) {
|
||||
return status;
|
||||
if (_PyExc_InitTypes(interp) < 0) {
|
||||
return _PyStatus_ERR("failed to initialize an exception type");
|
||||
}
|
||||
|
||||
status = _PyExc_InitGlobalObjects(interp);
|
||||
|
@ -790,9 +789,8 @@ pycore_init_builtins(PyThreadState *tstate)
|
|||
Py_INCREF(builtins_dict);
|
||||
interp->builtins = builtins_dict;
|
||||
|
||||
PyStatus status = _PyBuiltins_AddExceptions(bimod);
|
||||
if (_PyStatus_EXCEPTION(status)) {
|
||||
return status;
|
||||
if (_PyBuiltins_AddExceptions(bimod) < 0) {
|
||||
return _PyStatus_ERR("failed to add exceptions to builtins");
|
||||
}
|
||||
|
||||
interp->builtins_copy = PyDict_Copy(interp->builtins);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue