[pypy-commit] pypy llvm-translation-backend: hg merge default
mjacob
pypy.commits at gmail.com
Sun Feb 28 09:24:44 EST 2016
Author: Manuel Jacob <me at manueljacob.de>
Branch: llvm-translation-backend
Changeset: r82598:5efe50af086f
Date: 2016-02-28 13:51 +0100
http://bitbucket.org/pypy/pypy/changeset/5efe50af086f/
Log: hg merge default
diff --git a/pypy/config/pypyoption.py b/pypy/config/pypyoption.py
--- a/pypy/config/pypyoption.py
+++ b/pypy/config/pypyoption.py
@@ -170,12 +170,8 @@
cmdline="--translationmodules",
suggests=[("objspace.allworkingmodules", False)]),
- BoolOption("usepycfiles", "Write and read pyc files when importing",
- default=True),
-
BoolOption("lonepycfiles", "Import pyc files with no matching py file",
- default=False,
- requires=[("objspace.usepycfiles", True)]),
+ default=False),
StrOption("soabi",
"Tag to differentiate extension modules built for different Python interpreters",
diff --git a/pypy/doc/how-to-release.rst b/pypy/doc/how-to-release.rst
--- a/pypy/doc/how-to-release.rst
+++ b/pypy/doc/how-to-release.rst
@@ -1,5 +1,20 @@
-Making a PyPy Release
-=====================
+The PyPy Release Process
+========================
+
+Release Policy
+++++++++++++++
+
+We try to create a stable release a few times a year. These are released on
+a branch named like release-2.x or release-4.x, and each release is tagged,
+for instance release-4.0.1.
+
+After release, inevitably there are bug fixes. It is the responsibility of
+the commiter who fixes a bug to make sure this fix is on the release branch,
+so that we can then create a tagged bug-fix release, which will hopefully
+happen more often than stable releases.
+
+How to Create a PyPy Release
+++++++++++++++++++++++++++++
Overview
--------
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/goal/targetpypystandalone.py b/pypy/goal/targetpypystandalone.py
--- a/pypy/goal/targetpypystandalone.py
+++ b/pypy/goal/targetpypystandalone.py
@@ -277,7 +277,6 @@
if config.translation.sandbox:
config.objspace.lonepycfiles = False
- config.objspace.usepycfiles = False
config.translating = True
diff --git a/pypy/module/_vmprof/test/test__vmprof.py b/pypy/module/_vmprof/test/test__vmprof.py
--- a/pypy/module/_vmprof/test/test__vmprof.py
+++ b/pypy/module/_vmprof/test/test__vmprof.py
@@ -5,14 +5,15 @@
class AppTestVMProf(object):
def setup_class(cls):
cls.space = gettestobjspace(usemodules=['_vmprof', 'struct'])
- cls.tmpfile = udir.join('test__vmprof.1').open('wb')
- cls.w_tmpfileno = cls.space.wrap(cls.tmpfile.fileno())
- cls.w_tmpfilename = cls.space.wrap(cls.tmpfile.name)
- cls.tmpfile2 = udir.join('test__vmprof.2').open('wb')
- cls.w_tmpfileno2 = cls.space.wrap(cls.tmpfile2.fileno())
- cls.w_tmpfilename2 = cls.space.wrap(cls.tmpfile2.name)
+ cls.w_tmpfilename = cls.space.wrap(str(udir.join('test__vmprof.1')))
+ cls.w_tmpfilename2 = cls.space.wrap(str(udir.join('test__vmprof.2')))
def test_import_vmprof(self):
+ tmpfile = open(self.tmpfilename, 'wb')
+ tmpfileno = tmpfile.fileno()
+ tmpfile2 = open(self.tmpfilename2, 'wb')
+ tmpfileno2 = tmpfile2.fileno()
+
import struct, sys
WORD = struct.calcsize('l')
@@ -45,7 +46,7 @@
return count
import _vmprof
- _vmprof.enable(self.tmpfileno, 0.01)
+ _vmprof.enable(tmpfileno, 0.01)
_vmprof.disable()
s = open(self.tmpfilename, 'rb').read()
no_of_codes = count(s)
@@ -56,7 +57,7 @@
pass
""" in d
- _vmprof.enable(self.tmpfileno2, 0.01)
+ _vmprof.enable(tmpfileno2, 0.01)
exec """def foo2():
pass
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
@@ -85,7 +85,7 @@
# The "imp" module does not respect this, and is allowed to find
# lone .pyc files.
# check the .pyc file
- if space.config.objspace.usepycfiles and space.config.objspace.lonepycfiles:
+ if space.config.objspace.lonepycfiles:
pycfile = filepart + ".pyc"
if file_exists(pycfile):
# existing .pyc file
@@ -888,17 +888,11 @@
"""
w = space.wrap
- if space.config.objspace.usepycfiles:
- src_stat = os.fstat(fd)
- cpathname = pathname + 'c'
- mtime = int(src_stat[stat.ST_MTIME])
- mode = src_stat[stat.ST_MODE]
- stream = check_compiled_module(space, cpathname, mtime)
- else:
- cpathname = None
- mtime = 0
- mode = 0
- stream = None
+ src_stat = os.fstat(fd)
+ cpathname = pathname + 'c'
+ mtime = int(src_stat[stat.ST_MTIME])
+ mode = src_stat[stat.ST_MODE]
+ stream = check_compiled_module(space, cpathname, mtime)
if stream:
# existing and up-to-date .pyc file
@@ -913,7 +907,7 @@
else:
code_w = parse_source_module(space, pathname, source)
- if space.config.objspace.usepycfiles and write_pyc:
+ if write_pyc:
if not space.is_true(space.sys.get('dont_write_bytecode')):
write_compiled_module(space, code_w, cpathname, mode, mtime)
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
@@ -98,6 +98,10 @@
'a=5\nb=6\rc="""hello\r\nworld"""\r', mode='wb')
p.join('mod.py').write(
'a=15\nb=16\rc="""foo\r\nbar"""\r', mode='wb')
+ setuppkg("test_bytecode",
+ a = '',
+ b = '',
+ c = '')
# create compiled/x.py and a corresponding pyc file
p = setuppkg("compiled", x = "x = 84")
@@ -119,7 +123,7 @@
stream.try_to_find_file_descriptor())
finally:
stream.close()
- if space.config.objspace.usepycfiles:
+ if not space.config.translation.sandbox:
# also create a lone .pyc file
p.join('lone.pyc').write(p.join('x.pyc').read(mode='rb'),
mode='wb')
@@ -146,6 +150,8 @@
""")
def _teardown(space, w_saved_modules):
+ p = udir.join('impsubdir')
+ p.remove()
space.appexec([w_saved_modules], """
((saved_path, saved_modules)):
import sys
@@ -646,11 +652,13 @@
# one in sys.path.
import sys
assert '_md5' not in sys.modules
- import _md5
- assert hasattr(_md5, 'hello_world')
- assert not hasattr(_md5, 'count')
- assert '(built-in)' not in repr(_md5)
- del sys.modules['_md5']
+ try:
+ import _md5
+ assert hasattr(_md5, 'hello_world')
+ assert not hasattr(_md5, 'digest_size')
+ assert '(built-in)' not in repr(_md5)
+ finally:
+ sys.modules.pop('_md5', None)
def test_shadow_extension_2(self):
if self.runappdirect: skip("hard to test: module is already imported")
@@ -669,7 +677,7 @@
assert '(built-in)' in repr(_md5)
finally:
sys.path.insert(0, sys.path.pop())
- del sys.modules['_md5']
+ sys.modules.pop('_md5', None)
def test_invalid_pathname(self):
import imp
@@ -1342,15 +1350,56 @@
assert isinstance(importer, zipimport.zipimporter)
-class AppTestNoPycFile(object):
+class AppTestWriteBytecode(object):
spaceconfig = {
- "objspace.usepycfiles": False,
- "objspace.lonepycfiles": False
+ "translation.sandbox": False
}
+
def setup_class(cls):
- usepycfiles = cls.spaceconfig['objspace.usepycfiles']
+ cls.saved_modules = _setup(cls.space)
+ sandbox = cls.spaceconfig['translation.sandbox']
+ cls.w_sandbox = cls.space.wrap(sandbox)
+
+ def teardown_class(cls):
+ _teardown(cls.space, cls.saved_modules)
+ cls.space.appexec([], """
+ ():
+ import sys
+ sys.dont_write_bytecode = False
+ """)
+
+ def test_default(self):
+ import os.path
+ from test_bytecode import a
+ assert a.__file__.endswith('a.py')
+ assert os.path.exists(a.__file__ + 'c') == (not self.sandbox)
+
+ def test_write_bytecode(self):
+ import os.path
+ import sys
+ sys.dont_write_bytecode = False
+ from test_bytecode import b
+ assert b.__file__.endswith('b.py')
+ assert os.path.exists(b.__file__ + 'c')
+
+ def test_dont_write_bytecode(self):
+ import os.path
+ import sys
+ sys.dont_write_bytecode = True
+ from test_bytecode import c
+ assert c.__file__.endswith('c.py')
+ assert not os.path.exists(c.__file__ + 'c')
+
+
+class AppTestWriteBytecodeSandbox(AppTestWriteBytecode):
+ spaceconfig = {
+ "translation.sandbox": True
+ }
+
+
+class _AppTestLonePycFileBase(object):
+ def setup_class(cls):
lonepycfiles = cls.spaceconfig['objspace.lonepycfiles']
- cls.w_usepycfiles = cls.space.wrap(usepycfiles)
cls.w_lonepycfiles = cls.space.wrap(lonepycfiles)
cls.saved_modules = _setup(cls.space)
@@ -1359,10 +1408,7 @@
def test_import_possibly_from_pyc(self):
from compiled import x
- if self.usepycfiles:
- assert x.__file__.endswith('x.pyc')
- else:
- assert x.__file__.endswith('x.py')
+ assert x.__file__.endswith('x.pyc')
try:
from compiled import lone
except ImportError:
@@ -1371,15 +1417,13 @@
assert self.lonepycfiles, "should not have found 'lone.pyc'"
assert lone.__file__.endswith('lone.pyc')
-class AppTestNoLonePycFile(AppTestNoPycFile):
+class AppTestNoLonePycFile(_AppTestLonePycFileBase):
spaceconfig = {
- "objspace.usepycfiles": True,
"objspace.lonepycfiles": False
}
-class AppTestLonePycFile(AppTestNoPycFile):
+class AppTestLonePycFile(_AppTestLonePycFileBase):
spaceconfig = {
- "objspace.usepycfiles": True,
"objspace.lonepycfiles": True
}
diff --git a/pypy/module/sys/__init__.py b/pypy/module/sys/__init__.py
--- a/pypy/module/sys/__init__.py
+++ b/pypy/module/sys/__init__.py
@@ -77,7 +77,7 @@
'meta_path' : 'space.wrap([])',
'path_hooks' : 'space.wrap([])',
'path_importer_cache' : 'space.wrap({})',
- 'dont_write_bytecode' : 'space.w_False',
+ 'dont_write_bytecode' : 'space.wrap(space.config.translation.sandbox)',
'getdefaultencoding' : 'interp_encoding.getdefaultencoding',
'setdefaultencoding' : 'interp_encoding.setdefaultencoding',
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,14 +239,12 @@
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(50):
- print 'tick...', x # <-force the GIL to be released, as
- time.sleep(0.1) # time.sleep doesn't do non-translated
+ time.sleep(0.1)
waiting.pop()
# This is normally called by app_main.py
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
@@ -4,7 +4,7 @@
from pypy.interpreter.gateway import unwrap_spec
from rpython.rtyper.lltypesystem import lltype
from rpython.rlib.rarithmetic import intmask
-from rpython.rlib import rposix
+from rpython.rlib import rposix, rtime
from rpython.translator.tool.cbuild import ExternalCompilationInfo
import os
import sys
@@ -316,13 +316,13 @@
if secs < 0:
raise OperationError(space.w_IOError,
space.wrap("Invalid argument: negative time in sleep"))
- 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()
@@ -331,7 +331,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/memory/gctransform/boehm.py b/rpython/memory/gctransform/boehm.py
--- a/rpython/memory/gctransform/boehm.py
+++ b/rpython/memory/gctransform/boehm.py
@@ -156,9 +156,9 @@
resulttype = lltype.Signed)
hop.genop('int_invert', [v_int], resultvar=hop.spaceop.result)
- def gcheader_initdata(self, defnode):
+ def gcheader_initdata(self, obj):
hdr = lltype.malloc(self.HDR, immortal=True)
- hdr.hash = lltype.identityhash_nocache(defnode.obj._as_ptr())
+ hdr.hash = lltype.identityhash_nocache(obj._as_ptr())
return hdr._obj
diff --git a/rpython/memory/gctransform/framework.py b/rpython/memory/gctransform/framework.py
--- a/rpython/memory/gctransform/framework.py
+++ b/rpython/memory/gctransform/framework.py
@@ -1479,8 +1479,8 @@
resulttype=llmemory.Address)
llops.genop('raw_memclear', [v_adr, v_totalsize])
- def gcheader_initdata(self, defnode):
- o = lltype.top_container(defnode.obj)
+ def gcheader_initdata(self, obj):
+ o = lltype.top_container(obj)
needs_hash = self.get_prebuilt_hash(o) is not None
hdr = self.gc_header_for(o, needs_hash)
return hdr._obj
diff --git a/rpython/memory/gctransform/refcounting.py b/rpython/memory/gctransform/refcounting.py
--- a/rpython/memory/gctransform/refcounting.py
+++ b/rpython/memory/gctransform/refcounting.py
@@ -286,8 +286,8 @@
hop.genop("direct_call", [self.identityhash_ptr, v_adr],
resultvar=hop.spaceop.result)
- def gcheader_initdata(self, defnode):
- top = lltype.top_container(defnode.obj)
+ def gcheader_initdata(self, obj):
+ top = lltype.top_container(obj)
return self.gcheaderbuilder.header_of_object(top)._obj
def gct_zero_gc_pointers_inside(self, hop):
diff --git a/rpython/rlib/rsocket.py b/rpython/rlib/rsocket.py
--- a/rpython/rlib/rsocket.py
+++ b/rpython/rlib/rsocket.py
@@ -516,6 +516,10 @@
"""RPython-level socket object.
"""
fd = _c.INVALID_SOCKET
+ family = 0
+ type = 0
+ proto = 0
+ timeout = -1.0
def __init__(self, family=AF_INET, type=SOCK_STREAM, proto=0,
fd=_c.INVALID_SOCKET):
@@ -531,6 +535,11 @@
self.proto = proto
self.timeout = defaults.timeout
+ @staticmethod
+ def empty_rsocket():
+ rsocket = instantiate(RSocket)
+ return rsocket
+
@rgc.must_be_light_finalizer
def __del__(self):
fd = self.fd
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, [])
diff --git a/rpython/rtyper/test/test_rdict.py b/rpython/rtyper/test/test_rdict.py
--- a/rpython/rtyper/test/test_rdict.py
+++ b/rpython/rtyper/test/test_rdict.py
@@ -1,5 +1,8 @@
from rpython.translator.translator import TranslationContext
+from rpython.annotator import model as annmodel
+from rpython.annotator.dictdef import DictKey, DictValue
from rpython.rtyper.lltypesystem import lltype, rffi
+from rpython.rtyper.lltypesystem.rstr import string_repr
from rpython.rtyper import rint
from rpython.rtyper.lltypesystem import rdict, rstr
from rpython.rtyper.test.tool import BaseRtypingTest
@@ -1182,118 +1185,88 @@
count_frees += 1
assert count_frees >= 3
-class TestStress:
+N_KEYS = 400
- def test_stress(self):
- from rpython.annotator.dictdef import DictKey, DictValue
- from rpython.annotator import model as annmodel
- dictrepr = rdict.DictRepr(None, rint.signed_repr, rint.signed_repr,
- DictKey(None, annmodel.SomeInteger()),
- DictValue(None, annmodel.SomeInteger()))
- dictrepr.setup()
- l_dict = rdict.ll_newdict(dictrepr.DICT)
- referencetable = [None] * 400
- referencelength = 0
- value = 0
+def test_stress():
+ dictrepr = rdict.DictRepr(None, rint.signed_repr, rint.signed_repr,
+ DictKey(None, annmodel.SomeInteger()),
+ DictValue(None, annmodel.SomeInteger()))
+ dictrepr.setup()
+ l_dict = rdict.ll_newdict(dictrepr.DICT)
+ reference = {}
+ value = 0
- def complete_check():
- for n, refvalue in zip(range(len(referencetable)), referencetable):
- try:
- gotvalue = rdict.ll_dict_getitem(l_dict, n)
- except KeyError:
- assert refvalue is None
- else:
- assert gotvalue == refvalue
+ def check_value(n):
+ try:
+ gotvalue = rdict.ll_dict_getitem(l_dict, n)
+ except KeyError:
+ n not in reference
+ else:
+ assert gotvalue == reference[n]
- for x in not_really_random():
- n = int(x*100.0) # 0 <= x < 400
- op = repr(x)[-1]
- if op <= '2' and referencetable[n] is not None:
- rdict.ll_dict_delitem(l_dict, n)
- referencetable[n] = None
- referencelength -= 1
- elif op <= '6':
- rdict.ll_dict_setitem(l_dict, n, value)
- if referencetable[n] is None:
- referencelength += 1
- referencetable[n] = value
- value += 1
- else:
- try:
- gotvalue = rdict.ll_dict_getitem(l_dict, n)
- except KeyError:
- assert referencetable[n] is None
- else:
- assert gotvalue == referencetable[n]
- if 1.38 <= x <= 1.39:
- complete_check()
- print 'current dict length:', referencelength
- assert l_dict.num_items == referencelength
- complete_check()
+ def complete_check():
+ for n in range(N_KEYS):
+ check_value(n)
- def test_stress_2(self):
- yield self.stress_combination, True, False
- yield self.stress_combination, False, True
- yield self.stress_combination, False, False
- yield self.stress_combination, True, True
+ for x in not_really_random():
+ n = int(x*100.0) # 0 <= x < 400
+ op = repr(x)[-1]
+ if op <= '2' and n in reference:
+ rdict.ll_dict_delitem(l_dict, n)
+ del reference[n]
+ elif op <= '6':
+ rdict.ll_dict_setitem(l_dict, n, value)
+ reference[n] = value
+ value += 1
+ else:
+ check_value(n)
+ if 1.38 <= x <= 1.39:
+ complete_check()
+ print 'current dict length:', len(reference)
+ assert l_dict.num_items == len(reference)
+ complete_check()
- def stress_combination(self, key_can_be_none, value_can_be_none):
- from rpython.rtyper.lltypesystem.rstr import string_repr
- from rpython.annotator.dictdef import DictKey, DictValue
- from rpython.annotator import model as annmodel
- print
- print "Testing combination with can_be_None: keys %s, values %s" % (
- key_can_be_none, value_can_be_none)
+ at py.test.mark.parametrize('key_can_be_none', [True, False])
+ at py.test.mark.parametrize('value_can_be_none', [True, False])
+def test_stress_2(key_can_be_none, value_can_be_none):
+ class PseudoRTyper:
+ cache_dummy_values = {}
+ dictrepr = rdict.DictRepr(PseudoRTyper(), string_repr, string_repr,
+ DictKey(None, annmodel.SomeString(key_can_be_none)),
+ DictValue(None, annmodel.SomeString(value_can_be_none)))
+ dictrepr.setup()
+ l_dict = rdict.ll_newdict(dictrepr.DICT)
+ reference = {}
+ values = not_really_random()
+ keytable = [string_repr.convert_const("foo%d" % n) for n in range(N_KEYS)]
- class PseudoRTyper:
- cache_dummy_values = {}
- dictrepr = rdict.DictRepr(PseudoRTyper(), string_repr, string_repr,
- DictKey(None, annmodel.SomeString(key_can_be_none)),
- DictValue(None, annmodel.SomeString(value_can_be_none)))
- dictrepr.setup()
- print dictrepr.lowleveltype
- for key, value in dictrepr.DICTENTRY._adtmeths.items():
- print ' %s = %s' % (key, value)
- l_dict = rdict.ll_newdict(dictrepr.DICT)
- referencetable = [None] * 400
- referencelength = 0
- values = not_really_random()
- keytable = [string_repr.convert_const("foo%d" % n)
- for n in range(len(referencetable))]
+ def check_value(n):
+ try:
+ gotvalue = rdict.ll_dict_getitem(l_dict, keytable[n])
+ except KeyError:
+ assert n not in reference
+ else:
+ assert gotvalue == reference[n]
- def complete_check():
- for n, refvalue in zip(range(len(referencetable)), referencetable):
- try:
- gotvalue = rdict.ll_dict_getitem(l_dict, keytable[n])
- except KeyError:
- assert refvalue is None
- else:
- assert gotvalue == refvalue
+ def complete_check():
+ for n in range(N_KEYS):
+ check_value(n)
- for x in not_really_random():
- n = int(x*100.0) # 0 <= x < 400
- op = repr(x)[-1]
- if op <= '2' and referencetable[n] is not None:
- rdict.ll_dict_delitem(l_dict, keytable[n])
- referencetable[n] = None
- referencelength -= 1
- elif op <= '6':
- ll_value = string_repr.convert_const(str(values.next()))
- rdict.ll_dict_setitem(l_dict, keytable[n], ll_value)
- if referencetable[n] is None:
- referencelength += 1
- referencetable[n] = ll_value
- else:
- try:
- gotvalue = rdict.ll_dict_getitem(l_dict, keytable[n])
- except KeyError:
- assert referencetable[n] is None
- else:
- assert gotvalue == referencetable[n]
- if 1.38 <= x <= 1.39:
- complete_check()
- print 'current dict length:', referencelength
- assert l_dict.num_items == referencelength
- complete_check()
-
+ for x in not_really_random():
+ n = int(x*100.0) # 0 <= x < 400
+ op = repr(x)[-1]
+ if op <= '2' and n in reference:
+ rdict.ll_dict_delitem(l_dict, keytable[n])
+ del reference[n]
+ elif op <= '6':
+ ll_value = string_repr.convert_const(str(values.next()))
+ rdict.ll_dict_setitem(l_dict, keytable[n], ll_value)
+ reference[n] = ll_value
+ else:
+ check_value(n)
+ if 1.38 <= x <= 1.39:
+ complete_check()
+ print 'current dict length:', len(reference)
+ assert l_dict.num_items == len(reference)
+ complete_check()
diff --git a/rpython/translator/c/node.py b/rpython/translator/c/node.py
--- a/rpython/translator/c/node.py
+++ b/rpython/translator/c/node.py
@@ -546,7 +546,7 @@
if needs_gcheader(T):
gct = self.db.gctransformer
if gct is not None:
- self.gc_init = gct.gcheader_initdata(self)
+ self.gc_init = gct.gcheader_initdata(self.obj)
db.getcontainernode(self.gc_init)
else:
self.gc_init = None
@@ -677,7 +677,7 @@
if needs_gcheader(T):
gct = self.db.gctransformer
if gct is not None:
- self.gc_init = gct.gcheader_initdata(self)
+ self.gc_init = gct.gcheader_initdata(self.obj)
db.getcontainernode(self.gc_init)
else:
self.gc_init = None
More information about the pypy-commit
mailing list