@@ -28,34 +28,12 @@ _get_current_interp(void)
28
28
return PyInterpreterState_Get ();
29
29
}
30
30
31
- static PyObject *
32
- add_new_exception (PyObject * mod , const char * name , PyObject * base )
33
- {
34
- assert (!PyObject_HasAttrStringWithError (mod , name ));
35
- PyObject * exctype = PyErr_NewException (name , base , NULL );
36
- if (exctype == NULL ) {
37
- return NULL ;
38
- }
39
- int res = PyModule_AddType (mod , (PyTypeObject * )exctype );
40
- if (res < 0 ) {
41
- Py_DECREF (exctype );
42
- return NULL ;
43
- }
44
- return exctype ;
45
- }
46
-
47
- #define ADD_NEW_EXCEPTION (MOD , NAME , BASE ) \
48
- add_new_exception(MOD, MODULE_NAME "." Py_STRINGIFY(NAME), BASE)
49
-
50
31
51
32
/* module state *************************************************************/
52
33
53
34
typedef struct {
54
35
/* heap types */
55
36
PyTypeObject * ExceptionSnapshotType ;
56
-
57
- /* exceptions */
58
- PyObject * RunFailedError ;
59
37
} module_state ;
60
38
61
39
static inline module_state *
@@ -73,9 +51,6 @@ traverse_module_state(module_state *state, visitproc visit, void *arg)
73
51
/* heap types */
74
52
Py_VISIT (state -> ExceptionSnapshotType );
75
53
76
- /* exceptions */
77
- Py_VISIT (state -> RunFailedError );
78
-
79
54
return 0 ;
80
55
}
81
56
@@ -85,9 +60,6 @@ clear_module_state(module_state *state)
85
60
/* heap types */
86
61
Py_CLEAR (state -> ExceptionSnapshotType );
87
62
88
- /* exceptions */
89
- Py_CLEAR (state -> RunFailedError );
90
-
91
63
return 0 ;
92
64
}
93
65
@@ -186,30 +158,6 @@ get_code_str(PyObject *arg, Py_ssize_t *len_p, PyObject **bytes_p, int *flags_p)
186
158
187
159
/* interpreter-specific code ************************************************/
188
160
189
- static int
190
- exceptions_init (PyObject * mod )
191
- {
192
- module_state * state = get_module_state (mod );
193
- if (state == NULL ) {
194
- return -1 ;
195
- }
196
-
197
- #define ADD (NAME , BASE ) \
198
- do { \
199
- assert(state->NAME == NULL); \
200
- state->NAME = ADD_NEW_EXCEPTION(mod, NAME, BASE); \
201
- if (state->NAME == NULL) { \
202
- return -1; \
203
- } \
204
- } while (0)
205
-
206
- // An uncaught exception came out of interp_run_string().
207
- ADD (RunFailedError , PyExc_RuntimeError );
208
- #undef ADD
209
-
210
- return 0 ;
211
- }
212
-
213
161
static int
214
162
_run_script (PyObject * ns , const char * codestr , Py_ssize_t codestrlen , int flags )
215
163
{
@@ -772,11 +720,6 @@ module_exec(PyObject *mod)
772
720
goto error ;
773
721
}
774
722
775
- /* Add exception types */
776
- if (exceptions_init (mod ) != 0 ) {
777
- goto error ;
778
- }
779
-
780
723
// PyInterpreterID
781
724
if (PyModule_AddType (mod , & PyInterpreterID_Type ) < 0 ) {
782
725
goto error ;
0 commit comments