File tree Expand file tree Collapse file tree 4 files changed +17
-40
lines changed Expand file tree Collapse file tree 4 files changed +17
-40
lines changed Original file line number Diff line number Diff line change @@ -7,9 +7,6 @@ extern "C" {
7
7
#ifndef Py_LIMITED_API
8
8
PyAPI_FUNC (PyObject * ) _PyWarnings_Init (void );
9
9
#endif
10
- #ifdef Py_BUILD_CORE
11
- PyAPI_FUNC (PyObject * ) _PyWarnings_InitWithConfig (const _PyCoreConfig * config );
12
- #endif
13
10
14
11
PyAPI_FUNC (int ) PyErr_WarnEx (
15
12
PyObject * category ,
Original file line number Diff line number Diff line change @@ -1151,27 +1151,6 @@ pymain_get_program_name(_PyMain *pymain)
1151
1151
}
1152
1152
1153
1153
1154
- /* Initialize the main interpreter.
1155
- *
1156
- * Replaces previous call to Py_Initialize()
1157
- *
1158
- * Return 0 on success.
1159
- * Set pymain->err and return -1 on error.
1160
- */
1161
- static int
1162
- pymain_init_main_interpreter (_PyMain * pymain )
1163
- {
1164
- _PyInitError err ;
1165
-
1166
- err = _Py_InitializeMainInterpreter (& pymain -> config );
1167
- if (_Py_INIT_FAILED (err )) {
1168
- pymain -> err = err ;
1169
- return -1 ;
1170
- }
1171
- return 0 ;
1172
- }
1173
-
1174
-
1175
1154
static void
1176
1155
pymain_header (_PyMain * pymain )
1177
1156
{
@@ -2357,7 +2336,9 @@ pymain_init_python_main(_PyMain *pymain)
2357
2336
return -1 ;
2358
2337
}
2359
2338
2360
- if (pymain_init_main_interpreter (pymain )) {
2339
+ err = _Py_InitializeMainInterpreter (& pymain -> config );
2340
+ if (_Py_INIT_FAILED (err )) {
2341
+ pymain -> err = err ;
2361
2342
return -1 ;
2362
2343
}
2363
2344
Original file line number Diff line number Diff line change @@ -1173,7 +1173,7 @@ create_filter(PyObject *category, _Py_Identifier *id)
1173
1173
1174
1174
1175
1175
static PyObject *
1176
- init_filters (const _PyCoreConfig * config )
1176
+ init_filters (void )
1177
1177
{
1178
1178
#ifdef Py_DEBUG
1179
1179
/* Py_DEBUG builds show all warnings by default */
@@ -1218,8 +1218,8 @@ static struct PyModuleDef warningsmodule = {
1218
1218
};
1219
1219
1220
1220
1221
- PyObject *
1222
- _PyWarnings_InitWithConfig ( const _PyCoreConfig * config )
1221
+ PyMODINIT_FUNC
1222
+ _PyWarnings_Init ( void )
1223
1223
{
1224
1224
PyObject * m ;
1225
1225
@@ -1228,7 +1228,7 @@ _PyWarnings_InitWithConfig(const _PyCoreConfig *config)
1228
1228
return NULL ;
1229
1229
1230
1230
if (_PyRuntime .warnings .filters == NULL ) {
1231
- _PyRuntime .warnings .filters = init_filters (config );
1231
+ _PyRuntime .warnings .filters = init_filters ();
1232
1232
if (_PyRuntime .warnings .filters == NULL )
1233
1233
return NULL ;
1234
1234
}
@@ -1259,12 +1259,3 @@ _PyWarnings_InitWithConfig(const _PyCoreConfig *config)
1259
1259
_PyRuntime .warnings .filters_version = 0 ;
1260
1260
return m ;
1261
1261
}
1262
-
1263
-
1264
- PyMODINIT_FUNC
1265
- _PyWarnings_Init (void )
1266
- {
1267
- PyInterpreterState * interp = PyThreadState_GET ()-> interp ;
1268
- const _PyCoreConfig * config = & interp -> core_config ;
1269
- return _PyWarnings_InitWithConfig (config );
1270
- }
Original file line number Diff line number Diff line change @@ -737,7 +737,7 @@ _Py_InitializeCore(const _PyCoreConfig *core_config)
737
737
}
738
738
739
739
/* Initialize _warnings. */
740
- if (_PyWarnings_InitWithConfig ( & interp -> core_config ) == NULL ) {
740
+ if (_PyWarnings_Init ( ) == NULL ) {
741
741
return _Py_INIT_ERR ("can't initialize warnings" );
742
742
}
743
743
@@ -847,7 +847,9 @@ _Py_InitializeMainInterpreter(const _PyMainInterpreterConfig *config)
847
847
}
848
848
849
849
/* Initialize warnings. */
850
- if (PySys_HasWarnOptions ()) {
850
+ if (interp -> config .warnoptions != NULL &&
851
+ PyList_Size (interp -> config .warnoptions ) > 0 )
852
+ {
851
853
PyObject * warnings_module = PyImport_ImportModule ("warnings" );
852
854
if (warnings_module == NULL ) {
853
855
fprintf (stderr , "'import warnings' failed; traceback:\n" );
@@ -1021,9 +1023,15 @@ Py_FinalizeEx(void)
1021
1023
1022
1024
/* Copy the core config, PyInterpreterState_Delete() free
1023
1025
the core config memory */
1026
+ #ifdef Py_REF_DEBUG
1024
1027
int show_ref_count = interp -> core_config .show_ref_count ;
1028
+ #endif
1029
+ #ifdef Py_TRACE_REFS
1025
1030
int dump_refs = interp -> core_config .dump_refs ;
1031
+ #endif
1032
+ #ifdef WITH_PYMALLOC
1026
1033
int malloc_stats = interp -> core_config .malloc_stats ;
1034
+ #endif
1027
1035
1028
1036
/* Remaining threads (e.g. daemon threads) will automatically exit
1029
1037
after taking the GIL (in PyEval_RestoreThread()). */
You can’t perform that action at this time.
0 commit comments