summaryrefslogtreecommitdiffstats
path: root/Include
diff options
context:
space:
mode:
authorVictor Stinner <vstinner@python.org>2020-06-23 20:55:46 (GMT)
committerGitHub <noreply@github.com>2020-06-23 20:55:46 (GMT)
commit281cce1106568ef9fec17e3c72d289416fac02a5 (patch)
tree529d24e0db048c8914cc8a12ebf7b8328a62665d /Include
parent2c6e4e91c5a4d3f25908108f4ed32aba936df70c (diff)
downloadcpython-281cce1106568ef9fec17e3c72d289416fac02a5.zip
cpython-281cce1106568ef9fec17e3c72d289416fac02a5.tar.gz
cpython-281cce1106568ef9fec17e3c72d289416fac02a5.tar.bz2
bpo-40521: Make MemoryError free list per interpreter (GH-21086)
Each interpreter now has its own MemoryError free list: it is not longer shared by all interpreters. Add _Py_exc_state structure and PyInterpreterState.exc_state member. Move also errnomap into _Py_exc_state.
Diffstat (limited to 'Include')
-rw-r--r--Include/internal/pycore_interp.h8
-rw-r--r--Include/internal/pycore_pylifecycle.h4
2 files changed, 10 insertions, 2 deletions
diff --git a/Include/internal/pycore_interp.h b/Include/internal/pycore_interp.h
index c22bea7..435a72a 100644
--- a/Include/internal/pycore_interp.h
+++ b/Include/internal/pycore_interp.h
@@ -152,6 +152,13 @@ struct _Py_context_state {
int numfree;
};
+struct _Py_exc_state {
+ // The dict mapping from errno codes to OSError subclasses
+ PyObject *errnomap;
+ PyBaseExceptionObject *memerrors_freelist;
+ int memerrors_numfree;
+};
+
/* interpreter state */
@@ -251,6 +258,7 @@ struct _is {
struct _Py_frame_state frame;
struct _Py_async_gen_state async_gen;
struct _Py_context_state context;
+ struct _Py_exc_state exc_state;
};
/* Used by _PyImport_Cleanup() */
diff --git a/Include/internal/pycore_pylifecycle.h b/Include/internal/pycore_pylifecycle.h
index 30ba484..cd47044 100644
--- a/Include/internal/pycore_pylifecycle.h
+++ b/Include/internal/pycore_pylifecycle.h
@@ -43,7 +43,7 @@ extern PyStatus _PySys_Create(
extern PyStatus _PySys_ReadPreinitWarnOptions(PyWideStringList *options);
extern PyStatus _PySys_ReadPreinitXOptions(PyConfig *config);
extern int _PySys_InitMain(PyThreadState *tstate);
-extern PyStatus _PyExc_Init(void);
+extern PyStatus _PyExc_Init(PyThreadState *tstate);
extern PyStatus _PyErr_Init(void);
extern PyStatus _PyBuiltins_AddExceptions(PyObject * bltinmod);
extern PyStatus _PyImportHooks_Init(PyThreadState *tstate);
@@ -69,7 +69,7 @@ extern void _PyAsyncGen_Fini(PyThreadState *tstate);
extern void PyOS_FiniInterrupts(void);
-extern void _PyExc_Fini(void);
+extern void _PyExc_Fini(PyThreadState *tstate);
extern void _PyImport_Fini(void);
extern void _PyImport_Fini2(void);
extern void _PyGC_Fini(PyThreadState *tstate);