Author: Amaury Forgeot d'Arc <[email protected]>
Branch:
Changeset: r49425:05ed38d2c537
Date: 2011-11-15 00:50 +0100
http://bitbucket.org/pypy/pypy/changeset/05ed38d2c537/
Log: Fix usages of Py_InitModule outside of the module init() function.
SWIG for example uses it to share the type system between modules.
diff --git a/pypy/module/cpyext/modsupport.py b/pypy/module/cpyext/modsupport.py
--- a/pypy/module/cpyext/modsupport.py
+++ b/pypy/module/cpyext/modsupport.py
@@ -54,9 +54,15 @@
modname = rffi.charp2str(name)
state = space.fromcache(State)
f_name, f_path = state.package_context
- w_mod = PyImport_AddModule(space, f_name)
+ if f_name is not None:
+ modname = f_name
+ w_mod = PyImport_AddModule(space, modname)
+ state.package_context = None, None
- dict_w = {'__file__': space.wrap(f_path)}
+ if f_path is not None:
+ dict_w = {'__file__': space.wrap(f_path)}
+ else:
+ dict_w = {}
convert_method_defs(space, dict_w, methods, None, w_self, modname)
for key, w_value in dict_w.items():
space.setattr(w_mod, space.wrap(key), w_value)
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit