Author: Manuel Jacob <m...@manueljacob.de> Branch: py3.3 Changeset: r82573:e484ea33125b Date: 2016-02-26 19:20 +0100 http://bitbucket.org/pypy/pypy/changeset/e484ea33125b/
Log: hg merge py3k diff --git a/pypy/doc/whatsnew-head.rst b/pypy/doc/whatsnew-head.rst --- a/pypy/doc/whatsnew-head.rst +++ b/pypy/doc/whatsnew-head.rst @@ -170,4 +170,17 @@ When creating instances and adding attributes in several different orders depending on some condition, the JIT would create too much code. This is now -fixed. \ No newline at end of file +fixed. + +.. branch: cpyext-gc-support-2 + +Improve CPython C API support, which means lxml now runs unmodified +(after removing pypy hacks, pending pull request) + +.. branch: look-inside-tuple-hash + +Look inside tuple hash, improving mdp benchmark + +.. branch: vlen-resume + +Compress resume data, saving 10-20% of memory consumed by the JIT \ No newline at end of file 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 @@ -65,7 +65,7 @@ test_reload = "def test():\n raise ValueError\n", infinite_reload = "import infinite_reload, imp; imp.reload(infinite_reload)", del_sys_module = "import sys\ndel sys.modules['del_sys_module']\n", - itertools = "hello_world = 42\n", + _md5 = "hello_world = 42\n", gc = "should_never_be_seen = 42\n", ) root.ensure("packagenamespace", dir=1) # empty, no __init__.py @@ -202,7 +202,7 @@ class AppTestImport(BaseImportTest): spaceconfig = { - "usemodules": ['time', 'struct'], + "usemodules": ['_md5', 'time', 'struct'], } def setup_class(cls): @@ -696,13 +696,15 @@ def test_shadow_extension_1(self): if self.runappdirect: skip("hard to test: module is already imported") + # 'import _md5' is supposed to find _md5.py if there is + # one in sys.path. import sys - sys.modules.pop('itertools', None) - import itertools - assert hasattr(itertools, 'hello_world') - assert not hasattr(itertools, 'count') - assert '(built-in)' not in repr(itertools) - del sys.modules['itertools'] + assert '_md5' not in sys.modules + import _md5 + assert hasattr(_md5, 'hello_world') + assert not hasattr(_md5, 'md5') + assert '(built-in)' not in repr(_md5) + del sys.modules['_md5'] def test_shadow_extension_2(self): if self.runappdirect: skip("hard to test: module is already imported") @@ -712,16 +714,16 @@ # there is one in lib_pypy/_md5.py, which should not be seen # either; hence the (built-in) test below.) import sys - sys.modules.pop('itertools', None) + assert '_md5' not in sys.modules sys.path.append(sys.path.pop(0)) try: - import itertools - assert not hasattr(itertools, 'hello_world') - assert hasattr(itertools, 'islice') - assert '(built-in)' in repr(itertools) + import _md5 + assert not hasattr(_md5, 'hello_world') + assert hasattr(_md5, 'md5') + assert '(built-in)' in repr(_md5) finally: sys.path.insert(0, sys.path.pop()) - del sys.modules['itertools'] + del sys.modules['_md5'] def test_invalid_pathname(self): skip("This test fails on CPython 3.3, but passes on CPython 3.4+") diff --git a/pypy/module/thread/test/test_thread.py b/pypy/module/thread/test/test_thread.py --- a/pypy/module/thread/test/test_thread.py +++ b/pypy/module/thread/test/test_thread.py @@ -239,20 +239,18 @@ if waiting: _thread.interrupt_main() return - print('tock...', x) # <-force the GIL to be released, as - time.sleep(0.1) # time.sleep doesn't do non-translated + time.sleep(0.1) def busy_wait(): waiting.append(None) - for x in range(100): - print('tick...', x) # <-force the GIL to be released, as - time.sleep(0.1) # time.sleep doesn't do non-translated + for x in range(50): + time.sleep(0.1) waiting.pop() # This is normally called by app_main.py signal.signal(signal.SIGINT, signal.default_int_handler) - for i in range(10): + for i in range(100): print() print("loop", i) waiting = [] diff --git a/pypy/module/time/interp_time.py b/pypy/module/time/interp_time.py --- a/pypy/module/time/interp_time.py +++ b/pypy/module/time/interp_time.py @@ -5,7 +5,7 @@ from rpython.rtyper.lltypesystem import lltype from rpython.rlib.rarithmetic import intmask from rpython.rlib.rtime import win_perf_counter -from rpython.rlib import rposix +from rpython.rlib import rposix, rtime from rpython.translator.tool.cbuild import ExternalCompilationInfo import math import os @@ -339,13 +339,13 @@ if secs < 0: raise OperationError(space.w_ValueError, space.wrap("sleep length must be non-negative")) - pytime.sleep(secs) + rtime.sleep(secs) else: from rpython.rlib import rwin32 from errno import EINTR def _simple_sleep(space, secs, interruptible): if secs == 0.0 or not interruptible: - pytime.sleep(secs) + rtime.sleep(secs) else: millisecs = int(secs * 1000) interrupt_event = space.fromcache(State).get_interrupt_event() @@ -354,7 +354,7 @@ if rc == rwin32.WAIT_OBJECT_0: # Yield to make sure real Python signal handler # called. - pytime.sleep(0.001) + rtime.sleep(0.001) raise wrap_oserror(space, OSError(EINTR, "sleep() interrupted")) @unwrap_spec(secs=float) diff --git a/pypy/objspace/std/mapdict.py b/pypy/objspace/std/mapdict.py --- a/pypy/objspace/std/mapdict.py +++ b/pypy/objspace/std/mapdict.py @@ -65,21 +65,8 @@ def delete(self, obj, name, index): pass + @jit.elidable def find_map_attr(self, name, index): - if jit.we_are_jitted(): - # hack for the jit: - # the _find_map_attr method is pure too, but its argument is never - # constant, because it is always a new tuple - return self._find_map_attr_jit_pure(name, index) - else: - return self._find_map_attr_indirection(name, index) - - @jit.elidable - def _find_map_attr_jit_pure(self, name, index): - return self._find_map_attr_indirection(name, index) - - @jit.dont_look_inside - def _find_map_attr_indirection(self, name, index): if (self.space.config.objspace.std.withmethodcache): return self._find_map_attr_cache(name, index) return self._find_map_attr(name, index) diff --git a/pypy/tool/test/test_tab.py b/pypy/tool/test/test_tab.py --- a/pypy/tool/test/test_tab.py +++ b/pypy/tool/test/test_tab.py @@ -6,6 +6,7 @@ from pypy.conftest import pypydir ROOT = os.path.abspath(os.path.join(pypydir, '..')) +RPYTHONDIR = os.path.join(ROOT, "rpython") EXCLUDE = {'/virt_test/lib/python2.7/site-packages/setuptools'} @@ -28,3 +29,27 @@ if not entry.startswith('.'): walk('%s/%s' % (reldir, entry)) walk('') + +def test_no_pypy_import_in_rpython(): + def walk(reldir): + print reldir + if reldir: + path = os.path.join(RPYTHONDIR, *reldir.split('/')) + else: + path = RPYTHONDIR + if os.path.isfile(path): + if not path.lower().endswith('.py'): + return + with file(path) as f: + for line in f: + if "import" not in line: + continue + assert "from pypy." not in line + assert "import pypy." not in line + elif os.path.isdir(path) and not os.path.islink(path): + for entry in os.listdir(path): + if not entry.startswith('.'): + walk('%s/%s' % (reldir, entry)) + + walk('') + diff --git a/rpython/jit/metainterp/test/test_jitdriver.py b/rpython/jit/metainterp/test/test_jitdriver.py --- a/rpython/jit/metainterp/test/test_jitdriver.py +++ b/rpython/jit/metainterp/test/test_jitdriver.py @@ -227,7 +227,7 @@ i += 1 self.meta_interp(f, [0]) - self.check_resops(enter_portal_frame=1, leave_portal_frame=1) + self.check_simple_loop(enter_portal_frame=1, leave_portal_frame=1) class TestLLtype(MultipleJitDriversTests, LLJitMixin): pass diff --git a/rpython/rlib/test/test_posix.py b/rpython/rlib/test/test_posix.py --- a/rpython/rlib/test/test_posix.py +++ b/rpython/rlib/test/test_posix.py @@ -1,4 +1,4 @@ -import py +import py.test from rpython.rtyper.test.tool import BaseRtypingTest from rpython.rtyper.annlowlevel import hlstr from rpython.tool.udir import udir @@ -58,7 +58,7 @@ assert res def test_times(self): - import py; py.test.skip("llinterp does not like tuple returns") + py.test.skip("llinterp does not like tuple returns") from rpython.rtyper.test.test_llinterp import interpret times = interpret(lambda: posix.times(), ()) assert isinstance(times, tuple) @@ -119,21 +119,21 @@ res = self.interpret(f,[fi,20]) assert self.ll_to_string(res) == text - if hasattr(os, 'chown'): - def test_chown(self): - f = open(path, "w") - f.write("xyz") - f.close() - def f(): - try: - posix.chown(path, os.getuid(), os.getgid()) - return 1 - except OSError: - return 2 + @py.test.mark.skipif("not hasattr(os, 'chown')") + def test_chown(self): + f = open(path, "w") + f.write("xyz") + f.close() + def f(): + try: + posix.chown(path, os.getuid(), os.getgid()) + return 1 + except OSError: + return 2 - assert self.interpret(f, []) == 1 - os.unlink(path) - assert self.interpret(f, []) == 2 + assert self.interpret(f, []) == 1 + os.unlink(path) + assert self.interpret(f, []) == 2 def test_close(self): def f(fi): @@ -144,70 +144,70 @@ res = self.interpret(f,[fi]) py.test.raises( OSError, os.fstat, fi) - if hasattr(os, 'ftruncate'): - def test_ftruncate(self): - def f(fi,len): - os.ftruncate(fi,len) - fi = os.open(path,os.O_RDWR,0777) - func = self.interpret(f,[fi,6]) - assert os.fstat(fi).st_size == 6 + @py.test.mark.skipif("not hasattr(os, 'ftruncate')") + def test_ftruncate(self): + def f(fi,len): + os.ftruncate(fi,len) + fi = os.open(path,os.O_RDWR,0777) + func = self.interpret(f,[fi,6]) + assert os.fstat(fi).st_size == 6 - if hasattr(os, 'getuid'): - def test_getuid(self): - def f(): - return os.getuid() - assert self.interpret(f, []) == f() + @py.test.mark.skipif("not hasattr(os, 'getuid')") + def test_getuid(self): + def f(): + return os.getuid() + assert self.interpret(f, []) == f() - if hasattr(os, 'getgid'): - def test_getgid(self): - def f(): - return os.getgid() - assert self.interpret(f, []) == f() + @py.test.mark.skipif("not hasattr(os, 'getgid')") + def test_getgid(self): + def f(): + return os.getgid() + assert self.interpret(f, []) == f() - if hasattr(os, 'setuid'): - def test_os_setuid(self): - def f(): - os.setuid(os.getuid()) - return os.getuid() - assert self.interpret(f, []) == f() + @py.test.mark.skipif("not hasattr(os, 'setuid')") + def test_os_setuid(self): + def f(): + os.setuid(os.getuid()) + return os.getuid() + assert self.interpret(f, []) == f() - if hasattr(os, 'sysconf'): - def test_os_sysconf(self): - def f(i): - return os.sysconf(i) - assert self.interpret(f, [13]) == f(13) + @py.test.mark.skipif("not hasattr(os, 'sysconf')") + def test_os_sysconf(self): + def f(i): + return os.sysconf(i) + assert self.interpret(f, [13]) == f(13) - if hasattr(os, 'confstr'): - def test_os_confstr(self): - def f(i): - try: - return os.confstr(i) - except OSError: - return "oooops!!" - some_value = os.confstr_names.values()[-1] - res = self.interpret(f, [some_value]) - assert hlstr(res) == f(some_value) - res = self.interpret(f, [94781413]) - assert hlstr(res) == "oooops!!" + @py.test.mark.skipif("not hasattr(os, 'confstr')") + def test_os_confstr(self): + def f(i): + try: + return os.confstr(i) + except OSError: + return "oooops!!" + some_value = os.confstr_names.values()[-1] + res = self.interpret(f, [some_value]) + assert hlstr(res) == f(some_value) + res = self.interpret(f, [94781413]) + assert hlstr(res) == "oooops!!" - if hasattr(os, 'pathconf'): - def test_os_pathconf(self): - def f(i): - return os.pathconf("/tmp", i) - i = os.pathconf_names["PC_NAME_MAX"] - some_value = self.interpret(f, [i]) - assert some_value >= 31 + @py.test.mark.skipif("not hasattr(os, 'pathconf')") + def test_os_pathconf(self): + def f(i): + return os.pathconf("/tmp", i) + i = os.pathconf_names["PC_NAME_MAX"] + some_value = self.interpret(f, [i]) + assert some_value >= 31 - if hasattr(os, 'chroot'): - def test_os_chroot(self): - def f(): - try: - os.chroot('!@$#!#%$#^#@!#!$$#^') - except OSError: - return 1 - return 0 + @py.test.mark.skipif("not hasattr(os, 'chroot')") + def test_os_chroot(self): + def f(): + try: + os.chroot('!@$#!#%$#^#@!#!$$#^') + except OSError: + return 1 + return 0 - assert self.interpret(f, []) == 1 + assert self.interpret(f, []) == 1 def test_os_wstar(self): from rpython.rlib import rposix @@ -221,84 +221,84 @@ res = self.interpret(fun, [value]) assert res == fun(value) - if hasattr(os, 'getgroups'): - def test_getgroups(self): - def f(): - return os.getgroups() - ll_a = self.interpret(f, []) - assert self.ll_to_list(ll_a) == f() + @py.test.mark.skipif("not hasattr(os, 'getgroups')") + def test_getgroups(self): + def f(): + return os.getgroups() + ll_a = self.interpret(f, []) + assert self.ll_to_list(ll_a) == f() - if hasattr(os, 'setgroups'): - def test_setgroups(self): - def f(): - try: - os.setgroups(os.getgroups()) - except OSError: - pass - self.interpret(f, []) + @py.test.mark.skipif("not hasattr(os, 'setgroups')") + def test_setgroups(self): + def f(): + try: + os.setgroups(os.getgroups()) + except OSError: + pass + self.interpret(f, []) - if hasattr(os, 'initgroups'): - def test_initgroups(self): - def f(): - try: - os.initgroups('sUJJeumz', 4321) - except OSError: - return 1 - return 0 - res = self.interpret(f, []) - assert res == 1 + @py.test.mark.skipif("not hasattr(os, 'initgroups')") + def test_initgroups(self): + def f(): + try: + os.initgroups('sUJJeumz', 4321) + except OSError: + return 1 + return 0 + res = self.interpret(f, []) + assert res == 1 - if hasattr(os, 'tcgetpgrp'): - def test_tcgetpgrp(self): - def f(fd): - try: - return os.tcgetpgrp(fd) - except OSError: - return 42 - res = self.interpret(f, [9999]) - assert res == 42 + @py.test.mark.skipif("not hasattr(os, 'tcgetpgrp')") + def test_tcgetpgrp(self): + def f(fd): + try: + return os.tcgetpgrp(fd) + except OSError: + return 42 + res = self.interpret(f, [9999]) + assert res == 42 - if hasattr(os, 'tcsetpgrp'): - def test_tcsetpgrp(self): - def f(fd, pgrp): - try: - os.tcsetpgrp(fd, pgrp) - except OSError: - return 1 - return 0 - res = self.interpret(f, [9999, 1]) - assert res == 1 + @py.test.mark.skipif("not hasattr(os, 'tcsetpgrp')") + def test_tcsetpgrp(self): + def f(fd, pgrp): + try: + os.tcsetpgrp(fd, pgrp) + except OSError: + return 1 + return 0 + res = self.interpret(f, [9999, 1]) + assert res == 1 - if hasattr(os, 'getresuid'): - def test_getresuid(self): - def f(): - a, b, c = os.getresuid() - return a + b * 37 + c * 1291 - res = self.interpret(f, []) + @py.test.mark.skipif("not hasattr(os, 'getresuid')") + def test_getresuid(self): + def f(): a, b, c = os.getresuid() - assert res == a + b * 37 + c * 1291 + return a + b * 37 + c * 1291 + res = self.interpret(f, []) + a, b, c = os.getresuid() + assert res == a + b * 37 + c * 1291 - if hasattr(os, 'getresgid'): - def test_getresgid(self): - def f(): - a, b, c = os.getresgid() - return a + b * 37 + c * 1291 - res = self.interpret(f, []) + @py.test.mark.skipif("not hasattr(os, 'getresgid')") + def test_getresgid(self): + def f(): a, b, c = os.getresgid() - assert res == a + b * 37 + c * 1291 + return a + b * 37 + c * 1291 + res = self.interpret(f, []) + a, b, c = os.getresgid() + assert res == a + b * 37 + c * 1291 - if hasattr(os, 'setresuid'): - def test_setresuid(self): - def f(): - a, b, c = os.getresuid() - a = (a + 1) - 1 - os.setresuid(a, b, c) - self.interpret(f, []) + @py.test.mark.skipif("not hasattr(os, 'setresuid')") + def test_setresuid(self): + def f(): + a, b, c = os.getresuid() + a = (a + 1) - 1 + os.setresuid(a, b, c) + self.interpret(f, []) - if hasattr(os, 'setresgid'): - def test_setresgid(self): - def f(): - a, b, c = os.getresgid() - a = (a + 1) - 1 - os.setresgid(a, b, c) - self.interpret(f, []) + @py.test.mark.skipif("not hasattr(os, 'setresgid')") + def test_setresgid(self): + def f(): + a, b, c = os.getresgid() + a = (a + 1) - 1 + os.setresgid(a, b, c) + self.interpret(f, []) _______________________________________________ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit