Skip to content

Commit

Permalink
bpo-40268: Remove unused structmember.h includes (pythonGH-19530)
Browse files Browse the repository at this point in the history
If only offsetof() is needed: include stddef.h instead.

When structmember.h is used, add a comment explaining that
PyMemberDef is used.
  • Loading branch information
vstinner authored Apr 15, 2020
1 parent 62183b8 commit 4a21e57
Show file tree
Hide file tree
Showing 78 changed files with 99 additions and 111 deletions.
1 change: 0 additions & 1 deletion Modules/_abc.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
/* ABCMeta implementation */

#include "Python.h"
#include "structmember.h"
#include "clinic/_abc.c.h"

/*[clinic input]
Expand Down
2 changes: 1 addition & 1 deletion Modules/_asynciomodule.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include "Python.h"
#include "structmember.h"
#include <stddef.h> // offsetof()


/*[clinic input]
Expand Down
2 changes: 1 addition & 1 deletion Modules/_bz2module.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#define PY_SSIZE_T_CLEAN

#include "Python.h"
#include "structmember.h"
#include "structmember.h" // PyMemberDef

#include <bzlib.h>
#include <stdio.h>
Expand Down
4 changes: 2 additions & 2 deletions Modules/_collectionsmodule.c
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
#include "Python.h"
#include "structmember.h"
#include "structmember.h" // PyMemberDef

#ifdef STDC_HEADERS
#include <stddef.h>
#else
#include <sys/types.h> /* For size_t */
#include <sys/types.h> // size_t
#endif

/*[clinic input]
Expand Down
2 changes: 1 addition & 1 deletion Modules/_csv.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ module instead.
#define MODULE_VERSION "1.0"

#include "Python.h"
#include "structmember.h"
#include "structmember.h" // PyMemberDef
#include <stdbool.h>


Expand Down
2 changes: 1 addition & 1 deletion Modules/_ctypes/_ctypes.c
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ bytes(cdata)
#define PY_SSIZE_T_CLEAN

#include "Python.h"
#include "structmember.h"
#include "structmember.h" // PyMemberDef

#include <ffi.h>
#ifdef MS_WIN32
Expand Down
4 changes: 2 additions & 2 deletions Modules/_ctypes/callproc.c
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
*/

#include "Python.h"
#include "structmember.h"
#include "structmember.h" // PyMemberDef

#ifdef MS_WIN32
#include <windows.h>
Expand Down Expand Up @@ -751,7 +751,7 @@ static int ConvParam(PyObject *obj, Py_ssize_t index, struct argument *pa)
#if defined(MS_WIN32) && !defined(_WIN32_WCE)
/*
Per: https://msdn.microsoft.com/en-us/library/7572ztz4.aspx
To be returned by value in RAX, user-defined types must have a length
To be returned by value in RAX, user-defined types must have a length
of 1, 2, 4, 8, 16, 32, or 64 bits
*/
int can_return_struct_as_int(size_t s)
Expand Down
2 changes: 1 addition & 1 deletion Modules/_datetimemodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

#include "Python.h"
#include "datetime.h"
#include "structmember.h"
#include "structmember.h" // PyMemberDef

#include <time.h>

Expand Down
1 change: 0 additions & 1 deletion Modules/_decimal/_decimal.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@

#include <Python.h>
#include "longintrepr.h"
#include "structmember.h"
#include "complexobject.h"
#include "mpdecimal.h"

Expand Down
2 changes: 1 addition & 1 deletion Modules/_elementtree.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
#define PY_SSIZE_T_CLEAN

#include "Python.h"
#include "structmember.h"
#include "structmember.h" // PyMemberDef

/* -------------------------------------------------------------------- */
/* configuration */
Expand Down
4 changes: 2 additions & 2 deletions Modules/_functoolsmodule.c
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#include "Python.h"
#include "pycore_pymem.h"
#include "pycore_pystate.h" // _PyThreadState_GET()
#include "pycore_pystate.h" // _PyThreadState_GET()
#include "pycore_tupleobject.h"
#include "structmember.h"
#include "structmember.h" // PyMemberDef

/* _functools module written and maintained
by Hye-Shik Chang <[email protected]>
Expand Down
1 change: 0 additions & 1 deletion Modules/_hashopenssl.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
#define PY_SSIZE_T_CLEAN

#include "Python.h"
#include "structmember.h"
#include "hashlib.h"
#include "pystrhex.h"

Expand Down
1 change: 0 additions & 1 deletion Modules/_io/_iomodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@

#define PY_SSIZE_T_CLEAN
#include "Python.h"
#include "structmember.h"
#include "_iomodule.h"

#ifdef HAVE_SYS_TYPES_H
Expand Down
2 changes: 1 addition & 1 deletion Modules/_io/bufferedio.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#define PY_SSIZE_T_CLEAN
#include "Python.h"
#include "pycore_object.h"
#include "structmember.h"
#include "structmember.h" // PyMemberDef
#include "_iomodule.h"

/*[clinic input]
Expand Down
2 changes: 1 addition & 1 deletion Modules/_io/bytesio.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include "Python.h"
#include "pycore_object.h"
#include "structmember.h" /* for offsetof() */
#include <stddef.h> // offsetof()
#include "_iomodule.h"

/*[clinic input]
Expand Down
2 changes: 1 addition & 1 deletion Modules/_io/fileio.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#define PY_SSIZE_T_CLEAN
#include "Python.h"
#include "pycore_object.h"
#include "structmember.h"
#include "structmember.h" // PyMemberDef
#include <stdbool.h>
#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
Expand Down
2 changes: 1 addition & 1 deletion Modules/_io/iobase.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#define PY_SSIZE_T_CLEAN
#include "Python.h"
#include "pycore_object.h"
#include "structmember.h"
#include <stddef.h> // offsetof()
#include "_iomodule.h"

/*[clinic input]
Expand Down
2 changes: 1 addition & 1 deletion Modules/_io/stringio.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#define PY_SSIZE_T_CLEAN
#include "Python.h"
#include "structmember.h"
#include <stddef.h> // offsetof()
#include "pycore_accu.h"
#include "pycore_object.h"
#include "_iomodule.h"
Expand Down
6 changes: 3 additions & 3 deletions Modules/_io/textio.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@

#define PY_SSIZE_T_CLEAN
#include "Python.h"
#include "pycore_interp.h" // PyInterpreterState.fs_codec
#include "pycore_interp.h" // PyInterpreterState.fs_codec
#include "pycore_object.h"
#include "pycore_pystate.h" // _PyInterpreterState_GET()
#include "structmember.h"
#include "pycore_pystate.h" // _PyInterpreterState_GET()
#include "structmember.h" // PyMemberDef
#include "_iomodule.h"

/*[clinic input]
Expand Down
2 changes: 1 addition & 1 deletion Modules/_io/winconsoleio.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

#ifdef MS_WINDOWS

#include "structmember.h"
#include "structmember.h" // PyMemberDef
#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif
Expand Down
2 changes: 1 addition & 1 deletion Modules/_json.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#endif

#include "Python.h"
#include "structmember.h"
#include "structmember.h" // PyMemberDef
#include "pycore_accu.h"

typedef struct {
Expand Down
2 changes: 1 addition & 1 deletion Modules/_lzmamodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#define PY_SSIZE_T_CLEAN

#include "Python.h"
#include "structmember.h"
#include "structmember.h" // PyMemberDef

#include <stdarg.h>
#include <string.h>
Expand Down
1 change: 0 additions & 1 deletion Modules/_multiprocessing/posixshmem.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ posixshmem - A Python extension that provides shm_open() and shm_unlink()
#define PY_SSIZE_T_CLEAN

#include <Python.h>
#include "structmember.h"

// for shm_open() and shm_unlink()
#ifdef HAVE_SYS_MMAN_H
Expand Down
2 changes: 1 addition & 1 deletion Modules/_pickle.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#endif

#include "Python.h"
#include "structmember.h"
#include "structmember.h" // PyMemberDef

PyDoc_STRVAR(pickle_module_doc,
"Optimized C implementation for the Python pickle module.");
Expand Down
2 changes: 1 addition & 1 deletion Modules/_queuemodule.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include "Python.h"
#include "structmember.h" /* offsetof */
#include <stddef.h> // offsetof()

/*[clinic input]
module _queue
Expand Down
2 changes: 1 addition & 1 deletion Modules/_sqlite/connection.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

#include "cache.h"
#include "module.h"
#include "structmember.h"
#include "structmember.h" // PyMemberDef
#include "connection.h"
#include "statement.h"
#include "cursor.h"
Expand Down
1 change: 0 additions & 1 deletion Modules/_sqlite/microprotocols.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
*/

#include <Python.h>
#include <structmember.h>

#include "cursor.h"
#include "microprotocols.h"
Expand Down
2 changes: 1 addition & 1 deletion Modules/_sre.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ static const char copyright[] =
#define PY_SSIZE_T_CLEAN

#include "Python.h"
#include "structmember.h" /* offsetof */
#include "structmember.h" // PyMemberDef

#include "sre.h"

Expand Down
1 change: 0 additions & 1 deletion Modules/_statisticsmodule.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
/* statistics accelerator C extension: _statistics module. */

#include "Python.h"
#include "structmember.h"
#include "clinic/_statisticsmodule.c.h"

/*[clinic input]
Expand Down
2 changes: 1 addition & 1 deletion Modules/_struct.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#define PY_SSIZE_T_CLEAN

#include "Python.h"
#include "structmember.h"
#include "structmember.h" // PyMemberDef
#include <ctype.h>

/*[clinic input]
Expand Down
2 changes: 1 addition & 1 deletion Modules/_testcapimodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
#include "Python.h"
#include "datetime.h"
#include "marshal.h"
#include "structmember.h"
#include "structmember.h" // PyMemberDef
#include <float.h>
#include <signal.h>

Expand Down
8 changes: 3 additions & 5 deletions Modules/_threadmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@

#include "Python.h"
#include "pycore_pylifecycle.h"
#include "pycore_interp.h" // _PyInterpreterState.num_threads
#include "pycore_pystate.h" // _PyThreadState_Init()
#include <stddef.h> // offsetof()
#include "pycore_interp.h" // _PyInterpreterState.num_threads
#include "pycore_pystate.h" // _PyThreadState_Init()
#include <stddef.h> // offsetof()

static PyObject *ThreadError;
static PyObject *str_dict;
Expand Down Expand Up @@ -587,8 +587,6 @@ newlockobject(void)

/* Thread-local objects */

#include "structmember.h"

/* Quick overview:
We need to be able to reclaim reference cycles as soon as possible
Expand Down
6 changes: 3 additions & 3 deletions Modules/_winapi.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
/* See http://www.python.org/2.4/license for licensing details. */

#include "Python.h"
#include "structmember.h"
#include "structmember.h" // PyMemberDef

#define WINDOWS_LEAN_AND_MEAN
#include "windows.h"
Expand Down Expand Up @@ -1110,8 +1110,8 @@ _winapi_CreateProcess_impl(PyObject *module,
}
}
else if (command_line != Py_None) {
PyErr_Format(PyExc_TypeError,
"CreateProcess() argument 2 must be str or None, not %s",
PyErr_Format(PyExc_TypeError,
"CreateProcess() argument 2 must be str or None, not %s",
Py_TYPE(command_line)->tp_name);
goto cleanup;
}
Expand Down
2 changes: 1 addition & 1 deletion Modules/arraymodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

#define PY_SSIZE_T_CLEAN
#include "Python.h"
#include "structmember.h"
#include <stddef.h> // offsetof()

#ifdef STDC_HEADERS
#include <stddef.h>
Expand Down
2 changes: 1 addition & 1 deletion Modules/cjkcodecs/multibytecodec.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

#define PY_SSIZE_T_CLEAN
#include "Python.h"
#include "structmember.h"
#include "structmember.h" // PyMemberDef
#include "multibytecodec.h"
#include "clinic/multibytecodec.c.h"

Expand Down
2 changes: 1 addition & 1 deletion Modules/itertoolsmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#define PY_SSIZE_T_CLEAN
#include "Python.h"
#include "pycore_tupleobject.h"
#include "structmember.h"
#include <stddef.h> // offsetof()

/* Itertools module written and maintained
by Raymond D. Hettinger <[email protected]>
Expand Down
2 changes: 1 addition & 1 deletion Modules/mmapmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

#define PY_SSIZE_T_CLEAN
#include <Python.h>
#include "structmember.h"
#include <stddef.h> // offsetof()

#ifndef MS_WINDOWS
#define UNIX
Expand Down
2 changes: 1 addition & 1 deletion Modules/ossaudiodev.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

#define PY_SSIZE_T_CLEAN
#include "Python.h"
#include "structmember.h"
#include "structmember.h" // PyMemberDef

#ifdef HAVE_FCNTL_H
#include <fcntl.h>
Expand Down
2 changes: 1 addition & 1 deletion Modules/overlapped.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
Check itemsize */

#include "Python.h"
#include "structmember.h"
#include "structmember.h" // PyMemberDef

#define WINDOWS_LEAN_AND_MEAN
#include <winsock2.h>
Expand Down
8 changes: 4 additions & 4 deletions Modules/posixmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@
# include <windows.h>
#endif

#include "pycore_ceval.h" /* _PyEval_ReInitThreads() */
#include "pycore_import.h" /* _PyImport_ReInitLock() */
#include "pycore_pystate.h" /* _PyInterpreterState_GET() */
#include "structmember.h"
#include "pycore_ceval.h" // _PyEval_ReInitThreads()
#include "pycore_import.h" // _PyImport_ReInitLock()
#include "pycore_pystate.h" // _PyInterpreterState_GET()
#include "structmember.h" // PyMemberDef
#ifndef MS_WINDOWS
# include "posixmodule.h"
#else
Expand Down
Loading

0 comments on commit 4a21e57

Please sign in to comment.