]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
bpo-45570: Simplify setup macros for pyexpat (GH-29159)
authorChristian Heimes <christian@python.org>
Fri, 22 Oct 2021 16:28:23 +0000 (19:28 +0300)
committerGitHub <noreply@github.com>
Fri, 22 Oct 2021 16:28:23 +0000 (09:28 -0700)
* ``HAVE_EXPAT_CONFIG_H`` is not used by our code and not used by
  system-wide expat header files
* ``USE_PYEXPAT_CAPI`` is no longer used by our code
* ``XML_POOR_ENTROPY`` should be defined in expat_config.h

Signed-off-by: Christian Heimes <christian@python.org>
Misc/NEWS.d/next/Build/2021-10-22-14-45-40.bpo-45570.61gM2A.rst [new file with mode: 0644]
Modules/Setup
Modules/expat/expat_config.h
PCbuild/_elementtree.vcxproj
PCbuild/pyexpat.vcxproj
setup.py

diff --git a/Misc/NEWS.d/next/Build/2021-10-22-14-45-40.bpo-45570.61gM2A.rst b/Misc/NEWS.d/next/Build/2021-10-22-14-45-40.bpo-45570.61gM2A.rst
new file mode 100644 (file)
index 0000000..7de50f9
--- /dev/null
@@ -0,0 +1 @@
+:mod:`pyexpat` and :mod:`_elementtree` no longer define obsolete macros ``HAVE_EXPAT_CONFIG_H`` and ``USE_PYEXPAT_CAPI``. ``XML_POOR_ENTROPY`` is now defined in ``expat_config.h``.
index a5b1a7b9c14afad982f4195d3e3e26fde9bfefe0..d06d733fc9cbb3f13a35e0ae04f4872eabc9b3ea 100644 (file)
@@ -149,7 +149,7 @@ time timemodule.c
 #_contextvars _contextvarsmodule.c
 #_csv _csv.c
 #_datetime _datetimemodule.c
-#_elementtree -DHAVE_EXPAT_CONFIG_H -DUSE_PYEXPAT_CAPI -I$(srcdir)/Modules/expat _elementtree.c
+#_elementtree -I$(srcdir)/Modules/expat _elementtree.c
 #_heapq _heapqmodule.c
 #_json _json.c
 #_lsprof _lsprof.c rotatingtree.c
@@ -173,7 +173,7 @@ time timemodule.c
 #binascii binascii.c
 #cmath cmathmodule.c _math.c  # -lm
 #math mathmodule.c _math.c  # -lm
-#pyexpat -DHAVE_EXPAT_CONFIG_H -DXML_POOR_ENTROPY -DUSE_PYEXPAT_CAPI -I$(srcdir)/Modules/expat  expat/xmlparse.c expat/xmlrole.c expat/xmltok.c pyexpat.c
+#pyexpat -I$(srcdir)/Modules/expat  expat/xmlparse.c expat/xmlrole.c expat/xmltok.c pyexpat.c
 #unicodedata  unicodedata.c
 
 # Modules with some UNIX dependencies -- on by default:
index afbedd011f660ff96c10f025a40e102c98363906..6671f7b689ba973646d587b588a445d28446f7f5 100644 (file)
@@ -18,4 +18,8 @@
 #define XML_DTD 1
 #define XML_CONTEXT_BYTES 1024
 
+// bpo-30947: Python uses best available entropy sources to
+// call XML_SetHashSalt(), expat entropy sources are not needed
+#define XML_POOR_ENTROPY 1
+
 #endif /* EXPAT_CONFIG_H */
index 4a125b243b780dd13c89ddf8294ded267129159b..8da5244bac0cb65791c00cb0fc93f03d7385f196 100644 (file)
@@ -94,7 +94,7 @@
   <ItemDefinitionGroup>
     <ClCompile>
       <AdditionalIncludeDirectories>..\Modules\expat;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
-      <PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;USE_PYEXPAT_CAPI;XML_STATIC;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+      <PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;XML_STATIC;%(PreprocessorDefinitions)</PreprocessorDefinitions>
     </ClCompile>
   </ItemDefinitionGroup>
   <ItemGroup>
index b2d9f5d57d4975fa56cadd225eaa37007c3dc69c..001f8afd89b9e9fc54f11cd2ba7dc520fd3f44a7 100644 (file)
@@ -91,7 +91,7 @@
   <ItemDefinitionGroup>
     <ClCompile>
       <AdditionalIncludeDirectories>$(PySourcePath)Modules\expat;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
-      <PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;PYEXPAT_EXPORTS;HAVE_EXPAT_H;XML_STATIC;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+      <PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;PYEXPAT_EXPORTS;XML_STATIC;%(PreprocessorDefinitions)</PreprocessorDefinitions>
     </ClCompile>
   </ItemDefinitionGroup>
   <ItemGroup>
index 03dce63984ef3013f22e19b3a3d1e0c1db7d0aaa..4bef3cb52f2b2b73566f02eaff0a090f7c2f3cb5 100644 (file)
--- a/setup.py
+++ b/setup.py
@@ -1748,19 +1748,12 @@ class PyBuildExt(build_ext):
         #
         if '--with-system-expat' in sysconfig.get_config_var("CONFIG_ARGS"):
             expat_inc = []
-            define_macros = []
             extra_compile_args = []
             expat_lib = ['expat']
             expat_sources = []
             expat_depends = []
         else:
             expat_inc = [os.path.join(self.srcdir, 'Modules', 'expat')]
-            define_macros = [
-                ('HAVE_EXPAT_CONFIG_H', '1'),
-                # bpo-30947: Python uses best available entropy sources to
-                # call XML_SetHashSalt(), expat entropy sources are not needed
-                ('XML_POOR_ENTROPY', '1'),
-            ]
             extra_compile_args = []
             # bpo-44394: libexpat uses isnan() of math.h and needs linkage
             # against the libm
@@ -1788,7 +1781,6 @@ class PyBuildExt(build_ext):
                 extra_compile_args.append('-Wno-unreachable-code')
 
         self.add(Extension('pyexpat',
-                           define_macros=define_macros,
                            extra_compile_args=extra_compile_args,
                            include_dirs=expat_inc,
                            libraries=expat_lib,
@@ -1799,9 +1791,7 @@ class PyBuildExt(build_ext):
         # uses expat (via the CAPI hook in pyexpat).
 
         if os.path.isfile(os.path.join(self.srcdir, 'Modules', '_elementtree.c')):
-            define_macros.append(('USE_PYEXPAT_CAPI', None))
             self.add(Extension('_elementtree',
-                               define_macros=define_macros,
                                include_dirs=expat_inc,
                                libraries=expat_lib,
                                sources=['_elementtree.c'],