Skip to content

Commit f1bcdea

Browse files
authored
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.
1 parent a941e59 commit f1bcdea

File tree

5 files changed

+150
-190
lines changed

5 files changed

+150
-190
lines changed

Include/internal/pycore_exceptions.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ extern "C" {
1313

1414
extern PyStatus _PyExc_InitState(PyInterpreterState *);
1515
extern PyStatus _PyExc_InitGlobalObjects(PyInterpreterState *);
16-
extern PyStatus _PyExc_InitTypes(PyInterpreterState *);
16+
extern int _PyExc_InitTypes(PyInterpreterState *);
1717
extern void _PyExc_Fini(PyInterpreterState *);
1818

1919

Include/internal/pycore_pylifecycle.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ extern PyStatus _PySys_ReadPreinitWarnOptions(PyWideStringList *options);
5959
extern PyStatus _PySys_ReadPreinitXOptions(PyConfig *config);
6060
extern int _PySys_UpdateConfig(PyThreadState *tstate);
6161
extern void _PySys_Fini(PyInterpreterState *interp);
62-
extern PyStatus _PyBuiltins_AddExceptions(PyObject * bltinmod);
62+
extern int _PyBuiltins_AddExceptions(PyObject * bltinmod);
6363
extern PyStatus _Py_HashRandomization_Init(const PyConfig *);
6464

6565
extern PyStatus _PyImportZip_Init(PyThreadState *tstate);

Lib/test/exception_hierarchy.txt

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,9 @@
11
BaseException
2-
├── SystemExit
3-
├── KeyboardInterrupt
4-
├── GeneratorExit
52
├── BaseExceptionGroup
3+
├── GeneratorExit
4+
├── KeyboardInterrupt
5+
├── SystemExit
66
└── Exception
7-
├── ExceptionGroup [BaseExceptionGroup]
8-
├── StopIteration
9-
├── StopAsyncIteration
107
├── ArithmeticError
118
│ ├── FloatingPointError
129
│ ├── OverflowError
@@ -15,6 +12,7 @@ BaseException
1512
├── AttributeError
1613
├── BufferError
1714
├── EOFError
15+
├── ExceptionGroup [BaseExceptionGroup]
1816
├── ImportError
1917
│ └── ModuleNotFoundError
2018
├── LookupError
@@ -43,6 +41,8 @@ BaseException
4341
├── RuntimeError
4442
│ ├── NotImplementedError
4543
│ └── RecursionError
44+
├── StopAsyncIteration
45+
├── StopIteration
4646
├── SyntaxError
4747
│ └── IndentationError
4848
│ └── TabError
@@ -54,14 +54,14 @@ BaseException
5454
│ ├── UnicodeEncodeError
5555
│ └── UnicodeTranslateError
5656
└── Warning
57+
├── BytesWarning
5758
├── DeprecationWarning
59+
├── EncodingWarning
60+
├── FutureWarning
61+
├── ImportWarning
5862
├── PendingDeprecationWarning
63+
├── ResourceWarning
5964
├── RuntimeWarning
6065
├── SyntaxWarning
61-
├── UserWarning
62-
├── FutureWarning
63-
├── ImportWarning
6466
├── UnicodeWarning
65-
├── BytesWarning
66-
├── EncodingWarning
67-
└── ResourceWarning
67+
└── UserWarning

0 commit comments

Comments
 (0)