[Python-checkins] bpo-45459: Use type names in the internal C API (GH-31669)

vstinner webhook-mailer at python.org
Thu Mar 3 17:08:17 EST 2022


https://github.com/python/cpython/commit/32f0c8271706550096c454eb512450b85fbfc320
commit: 32f0c8271706550096c454eb512450b85fbfc320
branch: main
author: Victor Stinner <vstinner at python.org>
committer: vstinner <vstinner at python.org>
date: 2022-03-03T23:08:07+01:00
summary:

bpo-45459: Use type names in the internal C API (GH-31669)

Replace "struct xxx" with "xxx" types in the internal C API.

files:
M Include/internal/pycore_interp.h
M Include/internal/pycore_moduleobject.h
M Include/internal/pycore_pystate.h
M Include/internal/pycore_runtime.h
M Include/internal/pycore_traceback.h

diff --git a/Include/internal/pycore_interp.h b/Include/internal/pycore_interp.h
index 77e42b65f5d3c..db8edffda8bb9 100644
--- a/Include/internal/pycore_interp.h
+++ b/Include/internal/pycore_interp.h
@@ -79,12 +79,12 @@ struct atexit_state {
    */
 struct _is {
 
-    struct _is *next;
+    PyInterpreterState *next;
 
     struct pythreads {
         uint64_t next_unique_id;
         /* The linked list of threads, newest first. */
-        struct _ts *head;
+        PyThreadState *head;
         /* Used in Modules/_threadmodule.c. */
         long count;
         /* Support for runtime thread stack size tuning.
@@ -190,7 +190,7 @@ struct _is {
        */
 
     /* the initial PyInterpreterState.threads.head */
-    struct _ts _initial_thread;
+    PyThreadState _initial_thread;
 };
 
 
@@ -214,11 +214,11 @@ struct _xidregitem {
     struct _xidregitem *next;
 };
 
-PyAPI_FUNC(struct _is*) _PyInterpreterState_LookUpID(int64_t);
+PyAPI_FUNC(PyInterpreterState*) _PyInterpreterState_LookUpID(int64_t);
 
-PyAPI_FUNC(int) _PyInterpreterState_IDInitref(struct _is *);
-PyAPI_FUNC(int) _PyInterpreterState_IDIncref(struct _is *);
-PyAPI_FUNC(void) _PyInterpreterState_IDDecref(struct _is *);
+PyAPI_FUNC(int) _PyInterpreterState_IDInitref(PyInterpreterState *);
+PyAPI_FUNC(int) _PyInterpreterState_IDIncref(PyInterpreterState *);
+PyAPI_FUNC(void) _PyInterpreterState_IDDecref(PyInterpreterState *);
 
 #ifdef __cplusplus
 }
diff --git a/Include/internal/pycore_moduleobject.h b/Include/internal/pycore_moduleobject.h
index e9978abd25b10..76361b8dff113 100644
--- a/Include/internal/pycore_moduleobject.h
+++ b/Include/internal/pycore_moduleobject.h
@@ -11,7 +11,7 @@ extern "C" {
 typedef struct {
     PyObject_HEAD
     PyObject *md_dict;
-    struct PyModuleDef *md_def;
+    PyModuleDef *md_def;
     void *md_state;
     PyObject *md_weaklist;
     // for logging purposes after md_dict is cleared
diff --git a/Include/internal/pycore_pystate.h b/Include/internal/pycore_pystate.h
index 06f58fb5100f0..f0c238a608b10 100644
--- a/Include/internal/pycore_pystate.h
+++ b/Include/internal/pycore_pystate.h
@@ -172,7 +172,7 @@ extern void _PySignal_AfterFork(void);
 PyAPI_FUNC(int) _PyState_AddModule(
     PyThreadState *tstate,
     PyObject* module,
-    struct PyModuleDef* def);
+    PyModuleDef* def);
 
 
 PyAPI_FUNC(int) _PyOS_InterruptOccurred(PyThreadState *tstate);
diff --git a/Include/internal/pycore_runtime.h b/Include/internal/pycore_runtime.h
index 038e6f8263fae..18191c3771dfc 100644
--- a/Include/internal/pycore_runtime.h
+++ b/Include/internal/pycore_runtime.h
@@ -11,7 +11,7 @@ extern "C" {
 #include "pycore_atomic.h"          /* _Py_atomic_address */
 #include "pycore_gil.h"             // struct _gil_runtime_state
 #include "pycore_global_objects.h"  // struct _Py_global_objects
-#include "pycore_interp.h"          // struct _is
+#include "pycore_interp.h"          // PyInterpreterState
 #include "pycore_unicodeobject.h"   // struct _Py_unicode_runtime_ids
 
 
diff --git a/Include/internal/pycore_traceback.h b/Include/internal/pycore_traceback.h
index 84dbe27044fd3..c393b2c136f2d 100644
--- a/Include/internal/pycore_traceback.h
+++ b/Include/internal/pycore_traceback.h
@@ -8,9 +8,6 @@ extern "C" {
 #  error "this header requires Py_BUILD_CORE define"
 #endif
 
-/* Forward declaration */
-struct _is;
-
 /* Write the Python traceback into the file 'fd'. For example:
 
        Traceback (most recent call first):
@@ -57,7 +54,7 @@ PyAPI_FUNC(void) _Py_DumpTraceback(
 
 PyAPI_FUNC(const char*) _Py_DumpTracebackThreads(
     int fd,
-    struct _is *interp,
+    PyInterpreterState *interp,
     PyThreadState *current_tstate);
 
 /* Write a Unicode object into the file descriptor fd. Encode the string to



More information about the Python-checkins mailing list