This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author cgohlke
Recipients cgohlke, larry, lemburg, paul.moore, steve.dower, tim.golden, zach.ware
Date 2015-09-03.08:09:08
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
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`.

# 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."

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
    except FileNotFoundError:
    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'],
    for ext in 'c', 'obj', 'exp', 'lib':
    os.rename(name+'.dll', name+'.pyd')
Date User Action Args
2015-09-03 08:09:09cgohlkesetrecipients: + cgohlke, lemburg, paul.moore, larry, tim.golden, zach.ware, steve.dower
2015-09-03 08:09:09cgohlkesetmessageid: <>
2015-09-03 08:09:09cgohlkelinkissue24872 messages
2015-09-03 08:09:08cgohlkecreate