Commit 8ebe2727 authored by Stefan Behnel's avatar Stefan Behnel

Actually enable the error on PEP-489 module reinitialisation, and add it to the changelog.

parent 6b6cca3d
......@@ -57,6 +57,10 @@ Bugs fixed
exception stack traces.
Patch by Jeroen Demeyer. (Github issue #2492)
* When PEP-489 support is enabled, reloading the module overwrote any static
module state. It now raises an exception instead, given that reloading is
not actually supported.
Other changes
-------------
......
......@@ -166,11 +166,15 @@ class CythonMagics(Magics):
f.write(cell)
if 'pyximport' not in sys.modules or not self._pyximport_installed:
import pyximport
pyximport.install(reload_support=True)
pyximport.install()
self._pyximport_installed = True
if module_name in self._reloads:
module = self._reloads[module_name]
reload(module)
# Note: reloading extension modules is not actually supported
# (requires PEP-489 reinitialisation support).
# Don't know why this should ever have worked as it reads here.
# All we really need to do is to update the globals below.
#reload(module)
else:
__import__(module_name)
module = sys.modules[module_name]
......
......@@ -2333,11 +2333,10 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
Naming.module_cname,
Naming.pymodinit_module_arg,
))
# TODO: We should raise an exception here, as long as Cython cannot actually support reinitialisation.
# code.putln('PyErr_SetString(PyExc_RuntimeError,'
# ' "Module \'%s\' has already been imported. Re-initialisation is not supported");' %
# env.module_name)
# code.putln("return -1;")
code.putln('PyErr_SetString(PyExc_RuntimeError,'
' "Module \'%s\' has already been imported. Re-initialisation is not supported.");' %
env.module_name)
code.putln("return -1;")
code.putln("}")
code.putln("#elif PY_MAJOR_VERSION >= 3")
# Hack: enforce single initialisation also on reimports under different names on Python 3 (with PEP 3121/489).
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment