[pypy-commit] pypy release-2.0-beta2: fix those tests (how it have ever worked?)
Author: Maciej Fijalkowski fij...@gmail.com Branch: release-2.0-beta2 Changeset: r63045:fa07639d3d4e Date: 2013-04-05 11:23 +0200 http://bitbucket.org/pypy/pypy/changeset/fa07639d3d4e/ Log:fix those tests (how it have ever worked?) 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): ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy default: fix those tests (how it have ever worked?)
Author: Maciej Fijalkowski fij...@gmail.com Branch: Changeset: r63046:44a0540290bc Date: 2013-04-05 11:23 +0200 http://bitbucket.org/pypy/pypy/changeset/44a0540290bc/ Log:fix those tests (how it have ever worked?) 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): ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy default: Add a failing test
Author: Armin Rigo ar...@tunes.org Branch: Changeset: r63047:a163d0d435d5 Date: 2013-04-05 11:57 +0200 http://bitbucket.org/pypy/pypy/changeset/a163d0d435d5/ Log:Add a failing test diff --git a/lib_pypy/_sqlite3.py b/lib_pypy/_sqlite3.py --- a/lib_pypy/_sqlite3.py +++ b/lib_pypy/_sqlite3.py @@ -218,7 +218,7 @@ const char **pzTail /* OUT: Pointer to unused portion of zSql */ ); -void sqlite3_result_blob(sqlite3_context*, const void*, int, void(*)(void*)); +void sqlite3_result_blob(sqlite3_context*, const char*, 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); 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,15 @@ 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') ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy default: Fix the failing test (blob returned by sqlite3 need to be kept alive,
Author: Armin Rigo ar...@tunes.org Branch: Changeset: r63048:961fb066e7b7 Date: 2013-04-05 12:00 +0200 http://bitbucket.org/pypy/pypy/changeset/961fb066e7b7/ Log:Fix the failing test (blob returned by sqlite3 need to be kept alive, which require making a copy; CPython does a copy too.) diff --git a/lib_pypy/_sqlite3.py b/lib_pypy/_sqlite3.py --- a/lib_pypy/_sqlite3.py +++ b/lib_pypy/_sqlite3.py @@ -29,6 +29,7 @@ import string import sys import weakref +import array from threading import _get_ident as _thread_get_ident try: from __pypy__ import newlist_hint @@ -958,7 +959,11 @@ 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)) +# 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) row.append(val) return tuple(row) ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy default: Don't track allocations that go straight into setdata(), where they
Author: Armin Rigo ar...@tunes.org Branch: Changeset: r63049:c2e8c09de077 Date: 2013-04-05 12:13 +0200 http://bitbucket.org/pypy/pypy/changeset/c2e8c09de077/ Log:Don't track allocations that go straight into setdata(), where they will be handled by the __del__(). 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). ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy default: Use ctypes to get the size of long double reasonably. The issue is
Author: Armin Rigo ar...@tunes.org Branch: Changeset: r63050:20bd465b4b06 Date: 2013-04-05 12:20 +0200 http://bitbucket.org/pypy/pypy/changeset/20bd465b4b06/ Log:Use ctypes to get the size of long double reasonably. The issue is that it's not always 12/16 on all platforms; e.g. on Windows it is 8. 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 ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy default: add libsqlite3 to build instructions
Author: Matti Picus matti.pi...@gmail.com Branch: Changeset: r63051:0bd57f2b6c51 Date: 2013-04-05 14:00 +0300 http://bitbucket.org/pypy/pypy/changeset/0bd57f2b6c51/ Log:add libsqlite3 to build instructions 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@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@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`` modulei 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/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 ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy default: typo
Author: Matti Picus matti.pi...@gmail.com Branch: Changeset: r63052:13d908d37509 Date: 2013-04-05 14:04 +0300 http://bitbucket.org/pypy/pypy/changeset/13d908d37509/ Log:typo 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 @@ -62,7 +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`` modulei via cffi) + * ``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) ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy release-2.0-beta2: merge default
Author: Maciej Fijalkowski fij...@gmail.com Branch: release-2.0-beta2 Changeset: r63053:da4d2a8bc441 Date: 2013-04-05 13:31 +0200 http://bitbucket.org/pypy/pypy/changeset/da4d2a8bc441/ Log:merge default diff --git a/lib_pypy/_sqlite3.py b/lib_pypy/_sqlite3.py --- a/lib_pypy/_sqlite3.py +++ b/lib_pypy/_sqlite3.py @@ -1167,7 +1167,7 @@ if ret == _lib.SQLITE_OK and not self._statement: # an empty statement, work around that, as it's the least trouble -c_sql = _ffi.new(char[], select 42) +c_sql = _ffi.new(char[], bselect 42) ret = _lib.sqlite3_prepare_v2(self.__con._db, c_sql, -1, statement_star, next_char) self._statement = statement_star[0] 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/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
[pypy-commit] pypy.org extradoc: Add the text from esr as the first part of performance.html.
Author: Armin Rigo ar...@tunes.org Branch: extradoc Changeset: r385:a1796ffb4d27 Date: 2013-04-05 14:01 +0200 http://bitbucket.org/pypy/pypy.org/changeset/a1796ffb4d27/ Log:Add the text from esr as the first part of performance.html. diff --git a/performance.html b/performance.html --- a/performance.html +++ b/performance.html @@ -46,6 +46,214 @@ div div id=main h1 class=titlePerformance/h1 +div class=contents topic id=contents +p class=topic-title firstContents/p +ul class=simple +lia class=reference internal href=#optimization-strategy id=id1Optimization strategy/a/li +lia class=reference internal href=#micro-tuning-tips id=id2Micro-tuning tips/a/li +lia class=reference internal href=#insider-s-point-of-view id=id3Insider's point of view/a/li +/ul +/div +pThis document collects strategies, tactics and tricks for making your +code run faster under PyPy. Many of these are also useful hints for +stock Python and other languages. For contrast, we also describe some +CPython (stock Python) optimizations that are not needed in PyPy./p +div class=section id=optimization-strategy +h1a class=toc-backref href=#id1Optimization strategy/a/h1 +pThese suggestions apply to all computer languages. They're here as +reminders of things to try before any Python or PyPy-specific tweaking./p +div class=section id=build-a-regression-test-suite +h2Build a regression-test suite/h2 +pBefore you start tuning, build a regression-test suite for your code. +This front-loads a significant amount of work, but it means you can +try lots of optimizations without worrying so much about introducing +functional bugs./p +/div +div class=section id=measure-don-t-guess +h2Measure, don't guess/h2 +pHuman beings are bad at guessing or intuiting where the hotspots in code are. +Measure, don't guess; use a profiler to pin down the 20% of the +code where the code is spending 80% of its time, then speed-tune that./p +pMeasuring will save you a lot of effort wasted on tuning parts of the code +that aren't actually bottlenecks./p +pAs you tune, re-profile frequently so you can see how the hottest spots +are shifting around./p +/div +div class=section id=i-o-bound-is-different-from-compute-bound +h2I/O-bound is different from compute-bound/h2 +pBe aware of the difference between code that is compute-bound (slow +because it's doing a huge number of instructions) and code that is I/O +bound (slow because of disk or network delays)./p +pExpect to get most of your gains from optimizing compute-bound code. +It's usually (though not always) a sign that you're near the end of +worthwhile tuning when profiling shows that the bulk of the +application's time is spent on network and disk I/O./p +/div +div class=section id=tune-your-algorithms-first +h2Tune your algorithms first/h2 +pGenerally, when your code is doing things that are O(n**2) or larger +in the size of your data set, the cost of those operations is going +to swamp any small gains you can pick up with the tricks we describe +here./p +pTune your algorithms first. It's time to think about applying our +list of micro-tuning tips emafter/em you think you've optimized out +intrinsically expensive operations./p +pThat said, be prepared for the possibility that you will discover +better-hidden algorithmic problems as you micro-tune. Likely +you will go through this cycle more than once./p +/div +div class=section id=focus-on-tight-loops +h2Focus on tight loops/h2 +pIt's extremely common for high time costs to lurk within some +innocuous-looking code inside a tight loop - especially in code +that does something like a searching/matching/lookup operation +or any kind of graph traversal./p +pProbably the most common kind of performance-killer in compute-bound +code is an O(n**2) operation that is disguised by being some sort of +O(n) lookup or match inside an O(n) loop./p +pAnother common time-sink is relatively expensive common-setup +operations that are performed inside tight loops but could be moved +to before they start. (For a representative case of this, see the +micro-tuning tip on regexp compilation.)/p +/div +div class=section id=smaller-is-faster +h2Smaller is faster/h2 +pModern computers have multiple levels of memory caching, some directly +on the processor chip. Causing a cache miss at any level incurs a +performance penalty proportional to random-access time for the next +outward (and much slower) layer of cache./p +pAccordingly, smaller is faster. Programs or routines with a small +enough working set to fit inside a fast cache will be as fast as +that cache is. To make your code fast, reduce the length of the +series of Python or JIT-compiler opcodes it generates by making +it simpler./p +pThe tradeoff here is that algorithmic tuning often trades time for +space - that is, it increases the size of an algorithm's working set +by including pre-computations or tables or reverse maps in order to +avoid O(n**2) operations./p +pIt's impossible to predict in advance where the
[pypy-commit] pypy default: write the release announcement
Author: Maciej Fijalkowski fij...@gmail.com Branch: Changeset: r63054:03d69244d043 Date: 2013-04-05 14:12 +0200 http://bitbucket.org/pypy/pypy/changeset/03d69244d043/ Log:write the release announcement 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. ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy default: merge
Author: Maciej Fijalkowski fij...@gmail.com Branch: Changeset: r63055:1f9677f6bba1 Date: 2013-04-05 14:13 +0200 http://bitbucket.org/pypy/pypy/changeset/1f9677f6bba1/ Log:merge diff --git a/lib_pypy/_sqlite3.py b/lib_pypy/_sqlite3.py --- a/lib_pypy/_sqlite3.py +++ b/lib_pypy/_sqlite3.py @@ -29,6 +29,7 @@ import string import sys import weakref +import array from threading import _get_ident as _thread_get_ident try: from __pypy__ import newlist_hint @@ -218,7 +219,7 @@ const char **pzTail /* OUT: Pointer to unused portion of zSql */ ); -void sqlite3_result_blob(sqlite3_context*, const void*, int, void(*)(void*)); +void sqlite3_result_blob(sqlite3_context*, const char*, 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); @@ -958,7 +959,11 @@ 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)) +# 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) row.append(val) return tuple(row) 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@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@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/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/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,15 @@ 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') 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
[pypy-commit] pypy default: update this
Author: Maciej Fijalkowski fij...@gmail.com Branch: Changeset: r63056:09ca29d0ccba Date: 2013-04-05 14:14 +0200 http://bitbucket.org/pypy/pypy/changeset/09ca29d0ccba/ Log:update this 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 ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] cffi default: Hack to support, on top of CPython, older versions of pycparser
Author: Armin Rigo ar...@tunes.org Branch: Changeset: r1234:c2539e8cdc21 Date: 2013-04-05 14:22 +0200 http://bitbucket.org/cffi/cffi/changeset/c2539e8cdc21/ Log:Hack to support, on top of CPython, older versions of pycparser diff --git a/testing/test_zintegration.py b/testing/test_zintegration.py --- a/testing/test_zintegration.py +++ b/testing/test_zintegration.py @@ -23,6 +23,12 @@ modules = ('cffi', '_cffi_backend') except ImportError: modules = ('cffi', '_cffi_backend', 'pycparser') +try: +import ply +except ImportError: +pass +else: +modules += ('ply',) # needed for older versions of pycparser for module in modules: target = imp.find_module(module)[1] os.symlink(target, os.path.join(site_packages, ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy release-2.0-beta2: merge default
Author: Maciej Fijalkowski fij...@gmail.com Branch: release-2.0-beta2 Changeset: r63059:61273f6466dc Date: 2013-04-05 14:28 +0200 http://bitbucket.org/pypy/pypy/changeset/61273f6466dc/ Log:merge default diff --git a/lib_pypy/_sqlite3.py b/lib_pypy/_sqlite3.py --- a/lib_pypy/_sqlite3.py +++ b/lib_pypy/_sqlite3.py @@ -1080,7 +1080,6 @@ next_row = self.__next_row except AttributeError: self.__statement._reset() -self.__statement = None raise StopIteration del self.__next_row 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 @@ -210,3 +210,9 @@ 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 ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] cffi release-0.6: Mark the release 0.6.
Author: Armin Rigo ar...@tunes.org Branch: release-0.6 Changeset: r1235:22024b307b76 Date: 2013-04-05 14:27 +0200 http://bitbucket.org/cffi/cffi/changeset/22024b307b76/ Log:Mark the release 0.6. ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy default: we can't reset the statement to none here, fix it
Author: Maciej Fijalkowski fij...@gmail.com Branch: Changeset: r63058:221d5aeae574 Date: 2013-04-05 14:27 +0200 http://bitbucket.org/pypy/pypy/changeset/221d5aeae574/ Log:we can't reset the statement to none here, fix it diff --git a/lib_pypy/_sqlite3.py b/lib_pypy/_sqlite3.py --- a/lib_pypy/_sqlite3.py +++ b/lib_pypy/_sqlite3.py @@ -1080,7 +1080,6 @@ next_row = self.__next_row except AttributeError: self.__statement._reset() -self.__statement = None raise StopIteration del self.__next_row 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 @@ -210,3 +210,9 @@ 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 ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] cffi release-0.6: Add the checksums
Author: Armin Rigo ar...@tunes.org Branch: release-0.6 Changeset: r1236:4cf03951bacb Date: 2013-04-05 14:31 +0200 http://bitbucket.org/cffi/cffi/changeset/4cf03951bacb/ Log:Add the checksums diff --git a/doc/source/index.rst b/doc/source/index.rst --- a/doc/source/index.rst +++ b/doc/source/index.rst @@ -94,9 +94,9 @@ - Or grab the most current version by following the instructions below. - - MD5: ... + - MD5: 5be33b1ab0247a984d42b27344519337 - - SHA: ... + - SHA: e104c0d385e46c008080a3c751fa40d3f07f88be * Or get it from the `Bitbucket page`_: ``hg clone https://bitbucket.org/cffi/cffi`` ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] cffi default: Update the version of PyPy required
Author: Armin Rigo ar...@tunes.org Branch: Changeset: r1237:6ae25e98df41 Date: 2013-04-05 14:40 +0200 http://bitbucket.org/cffi/cffi/changeset/6ae25e98df41/ Log:Update the version of PyPy required diff --git a/doc/source/index.rst b/doc/source/index.rst --- a/doc/source/index.rst +++ b/doc/source/index.rst @@ -63,7 +63,7 @@ left. It supports CPython 2.6; 2.7; 3.x (tested with 3.2 and 3.3); -and PyPy 2.0 beta1 or later. +and PyPy 2.0 beta2 or later. Its speed is comparable to ctypes on CPython (a bit faster but a higher warm-up time). It is already faster on PyPy (1.5x-2x), but not yet @@ -71,7 +71,7 @@ Requirements: -* CPython 2.6 or 2.7 or 3.x, or PyPy trunk +* CPython 2.6 or 2.7 or 3.x, or PyPy 2.0 beta2 * on CPython you need to build the C extension module, so you need ``python-dev`` and ``libffi-dev`` (for Windows, libffi is included ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] cffi release-0.6: hg merge default
Author: Armin Rigo ar...@tunes.org Branch: release-0.6 Changeset: r1238:598753c0dca2 Date: 2013-04-05 14:40 +0200 http://bitbucket.org/cffi/cffi/changeset/598753c0dca2/ Log:hg merge default diff --git a/doc/source/index.rst b/doc/source/index.rst --- a/doc/source/index.rst +++ b/doc/source/index.rst @@ -63,7 +63,7 @@ left. It supports CPython 2.6; 2.7; 3.x (tested with 3.2 and 3.3); -and PyPy 2.0 beta1 or later. +and PyPy 2.0 beta2 or later. Its speed is comparable to ctypes on CPython (a bit faster but a higher warm-up time). It is already faster on PyPy (1.5x-2x), but not yet @@ -71,7 +71,7 @@ Requirements: -* CPython 2.6 or 2.7 or 3.x, or PyPy trunk +* CPython 2.6 or 2.7 or 3.x, or PyPy 2.0 beta2 * on CPython you need to build the C extension module, so you need ``python-dev`` and ``libffi-dev`` (for Windows, libffi is included ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy.org extradoc: fix the typo
Author: Maciej Fijalkowski fij...@gmail.com Branch: extradoc Changeset: r386:261b2d7db039 Date: 2013-04-05 15:18 +0200 http://bitbucket.org/pypy/pypy.org/changeset/261b2d7db039/ Log:fix the typo diff --git a/source/performance.txt b/source/performance.txt --- a/source/performance.txt +++ b/source/performance.txt @@ -179,7 +179,7 @@ with the admittedly less readable:: - s = %(head)%(body)%(maybe)%(tail) % locals() + s = %(head)s%(body)s%(maybe)s%(tail)s % locals() or even:: ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy.org extradoc: Regenerate
Author: Armin Rigo ar...@tunes.org Branch: extradoc Changeset: r387:9fe79f577903 Date: 2013-04-05 15:19 +0200 http://bitbucket.org/pypy/pypy.org/changeset/9fe79f577903/ Log:Regenerate diff --git a/performance.html b/performance.html --- a/performance.html +++ b/performance.html @@ -195,7 +195,7 @@ /pre pwith the admittedly less readable:/p pre class=literal-block -s = quot;%(head)%(body)%(maybe)%(tail)quot; % locals() +s = quot;%(head)s%(body)s%(maybe)s%(tail)squot; % locals() /pre por even:/p pre class=literal-block ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy default: (fijal, bivab) fix test_gc_integration on ARM. When calling the writebarrier on
Author: David Schneider david.schnei...@picle.org Branch: Changeset: r63062:55a59cc5a0b5 Date: 2013-04-05 17:06 +0200 http://bitbucket.org/pypy/pypy/changeset/55a59cc5a0b5/ Log:(fijal, bivab) fix test_gc_integration on ARM. When calling the writebarrier on the jitframe the argument was not passed correctly 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 @@ -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) 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/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] == (129) | (1 30) else: -assert frame.jf_gcmap[idx] == (124) | (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 + ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy default: Enable float support on ARM hardfloat.
Author: David Schneider david.schnei...@picle.org Branch: Changeset: r63063:473a75371871 Date: 2013-04-05 17:17 +0200 http://bitbucket.org/pypy/pypy/changeset/473a75371871/ Log:Enable float support on ARM hardfloat. Currently requires a patched version of CPython with the latest libffi from git to run all the tests successfully. 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 ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy default: merge heads
Author: David Schneider david.schnei...@picle.org Branch: Changeset: r63064:7fdab13dc79c Date: 2013-04-05 17:19 +0200 http://bitbucket.org/pypy/pypy/changeset/7fdab13dc79c/ Log:merge heads 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) ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy default: merge release-2.0-beta2 back into default, to get the updated version number
Author: Armin Rigo ar...@tunes.org Branch: Changeset: r63065:ad65bcfd3efb Date: 2013-04-05 17:39 +0200 http://bitbucket.org/pypy/pypy/changeset/ad65bcfd3efb/ Log:merge release-2.0-beta2 back into default, to get the updated version number 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 2.7.3 /* 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/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) ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy default: fix this copy more simply and in another place
Author: Brian Kearns bdkea...@gmail.com Branch: Changeset: r63066:ffe9f0680418 Date: 2013-04-05 13:38 -0400 http://bitbucket.org/pypy/pypy/changeset/ffe9f0680418/ Log:fix this copy more simply and in another place 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 @@ -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) @@ -1391,7 +1386,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) ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy default: fix test_tabs to check rpython too and make the test pass
Author: David Schneider david.schnei...@picle.org Branch: Changeset: r63067:8a5f5f3f1a51 Date: 2013-04-05 19:36 +0200 http://bitbucket.org/pypy/pypy/changeset/8a5f5f3f1a51/ Log:fix test_tabs to check rpython too and make the test pass 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]) # @@ -1060,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/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/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
[pypy-commit] pypy default: merge heads
Author: David Schneider david.schnei...@picle.org Branch: Changeset: r63068:e06dbffccdc6 Date: 2013-04-05 19:43 +0200 http://bitbucket.org/pypy/pypy/changeset/e06dbffccdc6/ Log:merge heads 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 @@ -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) @@ -1391,7 +1386,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) ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy default: more cleanups for sqlite
Author: Brian Kearns bdkea...@gmail.com Branch: Changeset: r63069:f09e57516642 Date: 2013-04-05 16:32 -0400 http://bitbucket.org/pypy/pypy/changeset/f09e57516642/ Log:more cleanups for sqlite 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() @@ -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) @@ -1118,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): @@ -1135,8 +1150,6 @@ class Statement(object): -_DML, _DQL, _DDL = range(3) - _statement = None def __init__(self, connection, sql): @@ -1147,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 +
[pypy-commit] pypy default: Issue #1435: Add a failing test
Author: Armin Rigo ar...@tunes.org Branch: Changeset: r63070:ba3fbbd1e5ba Date: 2013-04-05 23:35 +0200 http://bitbucket.org/pypy/pypy/changeset/ba3fbbd1e5ba/ Log:Issue #1435: Add a failing test 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 @@ -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 = ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy reflex-support: doh, don't touch memory after free-ing it ...
Author: Wim Lavrijsen wlavrij...@lbl.gov Branch: reflex-support Changeset: r63071:7b2dc9dd0300 Date: 2013-04-05 14:33 -0700 http://bitbucket.org/pypy/pypy/changeset/7b2dc9dd0300/ Log:doh, don't touch memory after free-ing it ... diff --git a/pypy/module/cppyy/capi/loadable_capi.py b/pypy/module/cppyy/capi/loadable_capi.py --- a/pypy/module/cppyy/capi/loadable_capi.py +++ b/pypy/module/cppyy/capi/loadable_capi.py @@ -1,10 +1,11 @@ from rpython.rtyper.lltypesystem import rffi, lltype from rpython.rlib import jit, jit_libffi, libffi, rdynload, objectmodel +from rpython.rlib.rarithmetic import r_singlefloat from rpython.tool import leakfinder from pypy.interpreter.error import OperationError -from pypy.module._cffi_backend import ctypefunc, ctypeprim, ctypeptr, misc +from pypy.module._cffi_backend import ctypefunc, ctypeprim, cdataobj, misc from pypy.module.cppyy.capi.capi_types import C_SCOPE, C_TYPE, C_OBJECT,\ C_METHOD, C_INDEX, C_INDEX_ARRAY, WLAVC_INDEX, C_METHPTRGETTER_PTR @@ -72,11 +73,14 @@ buffer) resultdata = rffi.ptradd(buffer, cif_descr.exchange_result) +# this wrapping is unnecessary, but the assumption is that given the +# immediate unwrapping, the round-trip is removed +w_res = self.ctitem.copy_and_convert_to_object(resultdata) finally: if raw_string != rffi.cast(rffi.CCHARP, 0): rffi.free_charp(raw_string) lltype.free(buffer, flavor='raw') -return rffi.cast(rffi.LONGP, resultdata) +return w_res class State(object): def __init__(self, space): @@ -107,7 +111,7 @@ c_double = nt.new_primitive_type(space, 'double') c_ccharp = nt.new_pointer_type(space, c_char) -c_index_array = nt.new_primitive_type(space, 'unsigned long') # likewise ... +c_index_array = nt.new_pointer_type(space, c_void) c_voidp = nt.new_pointer_type(space, c_void) c_size_t = nt.new_primitive_type(space, 'size_t') @@ -247,16 +251,22 @@ state.capi_calls[name] = c_call return c_call.ctype.rcall(c_call._cdata, args) -def _longptr_to_int(longptr): -# TODO: not understanding why this should be rffi.LONGP instead of rffi.INTP ?? -return int(rffi.cast(rffi.LONGP, longptr)[0]) +def _cdata_to_cobject(space, w_cdata): +return rffi.cast(C_OBJECT, space.int_w(w_cdata)) + +def _cdata_to_size_t(space, w_cdata): +return rffi.cast(rffi.SIZE_T, space.int_w(w_cdata)) + +def _cdata_to_ptr(space, w_cdata): # TODO: this is both a hack and dreadfully slow +return rffi.cast(rffi.VOIDP, +space.interp_w(cdataobj.W_CData, w_cdata, can_be_None=False)._cdata) def c_load_dictionary(name): return libffi.CDLL(name) # name to opaque C++ scope representation def c_num_scopes(space, cppscope): -return call_capi(space, 'num_scopes', [_Arg(l=cppscope.handle)])[0] +return space.int_w(call_capi(space, 'num_scopes', [_Arg(l=cppscope.handle)])) def c_scope_name(space, cppscope, iscope): args = [_Arg(l=cppscope.handle), _Arg(l=iscope)] return charp2str_free(space, call_capi(space, 'scope_name', args)) @@ -264,16 +274,16 @@ def c_resolve_name(space, name): return charp2str_free(space, call_capi(space, 'resolve_name', [_Arg(s=name)])) def c_get_scope_opaque(space, name): -return rffi.cast(C_SCOPE, call_capi(space, 'get_scope', [_Arg(s=name)])[0]) +return rffi.cast(C_SCOPE, space.int_w(call_capi(space, 'get_scope', [_Arg(s=name)]))) def c_get_template(space, name): -return rffi.cast(C_TYPE, call_capi(space, 'get_template', [_Arg(s=name)])[0]) +return rffi.cast(C_TYPE, space.int_w(call_capi(space, 'get_template', [_Arg(s=name)]))) def c_actual_class(space, cppclass, cppobj): args = [_Arg(l=cppclass.handle), _Arg(l=cppobj)] -return rffi.cast(C_TYPE, call_capi(space, 'actual_class', args)[0]) +return rffi.cast(C_TYPE, space.int_w(call_capi(space, 'actual_class', args))) # memory management -- def c_allocate(space, cppclass): -return rffi.cast(C_OBJECT, call_capi(space, 'allocate', [_Arg(l=cppclass.handle)])[0]) +return _cdata_to_cobject(space, call_capi(space, 'allocate', [_Arg(l=cppclass.handle)])) def c_deallocate(space, cppclass, cppobject): call_capi(space, 'deallocate', [_Arg(l=cppclass.handle), _Arg(l=cppobject)]) def c_destruct(space, cppclass, cppobject): @@ -285,65 +295,66 @@ call_capi(space, 'call_v', args) def c_call_b(space, cppmethod, cppobject, nargs, cargs): args = [_Arg(l=cppmethod), _Arg(l=cppobject), _Arg(l=nargs), _Arg(vp=cargs)] -return rffi.cast(rffi.UCHARP, call_capi(space, 'call_b', args))[0] +return rffi.cast(rffi.UCHAR, space.c_int_w(call_capi(space, 'call_b', args))) def c_call_c(space, cppmethod, cppobject, nargs, cargs): args = [_Arg(l=cppmethod),
[pypy-commit] pypy reflex-support: coding convention fix
Author: Wim Lavrijsen wlavrij...@lbl.gov Branch: reflex-support Changeset: r63073:b440e97a9581 Date: 2013-04-05 15:39 -0700 http://bitbucket.org/pypy/pypy/changeset/b440e97a9581/ Log:coding convention fix diff --git a/pypy/module/cppyy/src/reflexcwrapper.cxx b/pypy/module/cppyy/src/reflexcwrapper.cxx --- a/pypy/module/cppyy/src/reflexcwrapper.cxx +++ b/pypy/module/cppyy/src/reflexcwrapper.cxx @@ -620,7 +620,7 @@ } void cppyy_assign2stdstring(cppyy_object_t ptr, const char* str) { - *((std::string*)ptr) = str; +*((std::string*)ptr) = str; } void cppyy_free_stdstring(cppyy_object_t ptr) { ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy reflex-support: merge default into branch
Author: Wim Lavrijsen wlavrij...@lbl.gov Branch: reflex-support Changeset: r63072:607168b3bbc0 Date: 2013-04-05 15:18 -0700 http://bitbucket.org/pypy/pypy/changeset/607168b3bbc0/ Log:merge default into branch diff --git a/lib_pypy/_sqlite3.py b/lib_pypy/_sqlite3.py --- a/lib_pypy/_sqlite3.py +++ b/lib_pypy/_sqlite3.py @@ -48,13 +48,7 @@ from cffi import FFI as _FFI -if '__pypy__' not in sys.builtin_module_names: -from cffi.backend_ctypes import CTypesBackend -backend = CTypesBackend() -else: -backend = None - -_ffi = _FFI(backend=backend) +_ffi = _FFI() _ffi.cdef( #define SQLITE_OK ... @@ -224,7 +218,7 @@ const char **pzTail /* OUT: Pointer to unused portion of zSql */ ); -void sqlite3_result_blob(sqlite3_context*, const void*, int, void(*)(void*)); +void sqlite3_result_blob(sqlite3_context*, const char*, 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); @@ -257,7 +251,7 @@ def _has_load_extension(): Only available since 3.3.6 -unverified_ffi = _FFI(backend=backend) +unverified_ffi = _FFI() unverified_ffi.cdef( typedef ... sqlite3; int sqlite3_enable_load_extension(sqlite3 *db, int onoff); @@ -858,7 +852,7 @@ self._reset = False self.__locked = False self.__closed = False -self.__description = None +self.__lastrowid = None self.__rowcount = -1 con._check_thread() @@ -964,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) @@ -978,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) @@ -1002,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()
[pypy-commit] pypy reflex-support: fix check: cif_descr is initialized to null ptr, not to None
Author: Wim Lavrijsen wlavrij...@lbl.gov Branch: reflex-support Changeset: r63075:4ae8555bbb2c Date: 2013-04-05 16:28 -0700 http://bitbucket.org/pypy/pypy/changeset/4ae8555bbb2c/ Log:fix check: cif_descr is initialized to null ptr, not to None diff --git a/pypy/module/cppyy/interp_cppyy.py b/pypy/module/cppyy/interp_cppyy.py --- a/pypy/module/cppyy/interp_cppyy.py +++ b/pypy/module/cppyy/interp_cppyy.py @@ -204,7 +204,7 @@ @jit.unroll_safe def do_fast_call(self, cppthis, args_w, call_local): -if self.cif_descr is None: +if self.cif_descr == lltype.nullptr(jit_libffi.CIF_DESCRIPTION): raise FastCallNotPossible cif_descr = self.cif_descr buffer = lltype.malloc(rffi.CCHARP.TO, cif_descr.exchange_size, flavor='raw') ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy reflex-support: stubs use placement new
Author: Wim Lavrijsen wlavrij...@lbl.gov Branch: reflex-support Changeset: r63074:7159a9b97251 Date: 2013-04-05 16:18 -0700 http://bitbucket.org/pypy/pypy/changeset/7159a9b97251/ Log:stubs use placement new diff --git a/pypy/module/cppyy/src/reflexcwrapper.cxx b/pypy/module/cppyy/src/reflexcwrapper.cxx --- a/pypy/module/cppyy/src/reflexcwrapper.cxx +++ b/pypy/module/cppyy/src/reflexcwrapper.cxx @@ -170,11 +170,13 @@ } char* cppyy_call_s(cppyy_method_t method, cppyy_object_t self, int nargs, void* args) { -std::string result(); +std::string* cppresult = (std::string*)malloc(sizeof(std::string)); std::vectorvoid* arguments = build_args(nargs, args); Reflex::StubFunction stub = (Reflex::StubFunction)method; -stub(result, (void*)self, arguments, NULL /* stub context */); -return cppstring_to_cstring(result); +stub(cppresult, (void*)self, arguments, NULL /* stub context */); +char* cstr = cppstring_to_cstring(*cppresult); +delete cppresult; // the stub will have performed a placement-new +return cstr; } cppyy_object_t cppyy_constructor(cppyy_method_t method, cppyy_type_t handle, int nargs, void* args) { ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy default: fix whatsnew
Author: Brian Kearns bdkea...@gmail.com Branch: Changeset: r63076:d34ad891ac19 Date: 2013-04-05 20:22 -0400 http://bitbucket.org/pypy/pypy/changeset/d34ad891ac19/ Log:fix whatsnew 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 ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy py3k: this is text
Author: Philip Jenvey pjen...@underboss.org Branch: py3k Changeset: r63077:5b7c09b8a1af Date: 2013-04-05 17:24 -0700 http://bitbucket.org/pypy/pypy/changeset/5b7c09b8a1af/ Log:this is text 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,10 @@ 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 or ffi.string(key_n) == bUNKNOWN KEY: continue -key_n = ffi.string(key_n).replace('(', '').replace(')', '') +key_n = ffi.string(key_n).decode() +key_n = key_n.replace('(', '').replace(')', '') globals()[key_n] = key _setup() ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy py3k: int is W_LongObject
Author: Philip Jenvey pjen...@underboss.org Branch: py3k Changeset: r63078:727a7454acb0 Date: 2013-04-05 17:25 -0700 http://bitbucket.org/pypy/pypy/changeset/727a7454acb0/ Log:int is W_LongObject diff --git a/pypy/objspace/std/test/test_stdobjspace.py b/pypy/objspace/std/test/test_stdobjspace.py --- a/pypy/objspace/std/test/test_stdobjspace.py +++ b/pypy/objspace/std/test/test_stdobjspace.py @@ -51,13 +51,13 @@ def test_fastpath_isinstance(self): from pypy.objspace.std.stringobject import W_StringObject -from pypy.objspace.std.intobject import W_AbstractIntObject +from pypy.objspace.std.longobject import W_LongObject from pypy.objspace.std.iterobject import W_AbstractSeqIterObject from pypy.objspace.std.iterobject import W_SeqIterObject space = self.space assert space._get_interplevel_cls(space.w_str) is W_StringObject -assert space._get_interplevel_cls(space.w_int) is W_AbstractIntObject +assert space._get_interplevel_cls(space.w_int) is W_LongObject class X(W_StringObject): def __init__(self): pass ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy py3k: match cpython's stricter handling of extended unpacking
Author: Philip Jenvey pjen...@underboss.org Branch: py3k Changeset: r63079:6cded36a0209 Date: 2013-04-05 17:25 -0700 http://bitbucket.org/pypy/pypy/changeset/6cded36a0209/ Log:match cpython's stricter handling of extended unpacking diff --git a/pypy/interpreter/astcompiler/codegen.py b/pypy/interpreter/astcompiler/codegen.py --- a/pypy/interpreter/astcompiler/codegen.py +++ b/pypy/interpreter/astcompiler/codegen.py @@ -6,6 +6,7 @@ # help the annotator. To it, unfortunately, everything is not so obvious. If # you figure out a way to remove them, great, but try a translation first, # please. +import struct from pypy.interpreter.astcompiler import ast, assemble, symtable, consts, misc from pypy.interpreter.astcompiler import optimize # For side effects @@ -13,6 +14,7 @@ from pypy.tool import stdlib_opcode as ops from pypy.interpreter.error import OperationError +C_INT_MAX = (2 ** (struct.calcsize('i') * 8)) / 2 - 1 def compile_ast(space, module, info): Generate a code object from AST. @@ -771,6 +773,9 @@ return False for target in targets: if not isinstance(target, ast.Name): +if isinstance(target, ast.Starred): +# these require extra checks +return False break else: self.visit_sequence(values) @@ -935,28 +940,24 @@ def _visit_list_or_tuple(self, node, elts, ctx, op): elt_count = len(elts) if elts else 0 -star_pos = -1 if ctx == ast.Store: -if elt_count 0: -for i, elt in enumerate(elts): -if isinstance(elt, ast.Starred): -if star_pos != -1: -msg = too many starred expressions in assignment -self.error(msg, node) -star_pos = i -if star_pos != -1: -self.emit_op_arg(ops.UNPACK_EX, star_pos | (elt_count-star_pos-1)8) -else: +seen_star = False +for i in range(elt_count): +elt = elts[i] +is_starred = isinstance(elt, ast.Starred) +if is_starred and not seen_star: +if i = 1 8 or elt_count - i - 1 = (C_INT_MAX 8): +self.error(too many expressions in star-unpacking + assignment, node) +self.emit_op_arg(ops.UNPACK_EX, + i + ((elt_count - i - 1) 8)) +seen_star = True +elts[i] = elt.value +elif is_starred: +self.error(two starred expressions in assignment, node) +if not seen_star: self.emit_op_arg(ops.UNPACK_SEQUENCE, elt_count) -if elt_count 0: -if star_pos != -1: -for elt in elts: -if isinstance(elt, ast.Starred): -elt.value.walkabout(self) -else: -elt.walkabout(self) -else: -self.visit_sequence(elts) +self.visit_sequence(elts) if ctx == ast.Load: self.emit_op_arg(op, elt_count) diff --git a/pypy/interpreter/astcompiler/test/test_compiler.py b/pypy/interpreter/astcompiler/test/test_compiler.py --- a/pypy/interpreter/astcompiler/test/test_compiler.py +++ b/pypy/interpreter/astcompiler/test/test_compiler.py @@ -884,12 +884,30 @@ return a, b, c yield self.st, func, f(), (1, [2, 3], 4) -py.test.raises(SyntaxError, self.simple_test, *a, *b = [1, 2], - None, None) -py.test.raises(SyntaxError, self.simple_test, a = [*b, c], - None, None) -py.test.raises(SyntaxError, self.simple_test, for *a in x: pass, - None, None) + +def test_extended_unpacking_fail(self): +exc = py.test.raises(SyntaxError, self.simple_test, *a, *b = [1, 2], + None, None).value +assert exc.msg == two starred expressions in assignment +exc = py.test.raises(SyntaxError, self.simple_test, + [*b, *c] = range(10), None, None).value +assert exc.msg == two starred expressions in assignment + +exc = py.test.raises(SyntaxError, self.simple_test, a = [*b, c], + None, None).value +assert exc.msg == can use starred expression only as assignment target +exc = py.test.raises(SyntaxError, self.simple_test, for *a in x: pass, + None, None).value +assert exc.msg == starred assignment target must be in a list or tuple + +s = , .join(a%d % i for i in range(18)) + , *rest = range(18 + 1) +exc = py.test.raises(SyntaxError, self.simple_test, s, None, +
[pypy-commit] pypy py3k: correct UNPACK_EX's counting
Author: Philip Jenvey pjen...@underboss.org Branch: py3k Changeset: r63080:db0c22afb498 Date: 2013-04-05 17:25 -0700 http://bitbucket.org/pypy/pypy/changeset/db0c22afb498/ Log:correct UNPACK_EX's counting diff --git a/pypy/interpreter/pyopcode.py b/pypy/interpreter/pyopcode.py --- a/pypy/interpreter/pyopcode.py +++ b/pypy/interpreter/pyopcode.py @@ -604,15 +604,15 @@ w_iterable = self.popvalue() items = self.space.fixedview(w_iterable) itemcount = len(items) -if right itemcount: -count = left + right +count = left + right +if count itemcount: if count == 1: plural = '' else: plural = 's' raise operationerrfmt(self.space.w_ValueError, need more than %d value%s to unpack, - left + right, plural) + itemcount, plural) right = itemcount - right assert right = 0 # push values in reverse order diff --git a/pypy/interpreter/test/test_interpreter.py b/pypy/interpreter/test/test_interpreter.py --- a/pypy/interpreter/test/test_interpreter.py +++ b/pypy/interpreter/test/test_interpreter.py @@ -346,3 +346,17 @@ assert l(1, 2) == 1 + 2 + 20 assert l(1, 2, k=10) == 1 + 2 + 10 + +def test_extended_unpacking_short(self): + +class Seq: +def __getitem__(self, i): +if i = 0 and i 3: return i +raise IndexError +try: +a, *b, c, d, e = Seq() +except ValueError as e: +assert str(e) == need more than 3 values to unpack +else: +assert False, Expected ValueError + ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy py3k: ints are always PyLongs
Author: Philip Jenvey pjen...@underboss.org Branch: py3k Changeset: r63081:7ecf4bccf4c9 Date: 2013-04-05 17:26 -0700 http://bitbucket.org/pypy/pypy/changeset/7ecf4bccf4c9/ Log:ints are always PyLongs diff --git a/pypy/module/cpyext/test/test_longobject.py b/pypy/module/cpyext/test/test_longobject.py --- a/pypy/module/cpyext/test/test_longobject.py +++ b/pypy/module/cpyext/test/test_longobject.py @@ -50,11 +50,11 @@ assert api.PyLong_CheckExact(w_l) w_i = space.wrap(sys.maxint) -assert not api.PyLong_Check(w_i) -assert not api.PyLong_CheckExact(w_i) +assert api.PyLong_Check(w_i) +assert api.PyLong_CheckExact(w_i) L = space.appexec([], (): -class L(long): +class L(int): pass return L ) ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy default: not sure why this was changed in a163d0d435d5
Author: Brian Kearns bdkea...@gmail.com Branch: Changeset: r63082:d801b8e5feac Date: 2013-04-05 20:30 -0400 http://bitbucket.org/pypy/pypy/changeset/d801b8e5feac/ Log:not sure why this was changed in a163d0d435d5 diff --git a/lib_pypy/_sqlite3.py b/lib_pypy/_sqlite3.py --- a/lib_pypy/_sqlite3.py +++ b/lib_pypy/_sqlite3.py @@ -218,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); ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy default: transplant 5b7c09b8a1af and improve to only call ffi.string once
Author: Brian Kearns bdkea...@gmail.com Branch: Changeset: r63083:3e8013bc9ef3 Date: 2013-04-05 20:43 -0400 http://bitbucket.org/pypy/pypy/changeset/3e8013bc9ef3/ Log:transplant 5b7c09b8a1af and improve to only call ffi.string once 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 == bUNKNOWN KEY: +continue +key_n = key_n.decode().replace('(', '').replace(')', '') globals()[key_n] = key _setup() ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy default: pep8/whitespace
Author: Brian Kearns bdkea...@gmail.com Branch: Changeset: r63084:49a3f33a88d1 Date: 2013-04-05 20:57 -0400 http://bitbucket.org/pypy/pypy/changeset/49a3f33a88d1/ Log:pep8/whitespace 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(1) -pystonetime = t/stone -seconds = megapystone * 100 * pystonetime -return seconds -return float(timeout) +pystonetime = t/stone +seconds = megapystone * 100 * 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() -
[pypy-commit] pypy default: fix this test after c2e8c09de077
Author: Brian Kearns bdkea...@gmail.com Branch: Changeset: r63085:80ab72ab0def Date: 2013-04-05 21:29 -0400 http://bitbucket.org/pypy/pypy/changeset/80ab72ab0def/ Log:fix this test after c2e8c09de077 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 ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy default: fix test_package when faking pypy_c
Author: Brian Kearns bdkea...@gmail.com Branch: Changeset: r63086:086df98954ff Date: 2013-04-05 23:26 -0400 http://bitbucket.org/pypy/pypy/changeset/086df98954ff/ Log:fix test_package when faking 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: ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy default: cleanups in lib_pypy
Author: Brian Kearns bdkea...@gmail.com Branch: Changeset: r63087:f0e3b9fc043a Date: 2013-04-06 00:01 -0400 http://bitbucket.org/pypy/pypy/changeset/f0e3b9fc043a/ Log:cleanups in lib_pypy 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/_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]) 0x ) - + 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]) 0x t1 = (Sigma0(a) + Maj(a, b, c)) 0x d = (d + t0) 0x h = (t0 + t1) 0x return d 0x, h 0x - + 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]) 0x ) @@ -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([ ((i56) 0xff), ((i48) 0xff), ((i40) 0xff), ((i32) 0xff), ((i24) 0xff), ((i16) 0xff), ((i8) 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']] -
[pypy-commit] pypy default: remove conditional skip, this was a ctypes limitation
Author: Brian Kearns bdkea...@gmail.com Branch: Changeset: r63089:53926a2ab1b9 Date: 2013-04-06 00:28 -0400 http://bitbucket.org/pypy/pypy/changeset/53926a2ab1b9/ Log:remove conditional skip, this was a ctypes limitation 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,9 +1,5 @@ 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 ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy default: simplify sqlite tests by providing a funcarg that automatically connects/closes
Author: Brian Kearns bdkea...@gmail.com Branch: Changeset: r63090:3b60aa181915 Date: 2013-04-06 00:45 -0400 http://bitbucket.org/pypy/pypy/changeset/3b60aa181915/ Log:simplify sqlite tests by providing a funcarg that automatically connects/closes 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 @@ -3,10 +3,14 @@ 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 == [] @@ -17,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) @@ -31,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) @@ -81,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() @@ -127,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: @@ -143,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.' @@ -160,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,)) @@ -179,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') @@ -190,31 +183,26 @@ 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') -def test_description_after_fetchall(): -con =
[pypy-commit] pypy default: no ncurses on windowss
Author: mattip Branch: Changeset: r63091:79414fd8306a Date: 2013-04-06 07:41 +0200 http://bitbucket.org/pypy/pypy/changeset/79414fd8306a/ Log:no ncurses on windowss 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)] ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit