[pypy-commit] pypy py3.5: hg merge default
mjacob
pypy.commits at gmail.com
Wed Mar 22 04:01:23 EDT 2017
Author: Manuel Jacob <me at manueljacob.de>
Branch: py3.5
Changeset: r90785:eff72e17f613
Date: 2017-03-22 08:59 +0100
http://bitbucket.org/pypy/pypy/changeset/eff72e17f613/
Log: hg merge default
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
@@ -19,6 +19,14 @@
def init_moduleobject(space):
make_typedescr(Module.typedef, basestruct=PyModuleObject.TO)
+ at cpython_api([rffi.CCHARP], PyObject)
+def PyModule_New(space, name):
+ """
+ Return a new module object with the __name__ attribute set to name.
+ Only the module's __doc__ and __name__ attributes are filled in;
+ the caller is responsible for providing a __file__ attribute."""
+ return Module(space, space.newtext(rffi.charp2str(name)))
+
@cpython_api([PyModuleDef, rffi.INT_real], PyObject)
def PyModule_Create2(space, module, api_version):
"""Create a new module object, given the definition in module, assuming the
diff --git a/pypy/module/cpyext/stubs.py b/pypy/module/cpyext/stubs.py
--- a/pypy/module/cpyext/stubs.py
+++ b/pypy/module/cpyext/stubs.py
@@ -1326,14 +1326,6 @@
PyModule_Type."""
raise NotImplementedError
- at cpython_api([rffi.CCHARP], PyObject)
-def PyModule_New(space, name):
- """
- Return a new module object with the __name__ attribute set to name.
- Only the module's __doc__ and __name__ attributes are filled in;
- the caller is responsible for providing a __file__ attribute."""
- raise NotImplementedError
-
@cpython_api([PyObject], rffi.CCHARP)
def PyModule_GetFilename(space, module):
"""Similar to PyModule_GetFilenameObject() but return the filename
diff --git a/pypy/module/cpyext/test/test_module.py b/pypy/module/cpyext/test/test_module.py
--- a/pypy/module/cpyext/test/test_module.py
+++ b/pypy/module/cpyext/test/test_module.py
@@ -1,9 +1,16 @@
+from pypy.module.cpyext.modsupport import PyModule_New
from pypy.module.cpyext.test.test_api import BaseApiTest
from pypy.module.cpyext.test.test_cpyext import AppTestCpythonExtensionBase
from rpython.rtyper.lltypesystem import rffi
class TestModuleObject(BaseApiTest):
+ def test_module_new(self, space):
+ with rffi.scoped_str2charp('testname') as buf:
+ w_mod = PyModule_New(space, buf)
+ assert space.eq_w(space.getattr(w_mod, space.newtext('__name__')),
+ space.newtext('testname'))
+
def test_module_getname(self, space, api):
w_sys = space.wrap(space.sys)
p = api.PyModule_GetName(w_sys)
More information about the pypy-commit
mailing list