Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit b45d259

Browse filesBrowse files
authored
bpo-36710: Use tstate in pylifecycle.c (GH-14249)
In pylifecycle.c: pass tstate argument, rather than interp argument, to functions.
1 parent 35068bd commit b45d259
Copy full SHA for b45d259

File tree

Expand file treeCollapse file tree

8 files changed

+120
-108
lines changed
Filter options
Expand file treeCollapse file tree

8 files changed

+120
-108
lines changed

‎Include/internal/pycore_pylifecycle.h

Copy file name to clipboardExpand all lines: Include/internal/pycore_pylifecycle.h
+5-6Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ extern int _Py_SetFileSystemEncoding(
2121
const char *encoding,
2222
const char *errors);
2323
extern void _Py_ClearFileSystemEncoding(void);
24-
extern PyStatus _PyUnicode_InitEncodings(PyInterpreterState *interp);
24+
extern PyStatus _PyUnicode_InitEncodings(PyThreadState *tstate);
2525
#ifdef MS_WINDOWS
2626
extern int _PyUnicode_EnableLegacyWindowsFSEncoding(void);
2727
#endif
@@ -37,20 +37,20 @@ extern int _PyStructSequence_Init(void);
3737
extern int _PyLong_Init(void);
3838
extern PyStatus _PyFaulthandler_Init(int enable);
3939
extern int _PyTraceMalloc_Init(int enable);
40-
extern PyObject * _PyBuiltin_Init(void);
40+
extern PyObject * _PyBuiltin_Init(PyThreadState *tstate);
4141
extern PyStatus _PySys_Create(
4242
_PyRuntimeState *runtime,
43-
PyInterpreterState *interp,
43+
PyThreadState *tstate,
4444
PyObject **sysmod_p);
4545
extern PyStatus _PySys_SetPreliminaryStderr(PyObject *sysdict);
4646
extern int _PySys_InitMain(
4747
_PyRuntimeState *runtime,
4848
PyThreadState *tstate);
49-
extern PyStatus _PyImport_Init(PyInterpreterState *interp);
49+
extern PyStatus _PyImport_Init(PyThreadState *tstate);
5050
extern PyStatus _PyExc_Init(void);
5151
extern PyStatus _PyErr_Init(void);
5252
extern PyStatus _PyBuiltins_AddExceptions(PyObject * bltinmod);
53-
extern PyStatus _PyImportHooks_Init(void);
53+
extern PyStatus _PyImportHooks_Init(PyThreadState *tstate);
5454
extern int _PyFloat_Init(void);
5555
extern PyStatus _Py_HashRandomization_Init(const PyConfig *);
5656

@@ -88,7 +88,6 @@ extern void _PyWarnings_Fini(PyInterpreterState *interp);
8888

8989
extern void _PyGILState_Init(
9090
_PyRuntimeState *runtime,
91-
PyInterpreterState *interp,
9291
PyThreadState *tstate);
9392
extern void _PyGILState_Fini(_PyRuntimeState *runtime);
9493

‎Include/internal/pycore_pystate.h

Copy file name to clipboardExpand all lines: Include/internal/pycore_pystate.h
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,7 @@ PyAPI_FUNC(PyThreadState *) _PyThreadState_Swap(
310310
PyAPI_FUNC(PyStatus) _PyInterpreterState_Enable(_PyRuntimeState *runtime);
311311
PyAPI_FUNC(void) _PyInterpreterState_DeleteExceptMain(_PyRuntimeState *runtime);
312312

313-
/* Used by PyImport_Cleanup() */
313+
/* Used by _PyImport_Cleanup() */
314314
extern void _PyInterpreterState_ClearModules(PyInterpreterState *interp);
315315

316316
PyAPI_FUNC(void) _PyGILState_Reinit(_PyRuntimeState *runtime);

‎Objects/unicodeobject.c

Copy file name to clipboardExpand all lines: Objects/unicodeobject.c
+3-1Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15792,8 +15792,10 @@ init_fs_encoding(PyInterpreterState *interp)
1579215792

1579315793

1579415794
PyStatus
15795-
_PyUnicode_InitEncodings(PyInterpreterState *interp)
15795+
_PyUnicode_InitEncodings(PyThreadState *tstate)
1579615796
{
15797+
PyInterpreterState *interp = tstate->interp;
15798+
1579715799
PyStatus status = init_fs_encoding(interp);
1579815800
if (_PyStatus_EXCEPTION(status)) {
1579915801
return status;

‎Python/bltinmodule.c

Copy file name to clipboardExpand all lines: Python/bltinmodule.c
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2769,11 +2769,11 @@ static struct PyModuleDef builtinsmodule = {
27692769

27702770

27712771
PyObject *
2772-
_PyBuiltin_Init(void)
2772+
_PyBuiltin_Init(PyThreadState *tstate)
27732773
{
27742774
PyObject *mod, *dict, *debug;
27752775

2776-
const PyConfig *config = &_PyInterpreterState_GET_UNSAFE()->config;
2776+
const PyConfig *config = &tstate->interp->config;
27772777

27782778
if (PyType_Ready(&PyFilter_Type) < 0 ||
27792779
PyType_Ready(&PyMap_Type) < 0 ||

‎Python/import.c

Copy file name to clipboardExpand all lines: Python/import.c
+5-4Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,9 @@ module _imp
4848
/* Initialize things */
4949

5050
PyStatus
51-
_PyImport_Init(PyInterpreterState *interp)
51+
_PyImport_Init(PyThreadState *tstate)
5252
{
53+
PyInterpreterState *interp = tstate->interp;
5354
interp->builtins_copy = PyDict_Copy(interp->builtins);
5455
if (interp->builtins_copy == NULL) {
5556
return _PyStatus_ERR("Can't backup builtins dict");
@@ -58,7 +59,7 @@ _PyImport_Init(PyInterpreterState *interp)
5859
}
5960

6061
PyStatus
61-
_PyImportHooks_Init(void)
62+
_PyImportHooks_Init(PyThreadState *tstate)
6263
{
6364
PyObject *v, *path_hooks = NULL;
6465
int err = 0;
@@ -89,7 +90,7 @@ _PyImportHooks_Init(void)
8990
return _PyStatus_OK();
9091

9192
error:
92-
PyErr_Print();
93+
_PyErr_Print(tstate);
9394
return _PyStatus_ERR("initializing sys.meta_path, sys.path_hooks, "
9495
"or path_importer_cache failed");
9596
}
@@ -554,7 +555,7 @@ _PyImport_Cleanup(PyThreadState *tstate)
554555
}
555556
Py_XDECREF(dict);
556557
/* Clear module dict copies stored in the interpreter state */
557-
_PyInterpreterState_ClearModules(tstate->interp);
558+
_PyInterpreterState_ClearModules(interp);
558559
/* Collect references */
559560
_PyGC_CollectNoFail();
560561
/* Dump GC stats before it's too late, since it uses the warnings

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.