Author: Philip Jenvey <pjen...@underboss.org> Branch: py3k Changeset: r70134:6ff661c8a2b0 Date: 2014-03-19 16:56 -0700 http://bitbucket.org/pypy/pypy/changeset/6ff661c8a2b0/
Log: merge default diff --git a/pypy/interpreter/baseobjspace.py b/pypy/interpreter/baseobjspace.py --- a/pypy/interpreter/baseobjspace.py +++ b/pypy/interpreter/baseobjspace.py @@ -441,10 +441,11 @@ return name - def getbuiltinmodule(self, name, force_init=False): + def getbuiltinmodule(self, name, force_init=False, reuse=True): w_name = self.wrap(name) w_modules = self.sys.get('modules') if not force_init: + assert reuse is True try: return self.getitem(w_modules, w_name) except OperationError, e: @@ -460,10 +461,18 @@ "getbuiltinmodule() called with non-builtin module %s", name) else: - # And initialize it + # Initialize the module from pypy.interpreter.module import Module if isinstance(w_mod, Module): - w_mod.init(self) + if not reuse and w_mod.startup_called: + # Create a copy of the module + w_mod.getdict(self) # unlazy w_initialdict + w_new = self.wrap(Module(self, w_name)) + self.call_method(w_new.getdict(self), 'update', + w_mod.w_initialdict) + w_mod = w_new + else: + w_mod.init(self) # Add the module to sys.modules self.setitem(w_modules, w_name, w_mod) diff --git a/pypy/module/cpyext/include/pystate.h b/pypy/module/cpyext/include/pystate.h --- a/pypy/module/cpyext/include/pystate.h +++ b/pypy/module/cpyext/include/pystate.h @@ -21,9 +21,8 @@ #define Py_END_ALLOW_THREADS PyEval_RestoreThread(_save); \ } -typedef - enum {PyGILState_LOCKED, PyGILState_UNLOCKED} - PyGILState_STATE; +enum {PyGILState_LOCKED, PyGILState_UNLOCKED}; +typedef int PyGILState_STATE; #define PyThreadState_GET() PyThreadState_Get() diff --git a/pypy/module/cpyext/pystate.py b/pypy/module/cpyext/pystate.py --- a/pypy/module/cpyext/pystate.py +++ b/pypy/module/cpyext/pystate.py @@ -208,16 +208,14 @@ # Before external call is after running Python rffi.aroundstate.before() -PyGILState_STATE = rffi.COpaquePtr('PyGILState_STATE', - typedef='PyGILState_STATE', - compilation_info=CConfig._compilation_info_) +PyGILState_STATE = rffi.INT @cpython_api([], PyGILState_STATE, error=CANNOT_FAIL) def PyGILState_Ensure(space): if rffi.aroundstate.after: # After external call is before entering Python rffi.aroundstate.after() - return lltype.nullptr(PyGILState_STATE.TO) + return rffi.cast(PyGILState_STATE, 0) @cpython_api([PyGILState_STATE], lltype.Void) def PyGILState_Release(space, state): 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 @@ -585,7 +585,8 @@ return space.call_method(find_info.w_loader, "load_module", w_modulename) if find_info.modtype == C_BUILTIN: - return space.getbuiltinmodule(find_info.filename, force_init=True) + return space.getbuiltinmodule(find_info.filename, force_init=True, + reuse=reuse) if find_info.modtype in (PY_SOURCE, PY_COMPILED, C_EXTENSION, PKG_DIRECTORY): w_mod = None diff --git a/pypy/module/imp/test/test_app.py b/pypy/module/imp/test/test_app.py --- a/pypy/module/imp/test/test_app.py +++ b/pypy/module/imp/test/test_app.py @@ -219,7 +219,6 @@ def test_builtin_reimport(self): # from https://bugs.pypy.org/issue1514 - skip("fix me") import sys, marshal old = marshal.loads @@ -239,7 +238,6 @@ # taken from https://bugs.pypy.org/issue1514, with extra cases # that show a difference with CPython: we can get on CPython # several module objects for the same built-in module :-( - skip("several built-in module objects: not supported by pypy") import sys, marshal old = marshal.loads diff --git a/pypy/module/imp/test/test_import.py b/pypy/module/imp/test/test_import.py --- a/pypy/module/imp/test/test_import.py +++ b/pypy/module/imp/test/test_import.py @@ -652,7 +652,6 @@ assert hasattr(time, 'clock') def test_reimport_builtin_simple_case_2(self): - skip("fix me") import sys, time time.foo = "bar" del sys.modules['time'] @@ -660,7 +659,6 @@ assert not hasattr(time, 'foo') def test_reimport_builtin(self): - skip("fix me") import imp, sys, time oldpath = sys.path time.tzset = "<test_reimport_builtin removed this>" diff --git a/pypy/module/marshal/test/test_marshal.py b/pypy/module/marshal/test/test_marshal.py --- a/pypy/module/marshal/test/test_marshal.py +++ b/pypy/module/marshal/test/test_marshal.py @@ -173,7 +173,7 @@ import marshal types = (float, complex, int, tuple, list, dict, set, frozenset) for cls in types: - print cls + print(cls) class subtype(cls): pass exc = raises(ValueError, marshal.dumps, subtype) diff --git a/pypy/objspace/std/memoryview.py b/pypy/objspace/std/memoryview.py --- a/pypy/objspace/std/memoryview.py +++ b/pypy/objspace/std/memoryview.py @@ -41,14 +41,14 @@ self.buf = buf def buffer_w(self, space): - """Note that memoryview() is very inconsistent in CPython: it - does not support the buffer interface but does support the new - buffer interface: as a result, it is possible to pass memoryview - to e.g. socket.send() but not to file.write(). For simplicity - and consistency, in PyPy memoryview DOES support buffer(), which - means that it is accepted in more places than CPython. """ - self._check_released(space) + Note that memoryview() is very inconsistent in CPython: it does not + support the buffer interface but does support the new buffer + interface: as a result, it is possible to pass memoryview to + e.g. socket.send() but not to file.write(). For simplicity and + consistency, in PyPy memoryview DOES support buffer(), which means + that it is accepted in more places than CPython. + """ return self.buf @staticmethod _______________________________________________ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit