diff options
| author | Stefan Behnel <stefan_ml@behnel.de> | 2020-02-04 16:24:30 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-02-04 07:24:30 -0800 |
| commit | 9538bc9185e934bee2bd5ae2cda2b2e92a61906d (patch) | |
| tree | 17b2427bb0f49b48e30d9d18d31736d14a9405a3 /Lib/distutils/command | |
| parent | 850a4bd839ca11b59439e21dda2a3ebe917a9a16 (diff) | |
| download | cpython-git-9538bc9185e934bee2bd5ae2cda2b2e92a61906d.tar.gz | |
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
Diffstat (limited to 'Lib/distutils/command')
| -rw-r--r-- | Lib/distutils/command/build_ext.py | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/Lib/distutils/command/build_ext.py b/Lib/distutils/command/build_ext.py index 38bb8fd93c..1a9bd1200f 100644 --- a/Lib/distutils/command/build_ext.py +++ b/Lib/distutils/command/build_ext.py @@ -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 |
