Author: Amaury Forgeot d'Arc <[email protected]>
Branch: py3.3
Changeset: r72345:a53f63e78743
Date: 2014-06-23 14:11 +0200
http://bitbucket.org/pypy/pypy/changeset/a53f63e78743/
Log: Fix some cpyext tests.
diff --git a/pypy/module/_frozen_importlib/__init__.py
b/pypy/module/_frozen_importlib/__init__.py
--- a/pypy/module/_frozen_importlib/__init__.py
+++ b/pypy/module/_frozen_importlib/__init__.py
@@ -24,8 +24,9 @@
source = fp.read()
pathname = "<frozen importlib._bootstrap>"
code_w = ec.compiler.compile(source, pathname, 'exec', 0)
- w_dict = space.newdict()
- space.setitem(w_dict, space.wrap('__name__'), self.w_name)
+ space.setitem(self.w_dict, space.wrap('__name__'), self.w_name)
+ space.setitem(self.w_dict, space.wrap('__builtins__'),
+ space.wrap(space.builtin))
code_w.exec_code(space, self.w_dict, self.w_dict)
def startup(self, space):
diff --git a/pypy/module/cpyext/test/date.c b/pypy/module/cpyext/test/date.c
--- a/pypy/module/cpyext/test/date.c
+++ b/pypy/module/cpyext/test/date.c
@@ -17,6 +17,8 @@
PyObject *module, *othermodule;
module = PyModule_Create(&moduledef);
othermodule = PyImport_ImportModule("apple.banana");
+ if (!othermodule)
+ return NULL;
Py_DECREF(othermodule);
return module;
}
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
@@ -217,10 +217,12 @@
class AppTestCpythonExtensionBase(LeakCheckingTest):
def setup_class(cls):
- cls.space.getbuiltinmodule("cpyext")
- from pypy.module.imp.importing import importhook
- importhook(cls.space, "os") # warm up reference counts
- state = cls.space.fromcache(RefcountState)
+ space = cls.space
+ space.getbuiltinmodule("cpyext")
+ # 'import os' to warm up reference counts
+ w_import = space.builtin.getdictvalue(space, '__import__')
+ space.call_function(w_import, space.wrap("os"))
+ state = space.fromcache(RefcountState)
state.non_heaptypes_w[:] = []
def setup_method(self, func):
diff --git a/pypy/module/imp/importing.py b/pypy/module/imp/importing.py
--- a/pypy/module/imp/importing.py
+++ b/pypy/module/imp/importing.py
@@ -79,10 +79,9 @@
source = fp.read()
pathname = "<frozen %s>" % modulename
code_w = ec.compiler.compile(source, pathname, 'exec', 0)
- w_dict = space.newdict()
w_mod = add_module(space, space.wrap(modulename))
space.setitem(space.sys.get('modules'), w_mod.w_name, w_mod)
- space.setitem(w_dict, space.wrap('__name__'), w_mod.w_name)
+ space.setitem(w_mod.w_dict, space.wrap('__name__'), w_mod.w_name)
code_w.exec_code(space, w_mod.w_dict, w_mod.w_dict)
assert check_sys_modules_w(space, modulename)
return w_mod
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit