[pypy-commit] pypy py3k: merge default
bdkearns
noreply at buildbot.pypy.org
Sat Apr 6 06:13:33 CEST 2013
Author: Brian Kearns <bdkearns at gmail.com>
Branch: py3k
Changeset: r63088:1b3e654752cc
Date: 2013-04-06 00:13 -0400
http://bitbucket.org/pypy/pypy/changeset/1b3e654752cc/
Log: merge default
diff --git a/lib-python/conftest.py b/lib-python/conftest.py
--- a/lib-python/conftest.py
+++ b/lib-python/conftest.py
@@ -1,92 +1,90 @@
"""
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', 'binascii', '_socket',
'select', 'fcntl', '_posixsubprocess']
- 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
@@ -392,7 +390,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),
@@ -469,7 +467,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__):
@@ -485,33 +483,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':
@@ -520,9 +518,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())
@@ -531,8 +529,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)
@@ -541,34 +538,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:
@@ -576,8 +568,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:
@@ -589,13 +581,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
@@ -609,22 +601,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
@@ -634,12 +626,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):
@@ -648,4 +640,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 _thread import _get_ident as _thread_ident
except ImportError:
diff --git a/lib_pypy/_curses.py b/lib_pypy/_curses.py
--- a/lib_pypy/_curses.py
+++ b/lib_pypy/_curses.py
@@ -359,10 +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) == b"UNKNOWN KEY":
+ if key_n == ffi.NULL:
continue
- key_n = ffi.string(key_n).decode()
- key_n = 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/_dbm.py b/lib_pypy/_dbm.py
--- a/lib_pypy/_dbm.py
+++ b/lib_pypy/_dbm.py
@@ -172,7 +172,7 @@
'c': os.O_RDWR | os.O_CREAT,
'n': os.O_RDWR | os.O_CREAT | os.O_TRUNC,
}[flag]
- except KeyError as 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/_pypy_interact.py b/lib_pypy/_pypy_interact.py
--- a/lib_pypy/_pypy_interact.py
+++ b/lib_pypy/_pypy_interact.py
@@ -73,7 +73,6 @@
# ____________________________________________________________
if __name__ == '__main__': # for testing
- import os
if os.getenv('PYTHONSTARTUP'):
exec(compile(open(os.getenv('PYTHONSTARTUP')).read(), os.getenv('PYTHONSTARTUP'), 'exec'))
interactive_console()
diff --git a/lib_pypy/_sha512.py b/lib_pypy/_sha512.py
--- a/lib_pypy/_sha512.py
+++ b/lib_pypy/_sha512.py
@@ -28,23 +28,23 @@
def sha_transform(sha_info):
W = []
-
+
d = sha_info['data']
for i in range(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 range(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)
@@ -125,8 +125,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 )
@@ -159,35 +158,34 @@
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
sha_info['data'][sha_info['local']:sha_info['local']+i] = buffer[buffer_idx:buffer_idx+i]
-
+
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'] = list(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] = buffer[buffer_idx:buffer_idx + count]
@@ -207,7 +205,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;
@@ -216,7 +214,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
@@ -225,9 +223,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) ])
@@ -241,13 +239,13 @@
self._sha = sha_init()
if s:
sha_update(self._sha, s)
-
+
def update(self, s):
sha_update(self._sha, s)
-
+
def digest(self):
return sha_final(self._sha.copy())[:self._sha['digestsize']]
-
+
def hexdigest(self):
return ''.join(['%.2x' % i for i in self.digest()])
@@ -270,12 +268,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
@@ -852,7 +852,7 @@
self._reset = False
self.__locked = False
self.__closed = False
- self.__description = None
+ self.__lastrowid = None
self.__rowcount = -1
con._check_thread()
@@ -958,7 +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)
- val = _BLOB_TYPE(_ffi.buffer(blob, blob_len))
+ val = _BLOB_TYPE(_ffi.buffer(blob, blob_len)[:])
row.append(val)
return tuple(row)
@@ -972,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)
@@ -996,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)
@@ -1075,7 +1088,6 @@
next_row = self.__next_row
except AttributeError:
self.__statement._reset()
- self.__statement = None
raise StopIteration
del self.__next_row
@@ -1119,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):
@@ -1136,8 +1150,6 @@
class Statement(object):
- _DML, _DQL, _DDL = range(3)
-
_statement = None
def __init__(self, connection, sql):
@@ -1148,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')
@@ -1167,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)
@@ -1282,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)):
@@ -1387,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/cffi/api.py b/lib_pypy/cffi/api.py
--- a/lib_pypy/cffi/api.py
+++ b/lib_pypy/cffi/api.py
@@ -25,6 +25,7 @@
line = ''
return '%s%s' % (line, self.args[0])
+
class FFI(object):
r'''
The main top-level class that you instantiate once, or once per module.
@@ -220,7 +221,7 @@
it as a string or unicode string.
If 'cdata' is an enum, returns the value of the enumerator as a
- string, or '#NUMBER' if the value is out of range.
+ string, or 'NUMBER' if the value is out of range.
"""
return self._backend.string(cdata, maxlen)
diff --git a/lib_pypy/cffi/cparser.py b/lib_pypy/cffi/cparser.py
--- a/lib_pypy/cffi/cparser.py
+++ b/lib_pypy/cffi/cparser.py
@@ -2,7 +2,7 @@
from . import api, model
from .commontypes import COMMON_TYPES, resolve_common_type
try:
- from cffi import _pycparser as pycparser
+ from . import _pycparser as pycparser
except ImportError:
import pycparser
import weakref, re, sys
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/getting-started-python.rst b/pypy/doc/getting-started-python.rst
--- a/pypy/doc/getting-started-python.rst
+++ b/pypy/doc/getting-started-python.rst
@@ -46,14 +46,14 @@
2. Install build-time dependencies. On a Debian box these are::
[user at debian-box ~]$ sudo apt-get install \
- gcc make python-dev libffi-dev pkg-config \
+ gcc make python-dev libffi-dev lib-sqlite3-dev pkg-config \
libz-dev libbz2-dev libncurses-dev libexpat1-dev \
libssl-dev libgc-dev python-sphinx python-greenlet
On a Fedora-16 box these are::
[user at fedora-or-rh-box ~]$ sudo yum install \
- gcc make python-devel libffi-devel pkgconfig \
+ gcc make python-devel libffi-devel lib-sqlite3-devel pkgconfig \
zlib-devel bzip2-devel ncurses-devel expat-devel \
openssl-devel gc-devel python-sphinx python-greenlet
@@ -62,6 +62,7 @@
* ``pkg-config`` (to help us locate libffi files)
* ``libz-dev`` (for the optional ``zlib`` module)
* ``libbz2-dev`` (for the optional ``bz2`` module)
+ * ``libsqlite3-dev`` (for the optional ``sqlite3`` module via cffi)
* ``libncurses-dev`` (for the optional ``_minimal_curses`` module)
* ``libexpat1-dev`` (for the optional ``pyexpat`` module)
* ``libssl-dev`` (for the optional ``_ssl`` module)
diff --git a/pypy/doc/index.rst b/pypy/doc/index.rst
--- a/pypy/doc/index.rst
+++ b/pypy/doc/index.rst
@@ -15,7 +15,7 @@
* `FAQ`_: some frequently asked questions.
-* `Release 2.0 beta 1`_: the latest official release
+* `Release 2.0 beta 2`_: the latest official release
* `PyPy Blog`_: news and status info about PyPy
@@ -75,7 +75,7 @@
.. _`Getting Started`: getting-started.html
.. _`Papers`: extradoc.html
.. _`Videos`: video-index.html
-.. _`Release 2.0 beta 1`: http://pypy.org/download.html
+.. _`Release 2.0 beta 2`: http://pypy.org/download.html
.. _`speed.pypy.org`: http://speed.pypy.org
.. _`RPython toolchain`: translation.html
.. _`potential project ideas`: project-ideas.html
diff --git a/pypy/doc/release-2.0.0-beta2.rst b/pypy/doc/release-2.0.0-beta2.rst
new file mode 100644
--- /dev/null
+++ b/pypy/doc/release-2.0.0-beta2.rst
@@ -0,0 +1,84 @@
+===============
+PyPy 2.0 beta 2
+===============
+
+We're pleased to announce the 2.0 beta 2 release of PyPy. This is a major
+release of PyPy and we're getting very close to 2.0 final, however it includes
+quite a few new features that require further testing. Please test and report
+issues, so we can have a rock-solid 2.0 final. It also includes a performance
+regression of about 5% compared to 2.0 beta 1 that we hope to fix before
+2.0 final. The ARM support is not working yet and we're working hard to
+make it happen before the 2.0 final. The new major features are:
+
+* JIT now supports stackless features, that is greenlets and stacklets. This
+ means that JIT can now optimize the code that switches the context. It enables
+ running `eventlet`_ and `gevent`_ on PyPy (although gevent requires some
+ special support that's not quite finished, read below).
+
+* This is the first PyPy release that includes `cffi`_ as a core library.
+ Version 0.6 comes included in the PyPy library. cffi has seen a lot of
+ adoption among library authors and we believe it's the best way to wrap
+ C libaries. You can see examples of cffi usage in `_curses.py`_ and
+ `_sqlite3.py`_ in the PyPy source code.
+
+You can download the PyPy 2.0 beta 2 release here:
+
+ http://pypy.org/download.html
+
+What is PyPy?
+=============
+
+PyPy is a very compliant Python interpreter, almost a drop-in replacement for
+CPython 2.7.3. It's fast (`pypy 2.0 beta 2 and cpython 2.7.3`_
+performance comparison) due to its integrated tracing JIT compiler.
+
+This release supports x86 machines running Linux 32/64, Mac OS X 64 or
+Windows 32. It also supports ARM machines running Linux, however this is
+disabled for the beta 2 release.
+Windows 64 work is still stalling, we would welcome a volunteer
+to handle that.
+
+.. _`pypy 2.0 beta 2 and cpython 2.7.3`: http://bit.ly/USXqpP
+
+How to use PyPy?
+================
+
+We suggest using PyPy from a `virtualenv`_. Once you have a virtualenv
+installed, you can follow instructions from `pypy documentation`_ on how
+to proceed. This document also covers other `installation schemes`_.
+
+.. _`pypy documentation`: http://doc.pypy.org/en/latest/getting-started.html#installing-using-virtualenv
+.. _`virtualenv`: http://www.virtualenv.org/en/latest/
+.. _`installation schemes`: http://doc.pypy.org/en/latest/getting-started.html#installing-pypy
+
+Highlights
+==========
+
+* ``cffi`` is officially supported by PyPy. It comes included in the standard
+ library, just use ``import cffi``
+
+* stackless support - `eventlet`_ just works and `gevent`_ requires `pypycore`_
+ and `pypy-hacks`_ branch of gevent (which mostly disables cython-based
+ modules)
+
+* callbacks from C are now much faster. pyexpat is about 3x faster, cffi
+ callbacks around the same
+
+* ``__length_hint__`` is implemented (PEP 424)
+
+* a lot of numpy improvements
+
+Improvements since 1.9
+======================
+
+* `JIT hooks`_ are now a powerful tool to introspect the JITting process that
+ PyPy performs
+
+* various performance improvements compared to 1.9 and 2.0 beta 1
+
+* operations on ``long`` objects are now as fast as in CPython (from
+ roughly 2x slower)
+
+* we now have special strategies for ``dict``/``set``/``list`` which contain
+ unicode strings, which means that now such collections will be both faster
+ and more compact.
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/doc/windows.rst b/pypy/doc/windows.rst
--- a/pypy/doc/windows.rst
+++ b/pypy/doc/windows.rst
@@ -111,6 +111,18 @@
cd bzip2-1.0.5
nmake -f makefile.msc
+The sqlite3 database library
+~~~~~~~~~~~~~~~~~~~~
+
+Download http://www.sqlite.org/2013/sqlite-amalgamation-3071601.zip and extract
+it into a directory under the base directory. Also get
+http://www.sqlite.org/2013/sqlite-dll-win32-x86-3071601.zip and extract the dll
+into the bin directory, and the sqlite3.def into the sources directory.
+Now build the import library so cffi can use the header and dll::
+ lib /DEF:sqlite3.def" /OUT:sqlite3.lib"
+ copy sqlite3.lib path\to\libs
+
+
The expat XML parser
~~~~~~~~~~~~~~~~~~~~
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
@@ -217,7 +217,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/cpyext/include/patchlevel.h b/pypy/module/cpyext/include/patchlevel.h
--- a/pypy/module/cpyext/include/patchlevel.h
+++ b/pypy/module/cpyext/include/patchlevel.h
@@ -29,7 +29,7 @@
#define PY_VERSION "3.2.2"
/* PyPy version as a string */
-#define PYPY_VERSION "2.0.0-beta1"
+#define PYPY_VERSION "2.0.0-beta2"
/* Subversion Revision number of this file (not of the repository).
* Empty since Mercurial migration. */
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
@@ -181,3 +181,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/sys/version.py b/pypy/module/sys/version.py
--- a/pypy/module/sys/version.py
+++ b/pypy/module/sys/version.py
@@ -11,7 +11,7 @@
#XXX # sync CPYTHON_VERSION with patchlevel.h, package.py
CPYTHON_API_VERSION = 1013 #XXX # sync with include/modsupport.h
-PYPY_VERSION = (2, 0, 0, "beta", 1) #XXX # sync patchlevel.h
+PYPY_VERSION = (2, 0, 0, "beta", 2) #XXX # sync patchlevel.h
if platform.name == 'msvc':
COMPILER_INFO = 'MSC v.%d 32 bit' % (platform.version * 10 + 600)
diff --git a/pypy/module/test_lib_pypy/cffi_tests/snippets/distutils_module/setup.py b/pypy/module/test_lib_pypy/cffi_tests/snippets/distutils_module/setup.py
--- a/pypy/module/test_lib_pypy/cffi_tests/snippets/distutils_module/setup.py
+++ b/pypy/module/test_lib_pypy/cffi_tests/snippets/distutils_module/setup.py
@@ -1,3 +1,4 @@
+# Generated by pypy/tool/import_cffi.py
from distutils.core import setup
import snip_basic_verify
diff --git a/pypy/module/test_lib_pypy/cffi_tests/snippets/distutils_module/snip_basic_verify.py b/pypy/module/test_lib_pypy/cffi_tests/snippets/distutils_module/snip_basic_verify.py
--- a/pypy/module/test_lib_pypy/cffi_tests/snippets/distutils_module/snip_basic_verify.py
+++ b/pypy/module/test_lib_pypy/cffi_tests/snippets/distutils_module/snip_basic_verify.py
@@ -1,3 +1,4 @@
+# Generated by pypy/tool/import_cffi.py
from cffi import FFI
import sys
diff --git a/pypy/module/test_lib_pypy/cffi_tests/snippets/distutils_package_1/setup.py b/pypy/module/test_lib_pypy/cffi_tests/snippets/distutils_package_1/setup.py
--- a/pypy/module/test_lib_pypy/cffi_tests/snippets/distutils_package_1/setup.py
+++ b/pypy/module/test_lib_pypy/cffi_tests/snippets/distutils_package_1/setup.py
@@ -1,3 +1,4 @@
+# Generated by pypy/tool/import_cffi.py
from distutils.core import setup
import snip_basic_verify1
diff --git a/pypy/module/test_lib_pypy/cffi_tests/snippets/distutils_package_1/snip_basic_verify1/__init__.py b/pypy/module/test_lib_pypy/cffi_tests/snippets/distutils_package_1/snip_basic_verify1/__init__.py
--- a/pypy/module/test_lib_pypy/cffi_tests/snippets/distutils_package_1/snip_basic_verify1/__init__.py
+++ b/pypy/module/test_lib_pypy/cffi_tests/snippets/distutils_package_1/snip_basic_verify1/__init__.py
@@ -1,3 +1,4 @@
+# Generated by pypy/tool/import_cffi.py
from cffi import FFI
import sys
diff --git a/pypy/module/test_lib_pypy/cffi_tests/snippets/distutils_package_2/setup.py b/pypy/module/test_lib_pypy/cffi_tests/snippets/distutils_package_2/setup.py
--- a/pypy/module/test_lib_pypy/cffi_tests/snippets/distutils_package_2/setup.py
+++ b/pypy/module/test_lib_pypy/cffi_tests/snippets/distutils_package_2/setup.py
@@ -1,3 +1,4 @@
+# Generated by pypy/tool/import_cffi.py
from distutils.core import setup
import snip_basic_verify2
diff --git a/pypy/module/test_lib_pypy/cffi_tests/snippets/distutils_package_2/snip_basic_verify2/__init__.py b/pypy/module/test_lib_pypy/cffi_tests/snippets/distutils_package_2/snip_basic_verify2/__init__.py
--- a/pypy/module/test_lib_pypy/cffi_tests/snippets/distutils_package_2/snip_basic_verify2/__init__.py
+++ b/pypy/module/test_lib_pypy/cffi_tests/snippets/distutils_package_2/snip_basic_verify2/__init__.py
@@ -1,3 +1,4 @@
+# Generated by pypy/tool/import_cffi.py
from cffi import FFI
import sys
diff --git a/pypy/module/test_lib_pypy/cffi_tests/snippets/infrastructure/setup.py b/pypy/module/test_lib_pypy/cffi_tests/snippets/infrastructure/setup.py
--- a/pypy/module/test_lib_pypy/cffi_tests/snippets/infrastructure/setup.py
+++ b/pypy/module/test_lib_pypy/cffi_tests/snippets/infrastructure/setup.py
@@ -1,3 +1,4 @@
+# Generated by pypy/tool/import_cffi.py
from distutils.core import setup
diff --git a/pypy/module/test_lib_pypy/cffi_tests/snippets/infrastructure/snip_infrastructure/__init__.py b/pypy/module/test_lib_pypy/cffi_tests/snippets/infrastructure/snip_infrastructure/__init__.py
--- a/pypy/module/test_lib_pypy/cffi_tests/snippets/infrastructure/snip_infrastructure/__init__.py
+++ b/pypy/module/test_lib_pypy/cffi_tests/snippets/infrastructure/snip_infrastructure/__init__.py
@@ -1,3 +1,4 @@
+# Generated by pypy/tool/import_cffi.py
def func():
return 42
diff --git a/pypy/module/test_lib_pypy/cffi_tests/snippets/setuptools_module/setup.py b/pypy/module/test_lib_pypy/cffi_tests/snippets/setuptools_module/setup.py
--- a/pypy/module/test_lib_pypy/cffi_tests/snippets/setuptools_module/setup.py
+++ b/pypy/module/test_lib_pypy/cffi_tests/snippets/setuptools_module/setup.py
@@ -1,3 +1,4 @@
+# Generated by pypy/tool/import_cffi.py
from setuptools import setup
import snip_setuptools_verify
diff --git a/pypy/module/test_lib_pypy/cffi_tests/snippets/setuptools_module/snip_setuptools_verify.py b/pypy/module/test_lib_pypy/cffi_tests/snippets/setuptools_module/snip_setuptools_verify.py
--- a/pypy/module/test_lib_pypy/cffi_tests/snippets/setuptools_module/snip_setuptools_verify.py
+++ b/pypy/module/test_lib_pypy/cffi_tests/snippets/setuptools_module/snip_setuptools_verify.py
@@ -1,3 +1,4 @@
+# Generated by pypy/tool/import_cffi.py
from cffi import FFI
import sys
diff --git a/pypy/module/test_lib_pypy/cffi_tests/snippets/setuptools_package_1/setup.py b/pypy/module/test_lib_pypy/cffi_tests/snippets/setuptools_package_1/setup.py
--- a/pypy/module/test_lib_pypy/cffi_tests/snippets/setuptools_package_1/setup.py
+++ b/pypy/module/test_lib_pypy/cffi_tests/snippets/setuptools_package_1/setup.py
@@ -1,3 +1,4 @@
+# Generated by pypy/tool/import_cffi.py
from setuptools import setup
import snip_setuptools_verify1
diff --git a/pypy/module/test_lib_pypy/cffi_tests/snippets/setuptools_package_1/snip_setuptools_verify1/__init__.py b/pypy/module/test_lib_pypy/cffi_tests/snippets/setuptools_package_1/snip_setuptools_verify1/__init__.py
--- a/pypy/module/test_lib_pypy/cffi_tests/snippets/setuptools_package_1/snip_setuptools_verify1/__init__.py
+++ b/pypy/module/test_lib_pypy/cffi_tests/snippets/setuptools_package_1/snip_setuptools_verify1/__init__.py
@@ -1,3 +1,4 @@
+# Generated by pypy/tool/import_cffi.py
from cffi import FFI
import sys
diff --git a/pypy/module/test_lib_pypy/cffi_tests/snippets/setuptools_package_2/setup.py b/pypy/module/test_lib_pypy/cffi_tests/snippets/setuptools_package_2/setup.py
--- a/pypy/module/test_lib_pypy/cffi_tests/snippets/setuptools_package_2/setup.py
+++ b/pypy/module/test_lib_pypy/cffi_tests/snippets/setuptools_package_2/setup.py
@@ -1,3 +1,4 @@
+# Generated by pypy/tool/import_cffi.py
from setuptools import setup
import snip_setuptools_verify2
diff --git a/pypy/module/test_lib_pypy/cffi_tests/snippets/setuptools_package_2/snip_setuptools_verify2/__init__.py b/pypy/module/test_lib_pypy/cffi_tests/snippets/setuptools_package_2/snip_setuptools_verify2/__init__.py
--- a/pypy/module/test_lib_pypy/cffi_tests/snippets/setuptools_package_2/snip_setuptools_verify2/__init__.py
+++ b/pypy/module/test_lib_pypy/cffi_tests/snippets/setuptools_package_2/snip_setuptools_verify2/__init__.py
@@ -1,3 +1,4 @@
+# Generated by pypy/tool/import_cffi.py
from cffi import FFI
import sys
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
@@ -198,3 +198,28 @@
con = _sqlite3.connect(':memory:')
con.row_factory = 42
con.execute('select 1')
+
+def test_returning_blob_must_own_memory():
+ import gc
+ con = _sqlite3.connect(":memory:")
+ con.create_function("returnblob", 0, lambda: buffer("blob"))
+ cur = con.cursor()
+ cur.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')
+
+def test_description_after_fetchall():
+ con = _sqlite3.connect(":memory:")
+ cur = con.cursor()
+ cur.execute("select 42").fetchall()
+ assert cur.description is not None
+
+def test_executemany_lastrowid():
+ con = _sqlite3.connect(':memory:')
+ 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
@@ -43,6 +43,7 @@
def fix_permissions(basedir):
if sys.platform != 'win32':
os.system("chmod -R a+rX %s" % basedir)
+ os.system("chmod -R g-w %s" % basedir)
def package(basedir, name='pypy-nightly', rename_pypy_c='pypy',
copy_to_dir = None, override_pypy_c = None, nostrip=False):
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/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,26 @@
"""
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]
+ p1 = new_array(i1, descr=arraydescr)
+ # operations are not all removed because this new_array() is var-sized
+ # unsure exactly which operations should be left, but right now it's
+ # really buggy
+ 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 = """
diff --git a/rpython/rlib/rsocket.py b/rpython/rlib/rsocket.py
--- a/rpython/rlib/rsocket.py
+++ b/rpython/rlib/rsocket.py
@@ -80,7 +80,7 @@
def __del__(self):
if self.addr_p:
- lltype.free(self.addr_p, flavor='raw')
+ lltype.free(self.addr_p, flavor='raw', track_allocation=False)
def setdata(self, addr, addrlen):
# initialize self.addr and self.addrlen. 'addr' can be a different
@@ -271,7 +271,8 @@
result = instantiate(INETAddress)
# store the malloc'ed data into 'result' as soon as possible
# to avoid leaks if an exception occurs inbetween
- sin = lltype.malloc(_c.sockaddr_in, flavor='raw', zero=True)
+ sin = lltype.malloc(_c.sockaddr_in, flavor='raw', zero=True,
+ track_allocation=False)
result.setdata(sin, sizeof(_c.sockaddr_in))
# PLAT sin_len
rffi.setintfield(sin, 'c_sin_family', AF_INET)
@@ -337,7 +338,8 @@
result = instantiate(INET6Address)
# store the malloc'ed data into 'result' as soon as possible
# to avoid leaks if an exception occurs inbetween
- sin = lltype.malloc(_c.sockaddr_in6, flavor='raw', zero=True)
+ sin = lltype.malloc(_c.sockaddr_in6, flavor='raw', zero=True,
+ track_allocation=False)
result.setdata(sin, sizeof(_c.sockaddr_in6))
rffi.setintfield(sin, 'c_sin6_family', AF_INET6)
rffi.structcopy(sin.c_sin6_addr, in6_addr)
@@ -360,7 +362,8 @@
maxlen = sizeof(struct)
def __init__(self, path):
- sun = lltype.malloc(_c.sockaddr_un, flavor='raw', zero=True)
+ sun = lltype.malloc(_c.sockaddr_un, flavor='raw', zero=True,
+ track_allocation=False)
baseofs = offsetof(_c.sockaddr_un, 'c_sun_path')
self.setdata(sun, baseofs + len(path))
rffi.setintfield(sun, 'c_sun_family', AF_UNIX)
@@ -409,7 +412,8 @@
maxlen = minlen = sizeof(struct)
def __init__(self, pid, groups):
- addr = lltype.malloc(_c.sockaddr_nl, flavor='raw', zero=True)
+ addr = lltype.malloc(_c.sockaddr_nl, flavor='raw', zero=True,
+ track_allocation=False)
self.setdata(addr, NETLINKAddress.maxlen)
rffi.setintfield(addr, 'c_nl_family', AF_NETLINK)
rffi.setintfield(addr, 'c_nl_pid', pid)
@@ -444,7 +448,8 @@
raise RSocketError("address family mismatched")
# copy into a new buffer the address that 'addrptr' points to
addrlen = rffi.cast(lltype.Signed, addrlen)
- buf = lltype.malloc(rffi.CCHARP.TO, addrlen, flavor='raw')
+ buf = lltype.malloc(rffi.CCHARP.TO, addrlen, flavor='raw',
+ track_allocation=False)
src = rffi.cast(rffi.CCHARP, addrptr)
for i in range(addrlen):
buf[i] = src[i]
@@ -456,7 +461,8 @@
result = instantiate(INETAddress)
elif result.family != AF_INET:
raise RSocketError("address family mismatched")
- sin = lltype.malloc(_c.sockaddr_in, flavor='raw', zero=True)
+ sin = lltype.malloc(_c.sockaddr_in, flavor='raw', zero=True,
+ track_allocation=False)
result.setdata(sin, sizeof(_c.sockaddr_in))
rffi.setintfield(sin, 'c_sin_family', AF_INET) # PLAT sin_len
rffi.setintfield(sin.c_sin_addr, 'c_s_addr', s_addr)
@@ -465,7 +471,8 @@
def make_null_address(family):
klass = familyclass(family)
result = instantiate(klass)
- buf = lltype.malloc(rffi.CCHARP.TO, klass.maxlen, flavor='raw', zero=True)
+ buf = lltype.malloc(rffi.CCHARP.TO, klass.maxlen, flavor='raw', zero=True,
+ track_allocation=False)
# Initialize the family to the correct value. Avoids surprizes on
# Windows when calling a function that unexpectedly does not set
# the output address (e.g. recvfrom() on a connected IPv4 socket).
diff --git a/rpython/rtyper/lltypesystem/rffi.py b/rpython/rtyper/lltypesystem/rffi.py
--- a/rpython/rtyper/lltypesystem/rffi.py
+++ b/rpython/rtyper/lltypesystem/rffi.py
@@ -934,10 +934,8 @@
if tp is lltype.SingleFloat:
return 4
if tp is lltype.LongFloat:
- if globals()['r_void*'].BITS == 32:
- return 12
- else:
- return 16
+ import ctypes # :-/
+ return ctypes.sizeof(ctypes.c_longdouble)
assert isinstance(tp, lltype.Number)
if tp is lltype.Signed:
return LONG_BIT/8
More information about the pypy-commit
mailing list