mirror of
https://github.com/python/cpython.git
synced 2025-07-23 11:15:24 +00:00
bpo-39432: Implement PEP-489 algorithm for non-ascii "PyInit_*" symbol names in distutils (GH-18150)
Make it export the correct init symbol also on Windows. https://bugs.python.org/issue39432
This commit is contained in:
parent
850a4bd839
commit
9538bc9185
3 changed files with 23 additions and 1 deletions
|
@ -689,7 +689,15 @@ class build_ext(Command):
|
|||
provided, "PyInit_" + module_name. Only relevant on Windows, where
|
||||
the .pyd file (DLL) must export the module "PyInit_" function.
|
||||
"""
|
||||
initfunc_name = "PyInit_" + ext.name.split('.')[-1]
|
||||
suffix = '_' + ext.name.split('.')[-1]
|
||||
try:
|
||||
# Unicode module name support as defined in PEP-489
|
||||
# https://www.python.org/dev/peps/pep-0489/#export-hook-name
|
||||
suffix.encode('ascii')
|
||||
except UnicodeEncodeError:
|
||||
suffix = 'U' + suffix.encode('punycode').replace(b'-', b'_').decode('ascii')
|
||||
|
||||
initfunc_name = "PyInit" + suffix
|
||||
if initfunc_name not in ext.export_symbols:
|
||||
ext.export_symbols.append(initfunc_name)
|
||||
return ext.export_symbols
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue