[Python-checkins] bpo-40268: Remove unused osdefs.h includes (GH-19532)

Victor Stinner webhook-mailer at python.org
Tue Apr 14 21:25:01 EDT 2020


https://github.com/python/cpython/commit/361dcdcefc80f5729ed18ac0ef73327794fbf400
commit: 361dcdcefc80f5729ed18ac0ef73327794fbf400
branch: master
author: Victor Stinner <vstinner at python.org>
committer: GitHub <noreply at github.com>
date: 2020-04-15T03:24:57+02:00
summary:

bpo-40268: Remove unused osdefs.h includes (GH-19532)

When the include is needed, add required symbol in a comment.

files:
M Modules/_tracemalloc.c
M Modules/getpath.c
M Modules/posixmodule.c
M Modules/syslogmodule.c
M Objects/exceptions.c
M PC/getpathp.c
M Python/fileutils.c
M Python/import.c
M Python/pathconfig.c
M Python/pylifecycle.c
M Python/pythonrun.c
M Python/sysmodule.c
M Python/traceback.c

diff --git a/Modules/_tracemalloc.c b/Modules/_tracemalloc.c
index 691de07b9b3c6..dbae107c2da20 100644
--- a/Modules/_tracemalloc.c
+++ b/Modules/_tracemalloc.c
@@ -4,7 +4,6 @@
 #include "pycore_traceback.h"
 #include "hashtable.h"
 #include "frameobject.h"
-#include "osdefs.h"
 
 #include "clinic/_tracemalloc.c.h"
 /*[clinic input]
diff --git a/Modules/getpath.c b/Modules/getpath.c
index 1dd8dd0134e7c..94e06b3e3e86b 100644
--- a/Modules/getpath.c
+++ b/Modules/getpath.c
@@ -4,7 +4,7 @@
 #include "pycore_fileutils.h"
 #include "pycore_initconfig.h"
 #include "pycore_pathconfig.h"
-#include "osdefs.h"
+#include "osdefs.h"               // DELIM
 
 #include <sys/types.h>
 #include <string.h>
diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c
index f5beb09240130..89f9757c515bb 100644
--- a/Modules/posixmodule.c
+++ b/Modules/posixmodule.c
@@ -312,11 +312,11 @@ extern char        *ctermid_r(char *);
 #ifndef IO_REPARSE_TAG_MOUNT_POINT
 #define IO_REPARSE_TAG_MOUNT_POINT (0xA0000003L)
 #endif
-#include "osdefs.h"
+#include "osdefs.h"               // SEP
 #include <malloc.h>
 #include <windows.h>
-#include <shellapi.h>   /* for ShellExecute() */
-#include <lmcons.h>     /* for UNLEN */
+#include <shellapi.h>             // ShellExecute()
+#include <lmcons.h>               // UNLEN
 #define HAVE_SYMLINK
 #endif /* _MSC_VER */
 
diff --git a/Modules/syslogmodule.c b/Modules/syslogmodule.c
index 24517925c32eb..11718e277432f 100644
--- a/Modules/syslogmodule.c
+++ b/Modules/syslogmodule.c
@@ -50,7 +50,7 @@ Revision history:
 /* syslog module */
 
 #include "Python.h"
-#include "osdefs.h"
+#include "osdefs.h"               // SEP
 
 #include <syslog.h>
 
diff --git a/Objects/exceptions.c b/Objects/exceptions.c
index 69a6b5c284dfa..ca917b436c4bb 100644
--- a/Objects/exceptions.c
+++ b/Objects/exceptions.c
@@ -9,7 +9,7 @@
 #include "pycore_initconfig.h"
 #include "pycore_object.h"
 #include "structmember.h"         // PyMemberDef
-#include "osdefs.h"
+#include "osdefs.h"               // SEP
 
 
 /* Compatibility aliases */
@@ -1435,11 +1435,13 @@ my_basename(PyObject *name)
     size = PyUnicode_GET_LENGTH(name);
     offset = 0;
     for(i=0; i < size; i++) {
-        if (PyUnicode_READ(kind, data, i) == SEP)
+        if (PyUnicode_READ(kind, data, i) == SEP) {
             offset = i + 1;
+        }
     }
-    if (offset != 0)
+    if (offset != 0) {
         return PyUnicode_Substring(name, offset, size);
+    }
     else {
         Py_INCREF(name);
         return name;
diff --git a/PC/getpathp.c b/PC/getpathp.c
index 24a9323e6e67e..d23d2bbde809f 100644
--- a/PC/getpathp.c
+++ b/PC/getpathp.c
@@ -80,9 +80,9 @@
 
 
 #include "Python.h"
-#include "pycore_initconfig.h"   /* PyStatus */
-#include "pycore_pathconfig.h"   /* _PyPathConfig */
-#include "osdefs.h"
+#include "pycore_initconfig.h"    // PyStatus
+#include "pycore_pathconfig.h"    // _PyPathConfig
+#include "osdefs.h"               // SEP, ALTSEP
 #include <wchar.h>
 
 #ifndef MS_WINDOWS
diff --git a/Python/fileutils.c b/Python/fileutils.c
index 19ead9d676c7f..439bc351596f7 100644
--- a/Python/fileutils.c
+++ b/Python/fileutils.c
@@ -1,6 +1,6 @@
 #include "Python.h"
 #include "pycore_fileutils.h"
-#include "osdefs.h"
+#include "osdefs.h"               // SEP
 #include <locale.h>
 
 #ifdef MS_WINDOWS
diff --git a/Python/import.c b/Python/import.c
index a2aa4afa18a72..a8743458dd5c9 100644
--- a/Python/import.c
+++ b/Python/import.c
@@ -16,7 +16,6 @@
 #include "marshal.h"
 #include "code.h"
 #include "frameobject.h"
-#include "osdefs.h"
 #include "importdl.h"
 #include "pydtrace.h"
 
diff --git a/Python/pathconfig.c b/Python/pathconfig.c
index 6ebfdac3fd2d3..fe3ac3ee3d812 100644
--- a/Python/pathconfig.c
+++ b/Python/pathconfig.c
@@ -1,7 +1,7 @@
 /* Path configuration like module_search_path (sys.path) */
 
 #include "Python.h"
-#include "osdefs.h"
+#include "osdefs.h"               // DELIM
 #include "pycore_initconfig.h"
 #include "pycore_fileutils.h"
 #include "pycore_pathconfig.h"
diff --git a/Python/pylifecycle.c b/Python/pylifecycle.c
index 9c13274dac04d..688ee0c133b1e 100644
--- a/Python/pylifecycle.c
+++ b/Python/pylifecycle.c
@@ -26,7 +26,6 @@
 #include "symtable.h"
 #include "ast.h"
 #include "marshal.h"
-#include "osdefs.h"
 #include <locale.h>
 
 #ifdef HAVE_SIGNAL_H
diff --git a/Python/pythonrun.c b/Python/pythonrun.c
index 246669994c4dd..d6bc88320358c 100644
--- a/Python/pythonrun.c
+++ b/Python/pythonrun.c
@@ -27,7 +27,6 @@
 #include "symtable.h"
 #include "ast.h"
 #include "marshal.h"
-#include "osdefs.h"
 #include <locale.h>
 
 #ifdef HAVE_SIGNAL_H
diff --git a/Python/sysmodule.c b/Python/sysmodule.c
index 4e67325318aaf..92ea5e7d637b9 100644
--- a/Python/sysmodule.c
+++ b/Python/sysmodule.c
@@ -26,9 +26,9 @@ Data members:
 #include "pycore_pymem.h"         // _PyMem_SetDefaultAllocator()
 #include "pycore_pystate.h"       // _PyThreadState_GET()
 #include "pycore_tupleobject.h"
-#include "pydtrace.h"
 
-#include "osdefs.h"
+#include "pydtrace.h"
+#include "osdefs.h"               // DELIM
 #include <locale.h>
 
 #ifdef MS_WINDOWS
diff --git a/Python/traceback.c b/Python/traceback.c
index e3397ecfe48f5..85e9124bb6a68 100644
--- a/Python/traceback.c
+++ b/Python/traceback.c
@@ -6,7 +6,7 @@
 #include "code.h"
 #include "frameobject.h"
 #include "structmember.h"         // PyMemberDef
-#include "osdefs.h"
+#include "osdefs.h"               // SEP
 #ifdef HAVE_FCNTL_H
 #include <fcntl.h>
 #endif



More information about the Python-checkins mailing list