Skip to content

Commit ec93721

Browse files
authored
bpo-45570: Simplify setup macros for pyexpat (GH-29159)
* ``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 <[email protected]>
1 parent b781cc3 commit ec93721

File tree

6 files changed

+9
-14
lines changed

6 files changed

+9
-14
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
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``.

Modules/Setup

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ time timemodule.c
149149
#_contextvars _contextvarsmodule.c
150150
#_csv _csv.c
151151
#_datetime _datetimemodule.c
152-
#_elementtree -DHAVE_EXPAT_CONFIG_H -DUSE_PYEXPAT_CAPI -I$(srcdir)/Modules/expat _elementtree.c
152+
#_elementtree -I$(srcdir)/Modules/expat _elementtree.c
153153
#_heapq _heapqmodule.c
154154
#_json _json.c
155155
#_lsprof _lsprof.c rotatingtree.c
@@ -173,7 +173,7 @@ time timemodule.c
173173
#binascii binascii.c
174174
#cmath cmathmodule.c _math.c # -lm
175175
#math mathmodule.c _math.c # -lm
176-
#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
176+
#pyexpat -I$(srcdir)/Modules/expat expat/xmlparse.c expat/xmlrole.c expat/xmltok.c pyexpat.c
177177
#unicodedata unicodedata.c
178178

179179
# Modules with some UNIX dependencies -- on by default:

Modules/expat/expat_config.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,8 @@
1818
#define XML_DTD 1
1919
#define XML_CONTEXT_BYTES 1024
2020

21+
// bpo-30947: Python uses best available entropy sources to
22+
// call XML_SetHashSalt(), expat entropy sources are not needed
23+
#define XML_POOR_ENTROPY 1
24+
2125
#endif /* EXPAT_CONFIG_H */

PCbuild/_elementtree.vcxproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@
9494
<ItemDefinitionGroup>
9595
<ClCompile>
9696
<AdditionalIncludeDirectories>..\Modules\expat;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
97-
<PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;USE_PYEXPAT_CAPI;XML_STATIC;%(PreprocessorDefinitions)</PreprocessorDefinitions>
97+
<PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;XML_STATIC;%(PreprocessorDefinitions)</PreprocessorDefinitions>
9898
</ClCompile>
9999
</ItemDefinitionGroup>
100100
<ItemGroup>

PCbuild/pyexpat.vcxproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@
9191
<ItemDefinitionGroup>
9292
<ClCompile>
9393
<AdditionalIncludeDirectories>$(PySourcePath)Modules\expat;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
94-
<PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;PYEXPAT_EXPORTS;HAVE_EXPAT_H;XML_STATIC;%(PreprocessorDefinitions)</PreprocessorDefinitions>
94+
<PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;PYEXPAT_EXPORTS;XML_STATIC;%(PreprocessorDefinitions)</PreprocessorDefinitions>
9595
</ClCompile>
9696
</ItemDefinitionGroup>
9797
<ItemGroup>

setup.py

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1748,19 +1748,12 @@ def detect_expat_elementtree(self):
17481748
#
17491749
if '--with-system-expat' in sysconfig.get_config_var("CONFIG_ARGS"):
17501750
expat_inc = []
1751-
define_macros = []
17521751
extra_compile_args = []
17531752
expat_lib = ['expat']
17541753
expat_sources = []
17551754
expat_depends = []
17561755
else:
17571756
expat_inc = [os.path.join(self.srcdir, 'Modules', 'expat')]
1758-
define_macros = [
1759-
('HAVE_EXPAT_CONFIG_H', '1'),
1760-
# bpo-30947: Python uses best available entropy sources to
1761-
# call XML_SetHashSalt(), expat entropy sources are not needed
1762-
('XML_POOR_ENTROPY', '1'),
1763-
]
17641757
extra_compile_args = []
17651758
# bpo-44394: libexpat uses isnan() of math.h and needs linkage
17661759
# against the libm
@@ -1788,7 +1781,6 @@ def detect_expat_elementtree(self):
17881781
extra_compile_args.append('-Wno-unreachable-code')
17891782

17901783
self.add(Extension('pyexpat',
1791-
define_macros=define_macros,
17921784
extra_compile_args=extra_compile_args,
17931785
include_dirs=expat_inc,
17941786
libraries=expat_lib,
@@ -1799,9 +1791,7 @@ def detect_expat_elementtree(self):
17991791
# uses expat (via the CAPI hook in pyexpat).
18001792

18011793
if os.path.isfile(os.path.join(self.srcdir, 'Modules', '_elementtree.c')):
1802-
define_macros.append(('USE_PYEXPAT_CAPI', None))
18031794
self.add(Extension('_elementtree',
1804-
define_macros=define_macros,
18051795
include_dirs=expat_inc,
18061796
libraries=expat_lib,
18071797
sources=['_elementtree.c'],

0 commit comments

Comments
 (0)