[pypy-commit] pypy py3k-test-cpyext: Get import_extension() to work on -A

rlamy pypy.commits at gmail.com
Sat Oct 1 22:57:53 EDT 2016


Author: Ronan Lamy <ronan.lamy at gmail.com>
Branch: py3k-test-cpyext
Changeset: r87514:14eb3647cc89
Date: 2016-10-02 03:55 +0100
http://bitbucket.org/pypy/pypy/changeset/14eb3647cc89/

Log:	Get import_extension() to work on -A

diff --git a/pypy/module/cpyext/test/test_cpyext.py b/pypy/module/cpyext/test/test_cpyext.py
--- a/pypy/module/cpyext/test/test_cpyext.py
+++ b/pypy/module/cpyext/test/test_cpyext.py
@@ -244,6 +244,16 @@
                     PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)
             cls.w_import_module = w_import_module
 
+            def w_import_extension(self, modname, w_functions, prologue="",
+                include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False):
+                from extbuild import get_sys_info_app
+                sys_info = get_sys_info_app(self.udir)
+                return sys_info.import_extension(
+                    modname, w_functions, prologue=prologue,
+                    include_dirs=include_dirs, more_init=more_init,
+                    PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)
+            cls.w_import_extension = w_import_extension
+
     def record_imported_module(self, name):
         """
         Record a module imported in a test so that it can be cleaned up in
@@ -315,8 +325,6 @@
         if self.runappdirect:
             self.compile_module = self.sys_info.compile_extension_module
             self.load_module = self.sys_info.load_module
-            self.import_module = self.sys_info.import_module
-            self.import_extension = self.sys_info.import_extension
         else:
             wrap = self.space.wrap
             self.w_compile_module = wrap(interp2app(compile_module))
diff --git a/pypy/tool/cpyext/extbuild.py b/pypy/tool/cpyext/extbuild.py
--- a/pypy/tool/cpyext/extbuild.py
+++ b/pypy/tool/cpyext/extbuild.py
@@ -65,11 +65,8 @@
         filename.
         """
         if body or init:
-            body = body.encode()
             if init is None:
                 init = "return PyModule_Create(&moduledef);"
-            else:
-                init = init.encode()
         if init is not None:
             code = make_source(name, init, body, PY_SSIZE_T_CLEAN)
             kwds = dict(source_strings=[code])


More information about the pypy-commit mailing list