Message249615
Just to confirm: the following script fails with `ImportError: DLL load failed` on Python 3.5.0rc2. It fails around the 120th extension. The script passes on Python 3.4.3.
Also, Python 3.5.0rc2 (not Python 3.4.3) requires the `extra_postargs=['/DLL']` argument to the `link_shared_lib` function, otherwise the linker fails with `LINK : fatal error LNK1561: entry point must be defined`.
```
# test_issue24872.py
#
# Build up to 256 C extension modules and import them.
#
# On Python 3.5.0rc2 for Windows this raises "ImportError: DLL load failed:
# A dynamic link library (DLL) initialization routine failed."
#
# http://bugs.python.org/issue24872
import os
import sys
from importlib import import_module
from distutils import ccompiler
assert sys.platform == 'win32'
assert sys.version_info > (3, 2)
c_source = """/* Minimal Python 3 extension module */
#include "Python.h"
static struct PyModuleDef moduledef = {
PyModuleDef_HEAD_INIT, "%s", NULL, -1, NULL, NULL, NULL, NULL, NULL
};
PyMODINIT_FUNC PyInit_%s(void) { return PyModule_Create(&moduledef); }
"""
cl = ccompiler.new_compiler()
for i in range(256):
name = '_tmp%.3i' % i
try:
os.remove(name+'.pyd')
except FileNotFoundError:
pass
with open(name+'.c', 'w') as fh:
fh.write(c_source % (name, name))
objects = cl.compile([name+'.c'])
cl.link_shared_lib(objects, output_libname=name, extra_postargs=['/DLL'],
export_symbols=["PyInit_"+name])
for ext in 'c', 'obj', 'exp', 'lib':
os.remove(name+'.'+ext)
os.rename(name+'.dll', name+'.pyd')
import_module(name)
``` |
|
Date |
User |
Action |
Args |
2015-09-03 08:09:09 | cgohlke | set | recipients:
+ cgohlke, lemburg, paul.moore, larry, tim.golden, zach.ware, steve.dower |
2015-09-03 08:09:09 | cgohlke | set | messageid: <1441267749.61.0.503825924591.issue24872@psf.upfronthosting.co.za> |
2015-09-03 08:09:09 | cgohlke | link | issue24872 messages |
2015-09-03 08:09:08 | cgohlke | create | |
|