Skip to content

bpo-45570: Simplify setup macros for pyexpat #29159

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 22, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -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``.
4 changes: 2 additions & 2 deletions Modules/Setup
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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:
Expand Down
4 changes: 4 additions & 0 deletions Modules/expat/expat_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
2 changes: 1 addition & 1 deletion PCbuild/_elementtree.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
2 changes: 1 addition & 1 deletion PCbuild/pyexpat.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
10 changes: 0 additions & 10 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -1748,19 +1748,12 @@ def detect_expat_elementtree(self):
#
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
Expand Down Expand Up @@ -1788,7 +1781,6 @@ def detect_expat_elementtree(self):
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,
Expand All @@ -1799,9 +1791,7 @@ def detect_expat_elementtree(self):
# 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'],
Expand Down