[pypy-commit] pypy release-2.0-beta2: hg merge default
arigo
noreply at buildbot.pypy.org
Sat Apr 6 11:48:42 CEST 2013
Author: Armin Rigo <arigo at tunes.org>
Branch: release-2.0-beta2
Changeset: r63099:3eef596df459
Date: 2013-04-06 11:48 +0200
http://bitbucket.org/pypy/pypy/changeset/3eef596df459/
Log: hg merge default
diff --git a/.hgignore b/.hgignore
--- a/.hgignore
+++ b/.hgignore
@@ -70,6 +70,7 @@
^rpython/translator/cli/src/pypylib\.dll$
^rpython/translator/cli/src/query\.exe$
^rpython/translator/cli/src/main\.exe$
+^lib_pypy/__pycache__$
^lib_pypy/ctypes_config_cache/_.+_cache\.py$
^lib_pypy/ctypes_config_cache/_.+_.+_\.py$
^rpython/translator/cli/query-descriptions$
diff --git a/lib-python/conftest.py b/lib-python/conftest.py
--- a/lib-python/conftest.py
+++ b/lib-python/conftest.py
@@ -1,91 +1,89 @@
"""
test configuration(s) for running CPython's regression
-test suite on top of PyPy
+test suite on top of PyPy
"""
import py
import sys
import pypy
import re
-from pypy.interpreter.gateway import ApplevelClass
+from pypy.interpreter.gateway import ApplevelClass
from pypy.interpreter.error import OperationError
-from pypy.interpreter.module import Module as PyPyModule
+from pypy.interpreter.module import Module as PyPyModule
from pypy.interpreter.main import run_string, run_file
-# the following adds command line options as a side effect!
-from pypy.conftest import option as pypy_option
+# the following adds command line options as a side effect!
+from pypy.conftest import option as pypy_option
-from pypy.tool.pytest import appsupport
+from pypy.tool.pytest import appsupport
from pypy.tool.pytest.confpath import pypydir, rpythondir, testdir, testresultdir
from rpython.config.parse import parse_info
pytest_plugins = "resultlog",
rsyncdirs = ['.', '../pypy/']
-#
-# Interfacing/Integrating with py.test's collection process
+#
+# Interfacing/Integrating with py.test's collection process
#
def pytest_addoption(parser):
- group = parser.getgroup("complicance testing options")
- group.addoption('-T', '--timeout', action="store", type="string",
- default="1000", dest="timeout",
- help="fail a test module after the given timeout. "
- "specify in seconds or 'NUMmp' aka Mega-Pystones")
- group.addoption('--pypy', action="store", type="string",
- dest="pypy", help="use given pypy executable to run lib-python tests. "
- "This will run the tests directly (i.e. not through py.py)")
+ group = parser.getgroup("complicance testing options")
+ group.addoption('-T', '--timeout', action="store", type="string",
+ default="1000", dest="timeout",
+ help="fail a test module after the given timeout. "
+ "specify in seconds or 'NUMmp' aka Mega-Pystones")
+ group.addoption('--pypy', action="store", type="string", dest="pypy",
+ help="use given pypy executable to run lib-python tests. "
+ "This will run the tests directly (i.e. not through py.py)")
group.addoption('--filter', action="store", type="string", default=None,
- dest="unittest_filter", help="Similar to -k, XXX")
+ dest="unittest_filter", help="Similar to -k, XXX")
-def gettimeout(timeout):
+def gettimeout(timeout):
from rpython.translator.test import rpystone
- if timeout.endswith('mp'):
+ if timeout.endswith('mp'):
megapystone = float(timeout[:-2])
t, stone = pystone.Proc0(10000)
- pystonetime = t/stone
- seconds = megapystone * 1000000 * pystonetime
- return seconds
- return float(timeout)
+ pystonetime = t/stone
+ seconds = megapystone * 1000000 * pystonetime
+ return seconds
+ return float(timeout)
# ________________________________________________________________________
#
-# classification of all tests files (this is ongoing work)
+# classification of all tests files (this is ongoing work)
#
-class RegrTest:
- """ Regression Test Declaration."""
- def __init__(self, basename, core=False,
- compiler=None,
- usemodules = '',
- skip=None):
- self.basename = basename
+class RegrTest:
+ """ Regression Test Declaration."""
+ def __init__(self, basename, core=False, compiler=None, usemodules='',
+ skip=None):
+ self.basename = basename
self._usemodules = usemodules.split() + ['signal', 'rctime', 'itertools', '_socket']
- self._compiler = compiler
+ self._compiler = compiler
self.core = core
self.skip = skip
assert self.getfspath().check(), "%r not found!" % (basename,)
def usemodules(self):
- return self._usemodules #+ pypy_option.usemodules
+ return self._usemodules # + pypy_option.usemodules
usemodules = property(usemodules)
- def compiler(self):
- return self._compiler #or pypy_option.compiler
+ def compiler(self):
+ return self._compiler # or pypy_option.compiler
compiler = property(compiler)
- def ismodified(self):
+ def ismodified(self):
#XXX: ask hg
return None
- def getfspath(self):
+ def getfspath(self):
return testdir.join(self.basename)
- def run_file(self, space):
+ def run_file(self, space):
fspath = self.getfspath()
assert fspath.check()
- modname = fspath.purebasename
+ modname = fspath.purebasename
space.appexec([], '''():
from test import %(modname)s
m = %(modname)s
@@ -424,7 +422,7 @@
RegrTest('test_textwrap.py'),
RegrTest('test_thread.py', usemodules="thread", core=True),
RegrTest('test_threaded_import.py', usemodules="thread", core=True),
- RegrTest('test_threadedtempfile.py',
+ RegrTest('test_threadedtempfile.py',
usemodules="thread", core=False),
RegrTest('test_threading.py', usemodules="thread", core=True),
RegrTest('test_threading_local.py', usemodules="thread", core=True),
@@ -504,7 +502,7 @@
def pytest_configure(config):
config._basename2spec = cache = {}
- for x in testmap:
+ for x in testmap:
cache[x.basename] = x
def pytest_collect_file(path, parent, __multicall__):
@@ -520,33 +518,33 @@
return RunFileExternal(path.basename, parent=parent, regrtest=regrtest)
class RunFileExternal(py.test.collect.File):
- def __init__(self, name, parent, regrtest):
- super(RunFileExternal, self).__init__(name, parent)
- self.regrtest = regrtest
+ def __init__(self, name, parent, regrtest):
+ super(RunFileExternal, self).__init__(name, parent)
+ self.regrtest = regrtest
self.fspath = regrtest.getfspath()
- def collect(self):
- if self.regrtest.ismodified():
+ def collect(self):
+ if self.regrtest.ismodified():
name = 'modified'
else:
name = 'unmodified'
- return [ReallyRunFileExternal(name, parent=self)]
+ return [ReallyRunFileExternal(name, parent=self)]
#
-# testmethod:
+# testmethod:
# invoking in a separate process: py.py TESTFILE
#
import os
import time
import getpass
-class ReallyRunFileExternal(py.test.collect.Item):
+class ReallyRunFileExternal(py.test.collect.Item):
class ExternalFailure(Exception):
"""Failure in running subprocess"""
- def getinvocation(self, regrtest):
- fspath = regrtest.getfspath()
- python = sys.executable
+ def getinvocation(self, regrtest):
+ fspath = regrtest.getfspath()
+ python = sys.executable
pypy_script = pypydir.join('bin', 'pyinteractive.py')
alarm_script = pypydir.join('tool', 'alarm.py')
if sys.platform == 'win32':
@@ -555,9 +553,9 @@
watchdog_name = 'watchdog.py'
watchdog_script = rpythondir.join('tool', watchdog_name)
- regr_script = pypydir.join('tool', 'pytest',
+ regr_script = pypydir.join('tool', 'pytest',
'run-script', 'regrverbose.py')
-
+
regrrun = str(regr_script)
option = self.config.option
TIMEOUT = gettimeout(option.timeout.lower())
@@ -566,8 +564,7 @@
if not execpath.check():
execpath = py.path.local.sysfind(option.pypy)
if not execpath:
- raise LookupError("could not find executable %r" %
- (option.pypy,))
+ raise LookupError("could not find executable %r" % option.pypy)
# check modules
info = py.process.cmdexec("%s --info" % execpath)
@@ -576,34 +573,29 @@
if info.get('objspace.usemodules.%s' % mod) is not True:
py.test.skip("%s module not included in %s" % (mod,
execpath))
-
- cmd = "%s %s %s" %(
- execpath,
- regrrun, fspath.purebasename)
+ cmd = "%s %s %s" % (execpath, regrrun, fspath.purebasename)
# add watchdog for timing out
- cmd = "%s %s %s %s" %(
- python, watchdog_script, TIMEOUT,
- cmd)
+ cmd = "%s %s %s %s" % (python, watchdog_script, TIMEOUT, cmd)
else:
pypy_options = []
pypy_options.extend(
['--withmod-%s' % mod for mod in regrtest.usemodules])
- sopt = " ".join(pypy_options)
- cmd = "%s %s %d %s -S %s %s %s -v" %(
- python, alarm_script, TIMEOUT,
- pypy_script, sopt,
+ sopt = " ".join(pypy_options)
+ cmd = "%s %s %d %s -S %s %s %s -v" % (
+ python, alarm_script, TIMEOUT,
+ pypy_script, sopt,
regrrun, fspath.purebasename)
- return cmd
+ return cmd
- def runtest(self):
- """ invoke a subprocess running the test file via PyPy.
- record its output into the 'result/user at host' subdirectory.
- (we might want to create subdirectories for
- each user, because we will probably all produce
+ def runtest(self):
+ """ invoke a subprocess running the test file via PyPy.
+ record its output into the 'result/user at host' subdirectory.
+ (we might want to create subdirectories for
+ each user, because we will probably all produce
such result runs and they will not be the same
- i am afraid.
- """
+ i am afraid.
+ """
regrtest = self.parent.regrtest
if regrtest.skip:
if regrtest.skip is True:
@@ -611,8 +603,8 @@
else:
msg = regrtest.skip
py.test.skip(msg)
- (skipped, exit_status, test_stdout,
- test_stderr) = self.getresult(regrtest)
+ (skipped, exit_status, test_stdout, test_stderr) = \
+ self.getresult(regrtest)
if skipped:
py.test.skip(test_stderr.splitlines()[-1])
if exit_status:
@@ -624,13 +616,13 @@
out, err = excinfo.value.args
return out + err
- def getstatusouterr(self, cmd):
+ def getstatusouterr(self, cmd):
tempdir = py.test.ensuretemp(self.fspath.basename)
stdout = tempdir.join(self.fspath.basename) + '.out'
stderr = tempdir.join(self.fspath.basename) + '.err'
if sys.platform == 'win32':
- status = os.system("%s >%s 2>%s" %(cmd, stdout, stderr))
- if status>=0:
+ status = os.system("%s >%s 2>%s" % (cmd, stdout, stderr))
+ if status >= 0:
status = status
else:
status = 'abnormal termination 0x%x' % status
@@ -644,22 +636,22 @@
stdout.write('')
stderr.write('')
else:
- status = os.system("%s >>%s 2>>%s" %(cmd, stdout, stderr))
+ status = os.system("%s >>%s 2>>%s" % (cmd, stdout, stderr))
if os.WIFEXITED(status):
status = os.WEXITSTATUS(status)
else:
status = 'abnormal termination 0x%x' % status
return status, stdout.read(mode='rU'), stderr.read(mode='rU')
- def getresult(self, regrtest):
+ def getresult(self, regrtest):
cmd = self.getinvocation(regrtest)
tempdir = py.test.ensuretemp(self.fspath.basename)
oldcwd = tempdir.chdir()
exit_status, test_stdout, test_stderr = self.getstatusouterr(cmd)
oldcwd.chdir()
skipped = False
- timedout = test_stderr.rfind(26*"=" + "timedout" + 26*"=") != -1
- if not timedout:
+ timedout = test_stderr.rfind(26*"=" + "timedout" + 26*"=") != -1
+ if not timedout:
timedout = test_stderr.rfind("KeyboardInterrupt") != -1
if test_stderr.rfind(26*"=" + "skipped" + 26*"=") != -1:
skipped = True
@@ -669,12 +661,12 @@
# test in test_zipimport_support.py
if re.search(r'\bFAIL\b', test_stdout) or re.search('[^:]ERROR', test_stderr):
outcome = 'FAIL'
- exit_status = 2
- elif timedout:
- outcome = "T/O"
- else:
+ exit_status = 2
+ elif timedout:
+ outcome = "T/O"
+ else:
outcome = "ERR"
-
+
return skipped, exit_status, test_stdout, test_stderr
def _keywords(self):
@@ -683,4 +675,3 @@
if regrtest.core:
lst.append('core')
return lst
-
diff --git a/lib_pypy/_collections.py b/lib_pypy/_collections.py
--- a/lib_pypy/_collections.py
+++ b/lib_pypy/_collections.py
@@ -8,7 +8,6 @@
# Note that PyPy also contains a built-in module '_collections' which will hide
# this one if compiled in.
-import operator
try:
from threading import _get_ident as _thread_ident
except ImportError:
diff --git a/lib_pypy/_ctypes/function.py b/lib_pypy/_ctypes/function.py
--- a/lib_pypy/_ctypes/function.py
+++ b/lib_pypy/_ctypes/function.py
@@ -8,7 +8,6 @@
import _ffi
import sys
import traceback
-import warnings
try: from __pypy__ import builtinify
except ImportError: builtinify = lambda f: f
@@ -315,8 +314,12 @@
return
if argtypes is None:
- warnings.warn('C function without declared arguments called',
- RuntimeWarning, stacklevel=2)
+ # XXX this warning was originally meaning "it's going to be
+ # really slow". Now we don't worry that much about slowness
+ # of ctypes, and it's strange to get warnings for perfectly-
+ # legal code.
+ #warnings.warn('C function without declared arguments called',
+ # RuntimeWarning, stacklevel=2)
argtypes = []
if self._com_index:
@@ -342,6 +345,7 @@
if not outargs:
return result
+ from ctypes import c_void_p
simple_cdata = type(c_void_p()).__bases__[0]
outargs = [x.value if type(x).__bases__[0] is simple_cdata else x
for x in outargs]
diff --git a/lib_pypy/_curses.py b/lib_pypy/_curses.py
--- a/lib_pypy/_curses.py
+++ b/lib_pypy/_curses.py
@@ -359,9 +359,12 @@
if not lib._m_NetBSD:
for key in range(lib.KEY_MIN, lib.KEY_MAX):
key_n = lib.keyname(key)
- if key_n == ffi.NULL or ffi.string(key_n) == "UNKNOWN KEY":
+ if key_n == ffi.NULL:
continue
- key_n = ffi.string(key_n).replace('(', '').replace(')', '')
+ key_n = ffi.string(key_n)
+ if key_n == b"UNKNOWN KEY":
+ continue
+ key_n = key_n.decode().replace('(', '').replace(')', '')
globals()[key_n] = key
_setup()
diff --git a/lib_pypy/_pypy_interact.py b/lib_pypy/_pypy_interact.py
--- a/lib_pypy/_pypy_interact.py
+++ b/lib_pypy/_pypy_interact.py
@@ -74,7 +74,6 @@
# ____________________________________________________________
if __name__ == '__main__': # for testing
- import os
if os.getenv('PYTHONSTARTUP'):
execfile(os.getenv('PYTHONSTARTUP'))
interactive_console()
diff --git a/lib_pypy/_sha512.py b/lib_pypy/_sha512.py
--- a/lib_pypy/_sha512.py
+++ b/lib_pypy/_sha512.py
@@ -30,23 +30,23 @@
def sha_transform(sha_info):
W = []
-
+
d = sha_info['data']
for i in xrange(0,16):
W.append( (d[8*i]<<56) + (d[8*i+1]<<48) + (d[8*i+2]<<40) + (d[8*i+3]<<32) + (d[8*i+4]<<24) + (d[8*i+5]<<16) + (d[8*i+6]<<8) + d[8*i+7])
-
+
for i in xrange(16,80):
W.append( (Gamma1(W[i - 2]) + W[i - 7] + Gamma0(W[i - 15]) + W[i - 16]) & 0xffffffffffffffff )
-
+
ss = sha_info['digest'][:]
-
+
def RND(a,b,c,d,e,f,g,h,i,ki):
t0 = (h + Sigma1(e) + Ch(e, f, g) + ki + W[i]) & 0xffffffffffffffff
t1 = (Sigma0(a) + Maj(a, b, c)) & 0xffffffffffffffff
d = (d + t0) & 0xffffffffffffffff
h = (t0 + t1) & 0xffffffffffffffff
return d & 0xffffffffffffffff, h & 0xffffffffffffffff
-
+
ss[3], ss[7] = RND(ss[0],ss[1],ss[2],ss[3],ss[4],ss[5],ss[6],ss[7],0,0x428a2f98d728ae22)
ss[2], ss[6] = RND(ss[7],ss[0],ss[1],ss[2],ss[3],ss[4],ss[5],ss[6],1,0x7137449123ef65cd)
ss[1], ss[5] = RND(ss[6],ss[7],ss[0],ss[1],ss[2],ss[3],ss[4],ss[5],2,0xb5c0fbcfec4d3b2f)
@@ -127,8 +127,7 @@
ss[6], ss[2] = RND(ss[3],ss[4],ss[5],ss[6],ss[7],ss[0],ss[1],ss[2],77,0x597f299cfc657e2a)
ss[5], ss[1] = RND(ss[2],ss[3],ss[4],ss[5],ss[6],ss[7],ss[0],ss[1],78,0x5fcb6fab3ad6faec)
ss[4], ss[0] = RND(ss[1],ss[2],ss[3],ss[4],ss[5],ss[6],ss[7],ss[0],79,0x6c44198c4a475817)
-
-
+
dig = []
for i, x in enumerate(sha_info['digest']):
dig.append( (x + ss[i]) & 0xffffffffffffffff )
@@ -167,36 +166,35 @@
if clo < sha_info['count_lo']:
sha_info['count_hi'] += 1
sha_info['count_lo'] = clo
-
+
sha_info['count_hi'] += (count >> 29)
-
+
if sha_info['local']:
i = SHA_BLOCKSIZE - sha_info['local']
if i > count:
i = count
-
+
# copy buffer
for x in enumerate(buffer[buffer_idx:buffer_idx+i]):
sha_info['data'][sha_info['local']+x[0]] = struct.unpack('B', x[1])[0]
-
+
count -= i
buffer_idx += i
-
+
sha_info['local'] += i
if sha_info['local'] == SHA_BLOCKSIZE:
sha_transform(sha_info)
sha_info['local'] = 0
else:
return
-
+
while count >= SHA_BLOCKSIZE:
# copy buffer
sha_info['data'] = [struct.unpack('B',c)[0] for c in buffer[buffer_idx:buffer_idx + SHA_BLOCKSIZE]]
count -= SHA_BLOCKSIZE
buffer_idx += SHA_BLOCKSIZE
sha_transform(sha_info)
-
-
+
# copy buffer
pos = sha_info['local']
sha_info['data'][pos:pos+count] = [struct.unpack('B',c)[0] for c in buffer[buffer_idx:buffer_idx + count]]
@@ -216,7 +214,7 @@
sha_info['data'] = [0] * SHA_BLOCKSIZE
else:
sha_info['data'] = sha_info['data'][:count] + ([0] * (SHA_BLOCKSIZE - count))
-
+
sha_info['data'][112] = 0;
sha_info['data'][113] = 0;
sha_info['data'][114] = 0;
@@ -225,7 +223,7 @@
sha_info['data'][117] = 0;
sha_info['data'][118] = 0;
sha_info['data'][119] = 0;
-
+
sha_info['data'][120] = (hi_bit_count >> 24) & 0xff
sha_info['data'][121] = (hi_bit_count >> 16) & 0xff
sha_info['data'][122] = (hi_bit_count >> 8) & 0xff
@@ -234,9 +232,9 @@
sha_info['data'][125] = (lo_bit_count >> 16) & 0xff
sha_info['data'][126] = (lo_bit_count >> 8) & 0xff
sha_info['data'][127] = (lo_bit_count >> 0) & 0xff
-
+
sha_transform(sha_info)
-
+
dig = []
for i in sha_info['digest']:
dig.extend([ ((i>>56) & 0xff), ((i>>48) & 0xff), ((i>>40) & 0xff), ((i>>32) & 0xff), ((i>>24) & 0xff), ((i>>16) & 0xff), ((i>>8) & 0xff), (i & 0xff) ])
@@ -250,13 +248,13 @@
self._sha = sha_init()
if s:
sha_update(self._sha, getbuf(s))
-
+
def update(self, s):
sha_update(self._sha, getbuf(s))
-
+
def digest(self):
return sha_final(self._sha.copy())[:self._sha['digestsize']]
-
+
def hexdigest(self):
return ''.join(['%.2x' % ord(i) for i in self.digest()])
@@ -279,12 +277,14 @@
return new
def test():
+ import _sha512
+
a_str = "just a test string"
-
+
assert _sha512.sha512().hexdigest() == sha512().hexdigest()
assert _sha512.sha512(a_str).hexdigest() == sha512(a_str).hexdigest()
assert _sha512.sha512(a_str*7).hexdigest() == sha512(a_str*7).hexdigest()
-
+
s = sha512(a_str)
s.update(a_str)
assert _sha512.sha512(a_str+a_str).hexdigest() == s.hexdigest()
diff --git a/lib_pypy/_sqlite3.py b/lib_pypy/_sqlite3.py
--- a/lib_pypy/_sqlite3.py
+++ b/lib_pypy/_sqlite3.py
@@ -29,7 +29,6 @@
import string
import sys
import weakref
-import array
from threading import _get_ident as _thread_get_ident
try:
from __pypy__ import newlist_hint
@@ -219,7 +218,7 @@
const char **pzTail /* OUT: Pointer to unused portion of zSql */
);
-void sqlite3_result_blob(sqlite3_context*, const char*, int, void(*)(void*));
+void sqlite3_result_blob(sqlite3_context*, const void*, int, void(*)(void*));
void sqlite3_result_double(sqlite3_context*, double);
void sqlite3_result_error(sqlite3_context*, const char*, int);
void sqlite3_result_error16(sqlite3_context*, const void*, int);
@@ -853,7 +852,7 @@
self._reset = False
self.__locked = False
self.__closed = False
- self.__description = None
+ self.__lastrowid = None
self.__rowcount = -1
con._check_thread()
@@ -959,11 +958,7 @@
elif typ == _lib.SQLITE_BLOB:
blob = _lib.sqlite3_column_blob(self.__statement._statement, i)
blob_len = _lib.sqlite3_column_bytes(self.__statement._statement, i)
- # make a copy of the data into an array, in order to get
- # a read-write buffer in the end, and one that own the
- # memory for a more predictable length of time than 'blob'
- copy = array.array("c", _ffi.buffer(blob, blob_len))
- val = _BLOB_TYPE(copy)
+ val = _BLOB_TYPE(_ffi.buffer(blob, blob_len)[:])
row.append(val)
return tuple(row)
@@ -977,20 +972,24 @@
try:
if not isinstance(sql, basestring):
raise ValueError("operation parameter must be str or unicode")
- self.__description = None
+ try:
+ del self.__description
+ except AttributeError:
+ pass
self.__rowcount = -1
self.__statement = self.__connection._statement_cache.get(sql)
if self.__connection._isolation_level is not None:
- if self.__statement._kind == Statement._DDL:
+ if self.__statement._type in ("UPDATE", "DELETE", "INSERT", "REPLACE"):
+ if not self.__connection._in_transaction:
+ self.__connection._begin()
+ elif self.__statement._type == "OTHER":
if self.__connection._in_transaction:
self.__connection.commit()
- elif self.__statement._kind == Statement._DML:
- if not self.__connection._in_transaction:
- self.__connection._begin()
-
- if multiple and self.__statement._kind != Statement._DML:
- raise ProgrammingError("executemany is only for DML statements")
+ elif self.__statement._type == "SELECT":
+ if multiple:
+ raise ProgrammingError("You cannot execute SELECT "
+ "statements in executemany().")
for params in many_params:
self.__statement._set_params(params)
@@ -1001,17 +1000,26 @@
self.__statement._reset()
raise self.__connection._get_exception(ret)
- if self.__statement._kind == Statement._DML:
+ if ret == _lib.SQLITE_ROW:
+ if multiple:
+ raise ProgrammingError("executemany() can only execute DML statements.")
+ self.__build_row_cast_map()
+ self.__next_row = self.__fetch_one_row()
+ elif ret == _lib.SQLITE_DONE and not multiple:
self.__statement._reset()
- if ret == _lib.SQLITE_ROW:
- self.__build_row_cast_map()
- self.__next_row = self.__fetch_one_row()
-
- if self.__statement._kind == Statement._DML:
+ if self.__statement._type in ("UPDATE", "DELETE", "INSERT", "REPLACE"):
if self.__rowcount == -1:
self.__rowcount = 0
self.__rowcount += _lib.sqlite3_changes(self.__connection._db)
+
+ if not multiple and self.__statement._type == "INSERT":
+ self.__lastrowid = _lib.sqlite3_last_insert_rowid(self.__connection._db)
+ else:
+ self.__lastrowid = None
+
+ if multiple:
+ self.__statement._reset()
finally:
self.__connection._in_transaction = \
not _lib.sqlite3_get_autocommit(self.__connection._db)
@@ -1123,13 +1131,15 @@
rowcount = property(__get_rowcount)
def __get_description(self):
- if self.__description is None:
+ try:
+ return self.__description
+ except AttributeError:
self.__description = self.__statement._get_description()
- return self.__description
+ return self.__description
description = property(__get_description)
def __get_lastrowid(self):
- return _lib.sqlite3_last_insert_rowid(self.__connection._db)
+ return self.__lastrowid
lastrowid = property(__get_lastrowid)
def setinputsizes(self, *args):
@@ -1140,8 +1150,6 @@
class Statement(object):
- _DML, _DQL, _DDL = range(3)
-
_statement = None
def __init__(self, connection, sql):
@@ -1152,13 +1160,14 @@
if not isinstance(sql, basestring):
raise Warning("SQL is of wrong type. Must be string or unicode.")
- first_word = self._statement_kind = sql.lstrip().split(" ")[0].upper()
- if first_word in ("INSERT", "UPDATE", "DELETE", "REPLACE"):
- self._kind = Statement._DML
- elif first_word in ("SELECT", "PRAGMA"):
- self._kind = Statement._DQL
+
+ first_word = sql.lstrip().split(" ")[0].upper()
+ if first_word == "":
+ self._type = "INVALID"
+ elif first_word in ("SELECT", "INSERT", "UPDATE", "DELETE", "REPLACE"):
+ self._type = first_word
else:
- self._kind = Statement._DDL
+ self._type = "OTHER"
if isinstance(sql, unicode):
sql = sql.encode('utf-8')
@@ -1171,11 +1180,12 @@
if ret == _lib.SQLITE_OK and not self._statement:
# an empty statement, work around that, as it's the least trouble
+ self._type = "SELECT"
c_sql = _ffi.new("char[]", b"select 42")
ret = _lib.sqlite3_prepare_v2(self.__con._db, c_sql, -1,
statement_star, next_char)
self._statement = statement_star[0]
- self._kind = Statement._DQL
+
if ret != _lib.SQLITE_OK:
raise self.__con._get_exception(ret)
@@ -1286,7 +1296,7 @@
raise ValueError("parameters are of unsupported type")
def _get_description(self):
- if self._kind == Statement._DML:
+ if self._type in ("INSERT", "UPDATE", "DELETE", "REPLACE"):
return None
desc = []
for i in xrange(_lib.sqlite3_column_count(self._statement)):
@@ -1391,7 +1401,7 @@
elif typ == _lib.SQLITE_BLOB:
blob = _lib.sqlite3_value_blob(params[i])
blob_len = _lib.sqlite3_value_bytes(params[i])
- val = _BLOB_TYPE(_ffi.buffer(blob, blob_len))
+ val = _BLOB_TYPE(_ffi.buffer(blob, blob_len)[:])
else:
raise NotImplementedError
_params.append(val)
diff --git a/lib_pypy/dbm.py b/lib_pypy/dbm.py
--- a/lib_pypy/dbm.py
+++ b/lib_pypy/dbm.py
@@ -168,7 +168,7 @@
'c': os.O_RDWR | os.O_CREAT,
'n': os.O_RDWR | os.O_CREAT | os.O_TRUNC,
}[flag]
- except KeyError, e:
+ except KeyError:
raise error("arg 2 to open should be 'r', 'w', 'c', or 'n'")
a_db = getattr(lib, funcs['open'])(filename, openflag, mode)
diff --git a/lib_pypy/greenlet.py b/lib_pypy/greenlet.py
--- a/lib_pypy/greenlet.py
+++ b/lib_pypy/greenlet.py
@@ -1,4 +1,4 @@
-import _continuation, sys
+import _continuation
__version__ = "0.4.0"
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
@@ -115,9 +115,9 @@
.. branch: remove-list-smm
.. branch: bridge-logging
.. branch: curses_cffi
-
cffi implementation of _curses
.. branch: sqlite-cffi
+cffi implementation of sqlite3
-cffi implementation of sqlite3
+.. branch: release-2.0-beta2
diff --git a/pypy/module/_socket/test/test_sock_app.py b/pypy/module/_socket/test/test_sock_app.py
--- a/pypy/module/_socket/test/test_sock_app.py
+++ b/pypy/module/_socket/test/test_sock_app.py
@@ -233,7 +233,7 @@
def test_unknown_addr_as_object():
from pypy.module._socket.interp_socket import addr_as_object
- c_addr = lltype.malloc(rsocket._c.sockaddr, flavor='raw')
+ c_addr = lltype.malloc(rsocket._c.sockaddr, flavor='raw', track_allocation=False)
c_addr.c_sa_data[0] = 'c'
rffi.setintfield(c_addr, 'c_sa_family', 15)
# XXX what size to pass here? for the purpose of this test it has
diff --git a/pypy/module/pyexpat/interp_pyexpat.py b/pypy/module/pyexpat/interp_pyexpat.py
--- a/pypy/module/pyexpat/interp_pyexpat.py
+++ b/pypy/module/pyexpat/interp_pyexpat.py
@@ -305,14 +305,15 @@
w_result = space.call_function(handler, %(wargs)s)
%(post_code)s
except OperationError, e:
- parser._exc_info = e
+ if not parser._exc_info: # don't override an existing exception
+ parser._exc_info = e
XML_StopParser(parser.itself, XML_FALSE)
return %(result_error)s
return %(result_converter)s
callback = %(name)s_callback
""" % locals())
- exec str(src)
+ exec src.compile()
c_name = 'XML_Set' + name
callback_type = lltype.Ptr(lltype.FuncType(
@@ -335,7 +336,8 @@
try:
parser.UnknownEncodingHandler(space, name, info)
except OperationError, e:
- parser._exc_info = e
+ if parser._exc_info:
+ parser._exc_info = e
XML_StopParser(parser.itself, XML_FALSE)
result = 0
else:
diff --git a/pypy/module/pyexpat/test/test_parser.py b/pypy/module/pyexpat/test/test_parser.py
--- a/pypy/module/pyexpat/test/test_parser.py
+++ b/pypy/module/pyexpat/test/test_parser.py
@@ -167,3 +167,46 @@
p = pyexpat.ParserCreate()
p.ParseFile(fake_reader)
assert fake_reader.read_count == 4
+
+class AppTestPyexpat2:
+ spaceconfig = dict(usemodules=['pyexpat', 'itertools', '_socket',
+ 'rctime', 'struct', 'binascii'])
+
+ def test_django_bug(self):
+ xml_str = '<?xml version="1.0" standalone="no"?><!DOCTYPE example SYSTEM "http://example.com/example.dtd"><root/>'
+
+ from xml.dom import pulldom
+ from xml.sax import handler
+ from xml.sax.expatreader import ExpatParser as _ExpatParser
+ from StringIO import StringIO
+
+ class DefusedExpatParser(_ExpatParser):
+ def start_doctype_decl(self, name, sysid, pubid, has_internal_subset):
+ raise DTDForbidden(name, sysid, pubid)
+
+ def external_entity_ref_handler(self, context, base, sysid, pubid):
+ raise ExternalReferenceForbidden(context, base, sysid, pubid)
+
+ def reset(self):
+ _ExpatParser.reset(self)
+ parser = self._parser
+ parser.StartDoctypeDeclHandler = self.start_doctype_decl
+ parser.ExternalEntityRefHandler = self.external_entity_ref_handler
+
+
+ class DTDForbidden(ValueError):
+ pass
+
+
+ class ExternalReferenceForbidden(ValueError):
+ pass
+
+ stream = pulldom.parse(StringIO(xml_str), DefusedExpatParser())
+
+ try:
+ for event, node in stream:
+ print event, node
+ except DTDForbidden:
+ pass
+ else:
+ raise Exception("should raise DTDForbidden")
diff --git a/pypy/module/test_lib_pypy/ctypes_tests/test_functions.py b/pypy/module/test_lib_pypy/ctypes_tests/test_functions.py
--- a/pypy/module/test_lib_pypy/ctypes_tests/test_functions.py
+++ b/pypy/module/test_lib_pypy/ctypes_tests/test_functions.py
@@ -510,6 +510,7 @@
assert seen == ["yadda"]
def test_warnings(self):
+ py.test.skip("warnings are disabled")
import warnings
warnings.simplefilter("always")
with warnings.catch_warnings(record=True) as w:
diff --git a/pypy/module/test_lib_pypy/test_sqlite3.py b/pypy/module/test_lib_pypy/test_sqlite3.py
--- a/pypy/module/test_lib_pypy/test_sqlite3.py
+++ b/pypy/module/test_lib_pypy/test_sqlite3.py
@@ -1,16 +1,16 @@
"""Tests for _sqlite3.py"""
-import sys
-if sys.version_info < (2, 7):
- skip("lib_pypy._sqlite3 doesn't work with python < 2.7")
-
import pytest
from lib_pypy import _sqlite3
-def test_list_ddl():
+def pytest_funcarg__con(request):
+ con = _sqlite3.connect(':memory:')
+ request.addfinalizer(lambda: con.close())
+ return con
+
+def test_list_ddl(con):
"""From issue996. Mostly just looking for lack of exceptions."""
- connection = _sqlite3.connect(':memory:')
- cursor = connection.cursor()
+ cursor = con.cursor()
cursor.execute('CREATE TABLE foo (bar INTEGER)')
result = list(cursor)
assert result == []
@@ -21,8 +21,7 @@
result = list(cursor)
assert result == [(42,)]
-def test_total_changes_after_close():
- con = _sqlite3.connect(':memory:')
+def test_total_changes_after_close(con):
con.close()
pytest.raises(_sqlite3.ProgrammingError, "con.total_changes")
@@ -35,25 +34,22 @@
e = pytest.raises(_sqlite3.ProgrammingError, "con.cursor()")
assert '__init__' in e.value.message
-def test_cursor_check_init():
+def test_cursor_check_init(con):
class Cursor(_sqlite3.Cursor):
def __init__(self, name):
pass
- con = _sqlite3.connect(":memory:")
cur = Cursor(con)
e = pytest.raises(_sqlite3.ProgrammingError, "cur.execute('select 1')")
assert '__init__' in e.value.message
-def test_connection_after_close():
- con = _sqlite3.connect(':memory:')
+def test_connection_after_close(con):
pytest.raises(TypeError, "con()")
con.close()
# raises ProgrammingError because should check closed before check args
pytest.raises(_sqlite3.ProgrammingError, "con()")
-def test_cursor_iter():
- con = _sqlite3.connect(':memory:')
+def test_cursor_iter(con):
cur = con.cursor()
with pytest.raises(StopIteration):
next(cur)
@@ -85,8 +81,7 @@
with pytest.raises(StopIteration):
next(cur)
-def test_cursor_after_close():
- con = _sqlite3.connect(':memory:')
+def test_cursor_after_close(con):
cur = con.execute('select 1')
cur.close()
con.close()
@@ -131,11 +126,10 @@
finally:
resource.setrlimit(resource.RLIMIT_NOFILE, limit)
-def test_on_conflict_rollback_executemany():
+def test_on_conflict_rollback_executemany(con):
major, minor, micro = _sqlite3.sqlite_version.split('.')
if (int(major), int(minor), int(micro)) < (3, 2, 2):
pytest.skip("requires sqlite3 version >= 3.2.2")
- con = _sqlite3.connect(":memory:")
con.execute("create table foo(x, unique(x) on conflict rollback)")
con.execute("insert into foo(x) values (1)")
try:
@@ -147,10 +141,8 @@
con.commit()
except _sqlite3.OperationalError:
pytest.fail("_sqlite3 knew nothing about the implicit ROLLBACK")
- con.close()
-def test_statement_arg_checking():
- con = _sqlite3.connect(':memory:')
+def test_statement_arg_checking(con):
with pytest.raises(_sqlite3.Warning) as e:
con(123)
assert str(e.value) == 'SQL is of wrong type. Must be string or unicode.'
@@ -164,8 +156,7 @@
con.executescript(123)
assert str(e.value) == 'script argument must be unicode or string.'
-def test_statement_param_checking():
- con = _sqlite3.connect(':memory:')
+def test_statement_param_checking(con):
con.execute('create table foo(x)')
con.execute('insert into foo(x) values (?)', [2])
con.execute('insert into foo(x) values (?)', (2,))
@@ -183,10 +174,8 @@
with pytest.raises(ValueError) as e:
con.execute('insert into foo(x) values (?)', 2)
assert str(e.value) == 'parameters are of unsupported type'
- con.close()
-def test_explicit_begin():
- con = _sqlite3.connect(':memory:')
+def test_explicit_begin(con):
con.execute('BEGIN')
con.execute('BEGIN ')
con.execute('BEGIN')
@@ -194,25 +183,32 @@
con.execute('BEGIN')
con.commit()
-def test_row_factory_use():
- con = _sqlite3.connect(':memory:')
+def test_row_factory_use(con):
con.row_factory = 42
con.execute('select 1')
-def test_returning_blob_must_own_memory():
+def test_returning_blob_must_own_memory(con):
import gc
- con = _sqlite3.connect(":memory:")
con.create_function("returnblob", 0, lambda: buffer("blob"))
- cur = con.cursor()
- cur.execute("select returnblob()")
+ cur = con.execute("select returnblob()")
val = cur.fetchone()[0]
for i in range(5):
gc.collect()
got = (val[0], val[1], val[2], val[3])
assert got == ('b', 'l', 'o', 'b')
+ # in theory 'val' should be a read-write buffer
+ # but it's not right now
+ pytest.skip("in theory 'val' should be a read-write buffer")
+ val[1] = 'X'
+ assert got == ('b', 'X', 'o', 'b')
-def test_description_after_fetchall():
- con = _sqlite3.connect(":memory:")
+def test_description_after_fetchall(con):
cur = con.cursor()
cur.execute("select 42").fetchall()
assert cur.description is not None
+
+def test_executemany_lastrowid(con):
+ cur = con.cursor()
+ cur.execute("create table test(a)")
+ cur.executemany("insert into test values (?)", [[1], [2], [3]])
+ assert cur.lastrowid is None
diff --git a/pypy/tool/release/package.py b/pypy/tool/release/package.py
--- a/pypy/tool/release/package.py
+++ b/pypy/tool/release/package.py
@@ -67,7 +67,8 @@
'Bogus path: %r does not exist (see docstring for more info)'
% (os.path.dirname(str(pypy_c)),))
subprocess.check_call([str(pypy_c), '-c', 'import _sqlite3'])
- subprocess.check_call([str(pypy_c), '-c', 'import _curses'])
+ if not sys.platform == 'win32':
+ subprocess.check_call([str(pypy_c), '-c', 'import _curses'])
if sys.platform == 'win32' and not rename_pypy_c.lower().endswith('.exe'):
rename_pypy_c += '.exe'
binaries = [(pypy_c, rename_pypy_c)]
diff --git a/pypy/tool/release/test/test_package.py b/pypy/tool/release/test/test_package.py
--- a/pypy/tool/release/test/test_package.py
+++ b/pypy/tool/release/test/test_package.py
@@ -17,7 +17,7 @@
exe_name_in_archive = 'bin/pypy'
pypy_c = py.path.local(pypydir).join('goal', basename)
if not pypy_c.check():
- os.system("echo faked_pypy_c> %s" % (pypy_c,))
+ pypy_c.write("#!/bin/sh")
pypy_c.chmod(0755)
fake_pypy_c = True
else:
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
@@ -5,7 +5,7 @@
import os
from pypy.conftest import pypydir
-ROOT = pypydir
+ROOT = os.path.abspath(os.path.join(pypydir, '..'))
EXCLUDE = {}
diff --git a/rpython/jit/backend/arm/assembler.py b/rpython/jit/backend/arm/assembler.py
--- a/rpython/jit/backend/arm/assembler.py
+++ b/rpython/jit/backend/arm/assembler.py
@@ -305,7 +305,7 @@
self._restore_exception(mc, exc0, exc1)
mc.VPOP([vfpr.value for vfpr in r.caller_vfp_resp])
assert exc0 is not None
- assert exc1 is not None
+ assert exc1 is not None
mc.POP([gpr.value for gpr in r.caller_resp] +
[exc0.value, exc1.value])
#
@@ -526,9 +526,7 @@
self.gen_shadowstack_header(gcrootmap)
def gen_shadowstack_header(self, gcrootmap):
- # we need to put two words into the shadowstack: the MARKER_FRAME
- # and the address of the frame (fp, actually)
- # lr = rst addr
+ # lr = shadow stack top addr
# ip = *lr
rst = gcrootmap.get_root_stack_top_addr()
self.mc.gen_load_int(r.lr.value, rst)
@@ -1062,8 +1060,7 @@
self.mc.PUSH([helper.value], cond=cond)
self.load_reg(self.mc, loc, r.fp, offset, cond=cond, helper=helper)
if save_helper:
- self.mc.POP([helper.value], cond=cond)
-
+ self.mc.POP([helper.value], cond=cond)
def _mov_imm_float_to_loc(self, prev_loc, loc, cond=c.AL):
if loc.is_vfp_reg():
diff --git a/rpython/jit/backend/arm/opassembler.py b/rpython/jit/backend/arm/opassembler.py
--- a/rpython/jit/backend/arm/opassembler.py
+++ b/rpython/jit/backend/arm/opassembler.py
@@ -628,12 +628,14 @@
bool(self._regalloc.vfprm.reg_bindings))
assert self.wb_slowpath[helper_num] != 0
#
- if not is_frame and loc_base is not r.r0:
+ if loc_base is not r.r0:
# push two registers to keep stack aligned
mc.PUSH([r.r0.value, loc_base.value])
- remap_frame_layout(self, [loc_base], [r.r0], r.ip)
+ mc.MOV_rr(r.r0.value, loc_base.value)
+ if is_frame:
+ assert loc_base is r.fp
mc.BL(self.wb_slowpath[helper_num])
- if not is_frame and loc_base is not r.r0:
+ if loc_base is not r.r0:
mc.POP([r.r0.value, loc_base.value])
if card_marking:
diff --git a/rpython/jit/backend/arm/runner.py b/rpython/jit/backend/arm/runner.py
--- a/rpython/jit/backend/arm/runner.py
+++ b/rpython/jit/backend/arm/runner.py
@@ -120,7 +120,7 @@
"""ARM v7 uses hardfp ABI, requires vfp"""
hf_abi = True
backend_name = "armv7hf"
- supports_floats = False
+ supports_floats = True
supports_singlefloats = False
@@ -129,5 +129,5 @@
hf_abi = True
arch_version = 6
backend_name = "armv6hf"
- supports_floats = False
+ supports_floats = True
supports_singlefloats = False
diff --git a/rpython/jit/backend/arm/test/test_calling_convention.py b/rpython/jit/backend/arm/test/test_calling_convention.py
--- a/rpython/jit/backend/arm/test/test_calling_convention.py
+++ b/rpython/jit/backend/arm/test/test_calling_convention.py
@@ -72,7 +72,7 @@
callargs = []
def func(f0, f1, f2, f3, f4, f5, f6, i0, f7, i1, f8, f9):
callargs.append(zip(range(12),
- [f0, f1, f2, f3, f4, f5, f6, i0, f7, i1, f8, f9]))
+ [f0, f1, f2, f3, f4, f5, f6, i0, f7, i1, f8, f9]))
return f0 + f1 + f2 + f3 + f4 + f5 + f6 + float(i0 + i1) + f7 + f8 + f9
F = lltype.Float
I = lltype.Signed
@@ -103,7 +103,7 @@
callargs = []
def func(f0, f1, f2, f3, f4, f5, f6, f7, f8, f9):
callargs.append(zip(range(10),
- [f0, f1, f2, f3, f4, f5, f6, f7, f8, f9]))
+ [f0, f1, f2, f3, f4, f5, f6, f7, f8, f9]))
return f0 + f1 + f2 + f3 + f4 + f5 + f6 + f7 + f8 + f9
F = lltype.Float
FUNC = self.FuncType([F] * 10, F)
@@ -125,7 +125,7 @@
callargs = []
def func(f0, f1, f2, f3, f4, f5, f6, f7, f8, f9):
callargs.append(zip(range(10),
- [f0, f1, f2, f3, f4, f5, f6, f7, f8, f9]))
+ [f0, f1, f2, f3, f4, f5, f6, f7, f8, f9]))
return f0 + f1 + f2 + f3 + f4 + f5 + f6 + f7 + f8 + f9
I = lltype.Signed
diff --git a/rpython/jit/backend/llsupport/test/test_gc_integration.py b/rpython/jit/backend/llsupport/test/test_gc_integration.py
--- a/rpython/jit/backend/llsupport/test/test_gc_integration.py
+++ b/rpython/jit/backend/llsupport/test/test_gc_integration.py
@@ -256,7 +256,9 @@
if self.cpu.IS_64_BIT:
assert frame.jf_gcmap[idx] == (1<<29) | (1 << 30)
else:
- assert frame.jf_gcmap[idx] == (1<<24) | (1 << 23)
+ assert frame.jf_gcmap[idx]
+ exp_idx = self.cpu.JITFRAME_FIXED_SIZE - 32 * idx + 1 # +1 from i0
+ assert frame.jf_gcmap[idx] == (1 << (exp_idx + 1)) | (1 << exp_idx)
self.cpu = self.getcpu(check)
ops = '''
@@ -680,7 +682,7 @@
def f(frame, x):
# all the gc pointers are alive p1 -> p7 (but not p0)
- assert bin(frame.jf_gcmap[0]).count('1') == 7
+ assert getmap(frame).count('1') == 7 #
assert x == 1
return 2
@@ -713,7 +715,7 @@
def f(frame, arg, x):
assert not arg
assert frame.jf_gcmap[0] & 31 == 0
- assert bin(frame.jf_gcmap[0]).count('1') == 3 # p1, p2, p3, but
+ assert getmap(frame).count('1') == 3 # p1, p2, p3, but
# not in registers
frame.jf_descr = frame.jf_force_descr # make guard_not_forced fail
assert x == 1
@@ -749,7 +751,8 @@
cpu.compile_loop(loop.inputargs, loop.operations, token)
frame = lltype.cast_opaque_ptr(JITFRAMEPTR,
cpu.execute_token(token, 1, a))
- assert bin(frame.jf_gcmap[0]).count('1') == 4
+
+ assert getmap(frame).count('1') == 4
def test_call_gcmap_no_guard(self):
cpu = self.cpu
@@ -757,7 +760,7 @@
def f(frame, arg, x):
assert not arg
assert frame.jf_gcmap[0] & 31 == 0
- assert bin(frame.jf_gcmap[0]).count('1') == 3 # p1, p2, p3
+ assert getmap(frame).count('1') == 3 # p1, p2, p3
frame.jf_descr = frame.jf_force_descr # make guard_not_forced fail
assert x == 1
return lltype.nullptr(llmemory.GCREF.TO)
@@ -792,4 +795,5 @@
cpu.compile_loop(loop.inputargs, loop.operations, token)
frame = lltype.cast_opaque_ptr(JITFRAMEPTR,
cpu.execute_token(token, 1, a))
- assert bin(frame.jf_gcmap[0]).count('1') == 4
+ assert getmap(frame).count('1') == 4
+
diff --git a/rpython/jit/backend/test/calling_convention_test.py b/rpython/jit/backend/test/calling_convention_test.py
--- a/rpython/jit/backend/test/calling_convention_test.py
+++ b/rpython/jit/backend/test/calling_convention_test.py
@@ -384,7 +384,7 @@
def test_call_aligned_explicit_check(self):
if (not platform.machine().startswith('arm') and
- sys.maxint == 2 ** 31 - 1): # XXX is still necessary on x86?
+ sys.maxint == 2 ** 31 - 1): # XXX is still necessary on x86?
py.test.skip("libffi on 32bit is broken")
cpu = self.cpu
if not cpu.supports_floats:
diff --git a/rpython/jit/backend/x86/runner.py b/rpython/jit/backend/x86/runner.py
--- a/rpython/jit/backend/x86/runner.py
+++ b/rpython/jit/backend/x86/runner.py
@@ -58,10 +58,10 @@
self.assembler = Assembler386(self, self.translate_support_code)
def build_regalloc(self):
- ''' for tests'''
- from rpython.jit.backend.x86.regalloc import RegAlloc
- assert self.assembler is not None
- return RegAlloc(self.assembler, False)
+ ''' for tests'''
+ from rpython.jit.backend.x86.regalloc import RegAlloc
+ assert self.assembler is not None
+ return RegAlloc(self.assembler, False)
def setup_once(self):
self.profile_agent.startup()
diff --git a/rpython/jit/metainterp/optimizeopt/rewrite.py b/rpython/jit/metainterp/optimizeopt/rewrite.py
--- a/rpython/jit/metainterp/optimizeopt/rewrite.py
+++ b/rpython/jit/metainterp/optimizeopt/rewrite.py
@@ -456,7 +456,7 @@
[op.getarg(1),
ConstInt(index + source_start)], resbox,
descr=arraydescr)
- self.optimizer.propagate_forward(newop)
+ self.optimizer.send_extra_operation(newop)
val = self.getvalue(resbox)
if dest_value.is_virtual():
dest_value.setitem(index + dest_start, val)
diff --git a/rpython/jit/metainterp/optimizeopt/test/test_optimizeopt.py b/rpython/jit/metainterp/optimizeopt/test/test_optimizeopt.py
--- a/rpython/jit/metainterp/optimizeopt/test/test_optimizeopt.py
+++ b/rpython/jit/metainterp/optimizeopt/test/test_optimizeopt.py
@@ -4282,9 +4282,9 @@
self.optimize_loop(ops, expected)
def test_add_sub_ovf_second_operation_regular(self):
- py.test.skip("Smalltalk would like this to pass")
- # This situation occurs in Smalltalk because it uses 1-based indexing.
- # The below code is equivalent to a loop over an array.
+ py.test.skip("Smalltalk would like this to pass")
+ # This situation occurs in Smalltalk because it uses 1-based indexing.
+ # The below code is equivalent to a loop over an array.
ops = """
[i1]
i2 = int_sub(i1, 1)
@@ -7609,6 +7609,25 @@
"""
self.optimize_loop(ops, ops)
+ def test_setarrayitem_followed_by_arraycopy_2(self):
+ ops = """
+ [i1, i2]
+ p1 = new_array(i1, descr=arraydescr)
+ setarrayitem_gc(p1, 0, i2, descr=arraydescr)
+ p3 = new_array(5, descr=arraydescr)
+ call(0, p1, p3, 0, 1, 1, descr=arraycopydescr)
+ i4 = getarrayitem_gc(p3, 1, descr=arraydescr)
+ jump(i1, i4)
+ """
+ expected = """
+ [i1, i2]
+ # operations are not all removed because this new_array() is var-sized
+ p1 = new_array(i1, descr=arraydescr)
+ setarrayitem_gc(p1, 0, i2, descr=arraydescr)
+ jump(i1, i2)
+ """
+ self.optimize_loop(ops, expected)
+
def test_heap_cache_virtuals_forced_by_delayed_setfield(self):
py.test.skip('not yet supoprted')
ops = """
More information about the pypy-commit
mailing list