bpo-40268: Remove unused structmember.h includes (GH-19530)
If only offsetof() is needed: include stddef.h instead.
When structmember.h is used, add a comment explaining that
PyMemberDef is used.
diff --git a/Python/Python-ast.c b/Python/Python-ast.c
index 488276a..80f9164 100644
--- a/Python/Python-ast.c
+++ b/Python/Python-ast.c
@@ -4,7 +4,7 @@
#include "Python.h"
#include "Python-ast.h"
-#include "structmember.h"
+#include "structmember.h" // PyMemberDef
typedef struct {
int initialized;
diff --git a/Python/ceval.c b/Python/ceval.c
index 5e54356..59765d8 100644
--- a/Python/ceval.c
+++ b/Python/ceval.c
@@ -29,7 +29,6 @@
#include "opcode.h"
#include "pydtrace.h"
#include "setobject.h"
-#include "structmember.h"
#include <ctype.h>
diff --git a/Python/context.c b/Python/context.c
index 15749e9..f0217f2 100644
--- a/Python/context.c
+++ b/Python/context.c
@@ -6,7 +6,7 @@
#include "pycore_object.h"
#include "pycore_pyerrors.h"
#include "pycore_pystate.h" // _PyThreadState_GET()
-#include "structmember.h"
+#include "structmember.h" // PyMemberDef
#define CONTEXT_FREELIST_MAXLEN 255
diff --git a/Python/hamt.c b/Python/hamt.c
index 9924e33..8801c5e 100644
--- a/Python/hamt.c
+++ b/Python/hamt.c
@@ -1,8 +1,8 @@
#include "Python.h"
#include "pycore_hamt.h"
-#include "pycore_object.h" // _PyObject_GC_TRACK()
-#include "structmember.h"
+#include "pycore_object.h" // _PyObject_GC_TRACK()
+#include <stddef.h> // offsetof()
/*
This file provides an implementation of an immutable mapping using the
diff --git a/Python/structmember.c b/Python/structmember.c
index e653d02..ba88e15 100644
--- a/Python/structmember.c
+++ b/Python/structmember.c
@@ -2,8 +2,7 @@
/* Map C struct members to Python object attributes */
#include "Python.h"
-
-#include "structmember.h"
+#include "structmember.h" // PyMemberDef
PyObject *
PyMember_GetOne(const char *addr, PyMemberDef *l)
diff --git a/Python/symtable.c b/Python/symtable.c
index a3c5d65..d192f31 100644
--- a/Python/symtable.c
+++ b/Python/symtable.c
@@ -2,7 +2,7 @@
#include "pycore_pystate.h" // _PyThreadState_GET()
#include "symtable.h"
#undef Yield /* undefine macro conflicting with <winbase.h> */
-#include "structmember.h"
+#include "structmember.h" // PyMemberDef
/* error strings used for warnings */
#define GLOBAL_PARAM \
diff --git a/Python/traceback.c b/Python/traceback.c
index 610c217..e3397ec 100644
--- a/Python/traceback.c
+++ b/Python/traceback.c
@@ -5,7 +5,7 @@
#include "code.h"
#include "frameobject.h"
-#include "structmember.h"
+#include "structmember.h" // PyMemberDef
#include "osdefs.h"
#ifdef HAVE_FCNTL_H
#include <fcntl.h>