From arigo at codespeak.net Thu Jan 1 18:02:54 2009 From: arigo at codespeak.net (arigo at codespeak.net) Date: Thu, 1 Jan 2009 18:02:54 +0100 (CET) Subject: [pypy-svn] r60750 - in pypy/branch/oo-jit/pypy: jit/codegen/i386 jit/tl rpython/lltypesystem Message-ID: <20090101170254.3A8021683CD@codespeak.net> Author: arigo Date: Thu Jan 1 18:02:51 2009 New Revision: 60750 Modified: pypy/branch/oo-jit/pypy/jit/codegen/i386/ri386.py pypy/branch/oo-jit/pypy/jit/tl/tlc.py pypy/branch/oo-jit/pypy/rpython/lltypesystem/lltype.py Log: * simplify the code in tlc for green values. * add 'heap8' to ri386 -- sorry, forgot about it previously. * implement _cast_to_int() on lltype pointers to do the real thing instead of returning a randomish number. Modified: pypy/branch/oo-jit/pypy/jit/codegen/i386/ri386.py ============================================================================== --- pypy/branch/oo-jit/pypy/jit/codegen/i386/ri386.py (original) +++ pypy/branch/oo-jit/pypy/jit/codegen/i386/ri386.py Thu Jan 1 18:02:51 2009 @@ -259,6 +259,9 @@ def heap(offset): return memSIB(None, None, 0, offset) +def heap8(offset): + return memSIB8(None, None, 0, offset) + def heap64(offset): return memSIB64(None, None, 0, offset) Modified: pypy/branch/oo-jit/pypy/jit/tl/tlc.py ============================================================================== --- pypy/branch/oo-jit/pypy/jit/tl/tlc.py (original) +++ pypy/branch/oo-jit/pypy/jit/tl/tlc.py Thu Jan 1 18:02:51 2009 @@ -461,8 +461,10 @@ num_args += 1 # include self name = pool.strings[idx] meth_args = [None] * num_args - for i in range(num_args): - meth_args[-i-1] = stack.pop() + while num_args > 0: + num_args -= 1 + meth_args[num_args] = stack.pop() + hint(num_args, concrete=True) a = meth_args[0] hint(a, promote_class=True) meth_pc = hint(a.send(name), promote=True) Modified: pypy/branch/oo-jit/pypy/rpython/lltypesystem/lltype.py ============================================================================== --- pypy/branch/oo-jit/pypy/rpython/lltypesystem/lltype.py (original) +++ pypy/branch/oo-jit/pypy/rpython/lltypesystem/lltype.py Thu Jan 1 18:02:51 2009 @@ -1171,12 +1171,14 @@ obj = self._obj if isinstance(obj, int): return obj # special case for cast_int_to_ptr() results - obj = normalizeptr(self)._obj - result = intmask(obj._getid()) - # assume that id() returns an addressish value which is - # not zero and aligned to at least a multiple of 4 - assert result != 0 and (result & 3) == 0 - return result + # use ll2ctypes to obtain a real ctypes-based representation of + # the memory, and cast that address as an integer + import ctypes + from pypy.rpython.lltypesystem import ll2ctypes + c = ll2ctypes.lltype2ctypes(self) + c = ctypes.cast(c, ctypes.c_void_p) + assert c.value + return c.value def _cast_to_adr(self): from pypy.rpython.lltypesystem import llmemory From arigo at codespeak.net Thu Jan 1 18:31:59 2009 From: arigo at codespeak.net (arigo at codespeak.net) Date: Thu, 1 Jan 2009 18:31:59 +0100 (CET) Subject: [pypy-svn] r60752 - in pypy/branch/oo-jit/pypy/rpython: . lltypesystem Message-ID: <20090101173159.845ED1683DF@codespeak.net> Author: arigo Date: Thu Jan 1 18:31:59 2009 New Revision: 60752 Modified: pypy/branch/oo-jit/pypy/rpython/llinterp.py pypy/branch/oo-jit/pypy/rpython/lltypesystem/opimpl.py Log: Move this to llinterp, to make test_lloperation happy. Modified: pypy/branch/oo-jit/pypy/rpython/llinterp.py ============================================================================== --- pypy/branch/oo-jit/pypy/rpython/llinterp.py (original) +++ pypy/branch/oo-jit/pypy/rpython/llinterp.py Thu Jan 1 18:31:59 2009 @@ -541,6 +541,9 @@ def op_jit_marker(self, *args): pass + def op_promote_virtualizable(self, object, fieldname): + pass + def op_instrument_count(self, ll_tag, ll_label): pass # xxx for now Modified: pypy/branch/oo-jit/pypy/rpython/lltypesystem/opimpl.py ============================================================================== --- pypy/branch/oo-jit/pypy/rpython/lltypesystem/opimpl.py (original) +++ pypy/branch/oo-jit/pypy/rpython/lltypesystem/opimpl.py Thu Jan 1 18:31:59 2009 @@ -514,9 +514,6 @@ assert type(f) is float return ovfcheck(int(f)) -def op_promote_virtualizable(object, fieldname): - pass - # ____________________________________________________________ def get_op_impl(opname): From arigo at codespeak.net Thu Jan 1 18:37:38 2009 From: arigo at codespeak.net (arigo at codespeak.net) Date: Thu, 1 Jan 2009 18:37:38 +0100 (CET) Subject: [pypy-svn] r60753 - pypy/branch/oo-jit/pypy/rpython/lltypesystem Message-ID: <20090101173738.D8E5D1683F8@codespeak.net> Author: arigo Date: Thu Jan 1 18:37:38 2009 New Revision: 60753 Modified: pypy/branch/oo-jit/pypy/rpython/lltypesystem/ll2ctypes.py pypy/branch/oo-jit/pypy/rpython/lltypesystem/lltype.py Log: Revert the change to lltype and implement it as ll2ctypes.cast_adr_to_int(). Modified: pypy/branch/oo-jit/pypy/rpython/lltypesystem/ll2ctypes.py ============================================================================== --- pypy/branch/oo-jit/pypy/rpython/lltypesystem/ll2ctypes.py (original) +++ pypy/branch/oo-jit/pypy/rpython/lltypesystem/ll2ctypes.py Thu Jan 1 18:37:38 2009 @@ -881,6 +881,20 @@ def _cast_to_int(self): return ctypes.cast(self.void_p, ctypes.c_long) +def cast_adr_to_int(addr): + if isinstance(addr, llmemory.fakeaddress): + # use ll2ctypes to obtain a real ctypes-based representation of + # the memory, and cast that address as an integer + if addr.ptr is None: + return 0 + else: + c = lltype2ctypes(addr.ptr) + c = ctypes.cast(c, ctypes.c_void_p) + assert c.value + return c.value + else: + return addr._cast_to_int() + # ____________________________________________________________ # errno Modified: pypy/branch/oo-jit/pypy/rpython/lltypesystem/lltype.py ============================================================================== --- pypy/branch/oo-jit/pypy/rpython/lltypesystem/lltype.py (original) +++ pypy/branch/oo-jit/pypy/rpython/lltypesystem/lltype.py Thu Jan 1 18:37:38 2009 @@ -1171,14 +1171,12 @@ obj = self._obj if isinstance(obj, int): return obj # special case for cast_int_to_ptr() results - # use ll2ctypes to obtain a real ctypes-based representation of - # the memory, and cast that address as an integer - import ctypes - from pypy.rpython.lltypesystem import ll2ctypes - c = ll2ctypes.lltype2ctypes(self) - c = ctypes.cast(c, ctypes.c_void_p) - assert c.value - return c.value + obj = normalizeptr(self)._obj + result = intmask(obj._getid()) + # assume that id() returns an addressish value which is + # not zero and aligned to at least a multiple of 4 + assert result != 0 and (result & 3) == 0 + return result def _cast_to_adr(self): from pypy.rpython.lltypesystem import llmemory From pypy-svn at codespeak.net Thu Jan 1 19:54:34 2009 From: pypy-svn at codespeak.net (pypy-svn at codespeak.net) Date: Thu, 1 Jan 2009 19:54:34 +0100 (CET) Subject: [pypy-svn] your stock redemption Message-ID: <20090101185434.432D3168437@codespeak.net> An HTML attachment was scrubbed... URL: From pedronis at codespeak.net Thu Jan 1 21:31:13 2009 From: pedronis at codespeak.net (pedronis at codespeak.net) Date: Thu, 1 Jan 2009 21:31:13 +0100 (CET) Subject: [pypy-svn] r60757 - pypy/build/bot2 Message-ID: <20090101203113.A6282168402@codespeak.net> Author: pedronis Date: Thu Jan 1 21:31:12 2009 New Revision: 60757 Modified: pypy/build/bot2/TODO Log: that bit is kind of good enough now Modified: pypy/build/bot2/TODO ============================================================================== --- pypy/build/bot2/TODO (original) +++ pypy/build/bot2/TODO Thu Jan 1 21:31:12 2009 @@ -1,9 +1,6 @@ - buildbot Nightly scheduler that can pick a uniform revision server side and with support for specifying possibly branches -- improve summary page (defined in pypybuildbot/summary.page), support querying/slicing - by builders, formatting and css - - some kind of progress information for a run - support for better information in case of runner-level killed hanging tests From pypy-svn at codespeak.net Fri Jan 2 00:39:56 2009 From: pypy-svn at codespeak.net (pypy-svn at codespeak.net) Date: Fri, 2 Jan 2009 00:39:56 +0100 (CET) Subject: [pypy-svn] Make her beg for more Message-ID: <20090101233956.9F3E5168402@codespeak.net> An HTML attachment was scrubbed... URL: From arigo at codespeak.net Fri Jan 2 17:09:40 2009 From: arigo at codespeak.net (arigo at codespeak.net) Date: Fri, 2 Jan 2009 17:09:40 +0100 (CET) Subject: [pypy-svn] r60759 - pypy/trunk/lib-python/modified-2.5.2/ctypes Message-ID: <20090102160940.7CF0916845C@codespeak.net> Author: arigo Date: Fri Jan 2 17:09:37 2009 New Revision: 60759 Modified: pypy/trunk/lib-python/modified-2.5.2/ctypes/__init__.py Log: Make general code instead of PyPy-specific only. Modified: pypy/trunk/lib-python/modified-2.5.2/ctypes/__init__.py ============================================================================== --- pypy/trunk/lib-python/modified-2.5.2/ctypes/__init__.py (original) +++ pypy/trunk/lib-python/modified-2.5.2/ctypes/__init__.py Fri Jan 2 17:09:37 2009 @@ -433,7 +433,15 @@ cdll = LibraryLoader(CDLL) pydll = LibraryLoader(PyDLL) -pythonapi = None +if _sys.subversion[0] == 'CPython': + if _os.name in ("nt", "ce"): + pythonapi = PyDLL("python dll", None, _sys.dllhandle) + elif _sys.platform == "cygwin": + pythonapi = PyDLL("libpython%d.%d.dll" % _sys.version_info[:2]) + else: + pythonapi = PyDLL(None) +else: + pythonapi = None if _os.name in ("nt", "ce"): From pypy-svn at codespeak.net Sat Jan 3 06:24:08 2009 From: pypy-svn at codespeak.net (pypy-svn at codespeak.net) Date: Sat, 3 Jan 2009 06:24:08 +0100 (CET) Subject: [pypy-svn] Nothing will ever top this Message-ID: <20090103052408.E72421683BF@codespeak.net> An HTML attachment was scrubbed... URL: From fijal at codespeak.net Sun Jan 4 19:48:19 2009 From: fijal at codespeak.net (fijal at codespeak.net) Date: Sun, 4 Jan 2009 19:48:19 +0100 (CET) Subject: [pypy-svn] r60772 - in pypy/branch/oo-jit/pypy/rpython/lltypesystem: . test Message-ID: <20090104184819.DE55C1684A6@codespeak.net> Author: fijal Date: Sun Jan 4 19:48:17 2009 New Revision: 60772 Modified: pypy/branch/oo-jit/pypy/rpython/lltypesystem/ll2ctypes.py pypy/branch/oo-jit/pypy/rpython/lltypesystem/test/test_ll2ctypes.py Log: A test and a fix for negative addresses Modified: pypy/branch/oo-jit/pypy/rpython/lltypesystem/ll2ctypes.py ============================================================================== --- pypy/branch/oo-jit/pypy/rpython/lltypesystem/ll2ctypes.py (original) +++ pypy/branch/oo-jit/pypy/rpython/lltypesystem/ll2ctypes.py Sun Jan 4 19:48:17 2009 @@ -886,14 +886,19 @@ # use ll2ctypes to obtain a real ctypes-based representation of # the memory, and cast that address as an integer if addr.ptr is None: - return 0 + res = 0 else: c = lltype2ctypes(addr.ptr) c = ctypes.cast(c, ctypes.c_void_p) assert c.value - return c.value + res = c.value else: - return addr._cast_to_int() + res = addr._cast_to_int() + if res > sys.maxint: + res = res - 2*sys.maxint + assert int(res) == res + return int(res) + return res # ____________________________________________________________ # errno Modified: pypy/branch/oo-jit/pypy/rpython/lltypesystem/test/test_ll2ctypes.py ============================================================================== --- pypy/branch/oo-jit/pypy/rpython/lltypesystem/test/test_ll2ctypes.py (original) +++ pypy/branch/oo-jit/pypy/rpython/lltypesystem/test/test_ll2ctypes.py Sun Jan 4 19:48:17 2009 @@ -6,7 +6,7 @@ from pypy.rpython.lltypesystem.ll2ctypes import lltype2ctypes, ctypes2lltype from pypy.rpython.lltypesystem.ll2ctypes import standard_c_lib, get_ctypes_type from pypy.rpython.lltypesystem.ll2ctypes import uninitialized2ctypes -from pypy.rpython.lltypesystem.ll2ctypes import ALLOCATED +from pypy.rpython.lltypesystem.ll2ctypes import ALLOCATED, cast_adr_to_int from pypy.rpython.annlowlevel import llhelper from pypy.rlib import rposix from pypy.translator.tool.cbuild import ExternalCompilationInfo @@ -914,3 +914,12 @@ pc2 = lltype2ctypes(p) assert pc2.contents.value == 42 assert pc2.contents.next.contents.value == 42 + + def test_cast_adr_to_int(self): + class someaddr(object): + def _cast_to_int(self): + return sys.maxint/2 * 3 + + res = cast_adr_to_int(someaddr()) + assert isinstance(res, int) + assert res == -sys.maxint/2 - 1 From fijal at codespeak.net Mon Jan 5 10:06:16 2009 From: fijal at codespeak.net (fijal at codespeak.net) Date: Mon, 5 Jan 2009 10:06:16 +0100 (CET) Subject: [pypy-svn] r60783 - pypy/trunk/pypy/translator/js/test Message-ID: <20090105090616.D9EE616851A@codespeak.net> Author: fijal Date: Mon Jan 5 10:06:15 2009 New Revision: 60783 Modified: pypy/trunk/pypy/translator/js/test/runtest.py pypy/trunk/pypy/translator/js/test/test_rdict.py pypy/trunk/pypy/translator/js/test/test_rlist.py Log: skip/fix some tests Modified: pypy/trunk/pypy/translator/js/test/runtest.py ============================================================================== --- pypy/trunk/pypy/translator/js/test/runtest.py (original) +++ pypy/trunk/pypy/translator/js/test/runtest.py Mon Jan 5 10:06:15 2009 @@ -190,6 +190,8 @@ # assert False, 'function did raise no exception at all' def ll_to_string(self, s): + if str(s) == 'None': + return None return str(s) def ll_to_list(self, l): Modified: pypy/trunk/pypy/translator/js/test/test_rdict.py ============================================================================== --- pypy/trunk/pypy/translator/js/test/test_rdict.py (original) +++ pypy/trunk/pypy/translator/js/test/test_rdict.py Mon Jan 5 10:06:15 2009 @@ -43,3 +43,5 @@ def test_specific_obscure_bug(self): py.test.skip("rdict not implemented") + def test_r_dict(self): + py.test.skip("rdict not implemented") Modified: pypy/trunk/pypy/translator/js/test/test_rlist.py ============================================================================== --- pypy/trunk/pypy/translator/js/test/test_rlist.py (original) +++ pypy/trunk/pypy/translator/js/test/test_rlist.py Mon Jan 5 10:06:15 2009 @@ -83,3 +83,10 @@ res = self.ll_to_string(self.interpret(fn, [])) res = res.replace('pypy.translator.js.test.test_rlist.', '') assert res == ';[, , , , ]' + + def test_delslice(self): + py.test.skip("buggy") + + def test_getslice_not_constant_folded(self): + py.test.skip("buggy") + From fijal at codespeak.net Mon Jan 5 16:02:44 2009 From: fijal at codespeak.net (fijal at codespeak.net) Date: Mon, 5 Jan 2009 16:02:44 +0100 (CET) Subject: [pypy-svn] r60792 - pypy/branch/oo-jit/pypy/rpython/lltypesystem Message-ID: <20090105150244.C3341168532@codespeak.net> Author: fijal Date: Mon Jan 5 16:02:42 2009 New Revision: 60792 Modified: pypy/branch/oo-jit/pypy/rpython/lltypesystem/ll2ctypes.py Log: stupid fix for stupid ctypes behavior Modified: pypy/branch/oo-jit/pypy/rpython/lltypesystem/ll2ctypes.py ============================================================================== --- pypy/branch/oo-jit/pypy/rpython/lltypesystem/ll2ctypes.py (original) +++ pypy/branch/oo-jit/pypy/rpython/lltypesystem/ll2ctypes.py Mon Jan 5 16:02:42 2009 @@ -506,6 +506,8 @@ if isinstance(T.TO.RESULT, lltype.Ptr): _all_callbacks.append(res) res = ctypes.cast(res, ctypes.c_void_p).value + if res is None: + return 0 return res if conftest.option.usepdb: From fijal at codespeak.net Mon Jan 5 21:16:17 2009 From: fijal at codespeak.net (fijal at codespeak.net) Date: Mon, 5 Jan 2009 21:16:17 +0100 (CET) Subject: [pypy-svn] r60805 - pypy/branch/oo-jit/pypy/rpython/lltypesystem Message-ID: <20090105201617.715D216852A@codespeak.net> Author: fijal Date: Mon Jan 5 21:16:14 2009 New Revision: 60805 Modified: pypy/branch/oo-jit/pypy/rpython/lltypesystem/ll2ctypes.py Log: ext registry entry for ll2ctypes.cast_adr_to_int Modified: pypy/branch/oo-jit/pypy/rpython/lltypesystem/ll2ctypes.py ============================================================================== --- pypy/branch/oo-jit/pypy/rpython/lltypesystem/ll2ctypes.py (original) +++ pypy/branch/oo-jit/pypy/rpython/lltypesystem/ll2ctypes.py Mon Jan 5 21:16:14 2009 @@ -902,6 +902,20 @@ return int(res) return res +class CastAdrToIntEntry(ExtRegistryEntry): + _about_ = cast_adr_to_int + + def compute_result_annotation(self, s_addr): + return annmodel.SomeInteger() + + def specialize_call(self, hop): + assert isinstance(hop.args_r[0], raddress.AddressRepr) + adr, = hop.inputargs(hop.args_r[0]) + hop.exception_cannot_occur() + return hop.genop('cast_adr_to_int', [adr], + resulttype = lltype.Signed) + + # ____________________________________________________________ # errno From fijal at codespeak.net Mon Jan 5 21:44:45 2009 From: fijal at codespeak.net (fijal at codespeak.net) Date: Mon, 5 Jan 2009 21:44:45 +0100 (CET) Subject: [pypy-svn] r60806 - in pypy/extradoc/talk/sfi2008: . demo Message-ID: <20090105204445.3B8A4168516@codespeak.net> Author: fijal Date: Mon Jan 5 21:44:44 2009 New Revision: 60806 Added: pypy/extradoc/talk/sfi2008/talk.html Modified: pypy/extradoc/talk/sfi2008/demo/rainbow-view-jit-graphs pypy/extradoc/talk/sfi2008/demo/targetrpn.py pypy/extradoc/talk/sfi2008/talk.txt Log: last version including html Modified: pypy/extradoc/talk/sfi2008/demo/rainbow-view-jit-graphs ============================================================================== --- pypy/extradoc/talk/sfi2008/demo/rainbow-view-jit-graphs (original) +++ pypy/extradoc/talk/sfi2008/demo/rainbow-view-jit-graphs Mon Jan 5 21:44:44 2009 @@ -1,5 +1,8 @@ #! /usr/bin/env python +import sys +sys.path.insert(0, '/home/fijal/lang/python/pypy-rainbow') + import rpn from pypy.conftest import option option.view = True @@ -20,4 +23,4 @@ return rpn.interpret(code, arg) self.timeshift_from_portal(main, rpn.interpret, - [1, 100], policy=P_OOPSPEC) + [2, 100], policy=P_OOPSPEC) Modified: pypy/extradoc/talk/sfi2008/demo/targetrpn.py ============================================================================== --- pypy/extradoc/talk/sfi2008/demo/targetrpn.py (original) +++ pypy/extradoc/talk/sfi2008/demo/targetrpn.py Mon Jan 5 21:44:44 2009 @@ -12,3 +12,4 @@ def target(*args): return entry_point, None + Added: pypy/extradoc/talk/sfi2008/talk.html ============================================================================== --- (empty file) +++ pypy/extradoc/talk/sfi2008/talk.html Mon Jan 5 21:44:44 2009 @@ -0,0 +1,660 @@ + + + + + + + +PyPy + + + + + + + + + + + + + + + + +
+
+
+ + +
+
+
+

PyPy

+ +++ + + + + + + + +
Author:Maciej Fijalkowski, merlinux GmbH
Title:PyPy - Automatic Generation of VMs for Dynamic Languages
Date:6th March 2008
+ +
+
+

VMs for dynamic languages

+
    +
  • Example - Python
  • +
  • Coded in a low-level language, such as C (or Java or C#)
  • +
  • Hard-coded design decisions (garbage collection, threading model)
  • +
  • Primary example - CPython.
      +
    • refcounting fixed hard to change
    • +
    • global interpreter lock hard to change
    • +
    +
  • +
+
+
+

Ideally, we would...

+
    +
  • Use a high-level language
  • +
  • Use a statically analyzable implementation language
  • +
  • Have a flexible compiler toolchain to do part of the job for you
  • +
+
+
+

Generating VMs

+
    +
  • Writing by hand is a lot of trouble
  • +
  • We want to perform each of the following once:
      +
    • encode the language semantics
    • +
    • encode language-agnostic design decisions (ie object model)
    • +
    • encode platform details
    • +
    +
  • +
+
+
+

PyPy Motivation

+
    +
  • Create highly-flexible compiler toolchain
  • +
  • Use high-level language for encoding semantics
  • +
  • Use compiler toolchain to try hard to make +things such as object model orthogonal to language semantics +encoding
  • +
+
+
+

Development technology

+
    +
  • We use test driven development extensively
  • +
  • We've got a test suite which would need ~8 hours to run on a single processor
  • +
  • Our special testing tool, py.test, little hassle and a lot of features
  • +
  • Sprint-driven development
  • +
+
+
+

General idea

+
+
+

Even more

+
    +
  • Take any interpreter, python, javascript, smalltalk...
  • +
  • Make some decisions (which gc to use...)
  • +
  • Compile it to your platform (C/POSIX, .NET, ...)
  • +
+
+
+

An example of benefit

+
    +
  • Python has complicated semantics
  • +
  • Python guarantees that it won't segfault on +a stack exhaustion
  • +
  • CPython includes some stack checks in the source, but they +don't catch every case
  • +
  • We include it automatically so all cases are guaranteed to be covered
  • +
+
+
+

Example of static analysis

+
    +
  • we analyze interpreter source, not user code!
  • +
  • replace all external calls with stubs
  • +
  • sandboxing - a very small piece of code to trust
  • +
  • build your own library (in python) which implements +your own security policy
  • +
  • no need to worry about third party modules
  • +
+
+
+

RPython

+
    +
  • We use RPython, a proper subset of Python to implement +a Python interpreter
  • +
  • More static than Python
  • +
  • Designed for speed, and designed for writing interpreters
  • +
  • Still high-level, fully analyzable
  • +
  • User code (executed by the interpreter) is full python (not restricted)
  • +
+
+
+

Abstract interpretation

+
    +
  • We start by importing the RPython modules on top of CPython
  • +
  • Next we analyze the bytecode and produce a forest of flow graphs
  • +
  • We call this the abstract interpretation of bytecode
  • +
  • The bytecode can be prepared dynamically (meta-programming)
  • +
+
+
+

Flow graphs

+
    +
  • Intermediate representation
  • +
  • Can encode different layers of abstraction
  • +
+
+
+

Annotation

+
    +
  • The part which does the type inference over existing +graphs
  • +
  • A Powerful but practical type system
  • +
  • Still very high-level
  • +
+
+
+

RTyper

+
    +
  • Translates high-level graphs into lower-levels
  • +
  • Two type systems:
      +
    • lltype, for backends that understand pointers, +structures etc.
    • +
    • ootype, for backends that have notion of objects
    • +
    +
  • +
  • lltype has more low-level details, such as an implementation of strings +(ootype assumes strings built-in)
  • +
+
+
+

Translation aspects

+
    +
  • Optimizations (inlining, malloc removal)
  • +
  • Different GCs
  • +
  • ...
  • +
+
+
+

GC framework

+
    +
  • flexible
  • +
  • implemented as a translation aspect
  • +
  • gc-specific things, such as write barriers, are inserted automatically
  • +
  • different root finding strategies
  • +
  • effective (RPython is faster than C when GC is a bottleneck)
  • +
  • GCs are written in RPython as well
  • +
  • Motivation: MMtk
  • +
+
+
+

Backends

+
    +
  • lltype-based - C, LLVM
  • +
  • ootype-based - CLI, JVM, ...
  • +
  • llinterpreter - a virtual backend for running flow graphs +directly, useful for testing
  • +
  • .NET bindings, for example, are backend specific
  • +
+
+
+

Special translation aspect

+
    +
  • generating Just-in-time compilers from interpreters
  • +
+
+
+

JIT - motivation

+
    +
  • Interpreters are much easier to write than compilers
  • +
  • For many languages, one cannot achieve C-level performance +with static analysis
  • +
  • Dynamic compilation can produce faster results +than static compilation (e.g. a good Java VM versus gcj)
  • +
+
+
+

Traditional JIT approach

+
    +
  • Written by hand
  • +
  • Carefully encoded language semantics
  • +
  • Hard to maintain as language evolves
  • +
  • We can do better!
  • +
+
+
+

PyPy approach to JIT

+
+ +
+
+

JIT - basics

+
    +
  • partial evaluation
  • +
  • automatic generation of a compiler from an interpreter
  • +
  • an old idea with relatively few practical applications so far
  • +
+
+
+

JIT - general idea

+
    +
  • constant-propagate python bytecode through the interpreter
  • +
  • may not yield good performance (our experiments show +about 2x for removing intepretation overhead)
  • +
  • things such as the types of Python objects are still not known
  • +
+
+
+

Solution: promotion

+
    +
  • Enhance partial evaluation to be able to promote run-time +values into compile-time values
  • +
  • Implementation-wise this is a generalization of the polymorphic +in-line caches used in Java VM JITs
  • +
+
+
+

Concrete ingredients

+
    +
  • Variety of hints to guide partial evaluation
  • +
  • Promotion on certain paths to achieve +"static-enough" parts
  • +
  • Lazy allocation of objects (allocation only happens when the object escapes)
  • +
  • Use CPU stack and registers as a cache for Python frame +objects that live in the heap
  • +
+
+
+

Irrelevant to interpreter

+
    +
  • These techniques can be applied relatively easily +to other interpreters, just by adding a few hints
  • +
  • Or to any other program written in RPython +(for instance a templating language where the templates are constant)
  • +
+
+
+

The hint annotator

+
    +
  • This annotator is very similiar to the normal one; it +adds color propagation
  • +
  • Green - compile-time, can be constant-folded
  • +
  • Red - runtime
  • +
  • Some rules about the color propagation
  • +
+
+
+

The rainbow interpreter

+
    +
  • Very very experimental, lives on a branch right now
  • +
  • We dump colored graphs as a bytecode and interpret them
  • +
+
+
+

JIT details - backends

+
    +
  • JIT backends produce assembly code from coloured graphs
  • +
  • As usual, we plan to have many (PPC, i386, JVM, +dummy one...)
  • +
  • They're very rudimentary right now
  • +
  • It's a relatively pleasant job to write Python that generates +assembler code
  • +
  • We would definitely benefit from help from an assembler +expert
  • +
+
+
+

JIT conclusion

+
    +
  • We're able to run carefully crafted examples ~60x faster +than CPython
  • +
  • About the same as gcc -O0
  • +
  • We can definitely do better, for example by enhancing the backends
  • +
  • There is a lot of work to be done in JIT area
  • +
+
+
+

JIT plans

+
    +
  • Faster than C!
  • +
  • For long-enough running programs that's theoretically +possible
  • +
  • We have more information at runtime than one can have +at compile-time
  • +
+
+
+

JIT short term plans

+
    +
  • Compile just hotspots (not everything)
  • +
  • Extend backends and make them smarter
  • +
  • Make generating assembly code faster
  • +
  • Benchmark bottlenecks
  • +
+
+
+

It's not only technical

+
    +
  • EU 6th Framework Programme
  • +
  • Actively searching for both grants and consultancy contracts
  • +
+
+
+

Project future

+
    +
  • More JIT work
  • +
  • Making PyPy's python interpreter run existing +applications
  • +
  • Interfacing with external libraries
  • +
  • We're very friendly for newcomers
  • +
+
+
+ + Modified: pypy/extradoc/talk/sfi2008/talk.txt ============================================================================== --- pypy/extradoc/talk/sfi2008/talk.txt (original) +++ pypy/extradoc/talk/sfi2008/talk.txt Mon Jan 5 21:44:44 2009 @@ -40,7 +40,7 @@ - encode the language semantics - - encode language-agnostic design decisions (ie threading model) + - encode language-agnostic design decisions (ie object model) - encode platform details @@ -102,7 +102,7 @@ * replace all external calls with stubs -* a very small piece of code to trust +* sandboxing - a very small piece of code to trust * build your own library (in python) which implements your own security policy @@ -268,8 +268,6 @@ * Implementation-wise this is a generalization of the polymorphic in-line caches used in Java VM JITs -XXX put slide about virtualizables somewhere - Concrete ingredients ==================== @@ -304,8 +302,6 @@ * Some rules about the color propagation -XXX demo - The rainbow interpreter ===================================== @@ -313,8 +309,6 @@ * We dump colored graphs as a bytecode and interpret them -XXX demo - JIT details - backends ====================== From fijal at codespeak.net Mon Jan 5 21:53:40 2009 From: fijal at codespeak.net (fijal at codespeak.net) Date: Mon, 5 Jan 2009 21:53:40 +0100 (CET) Subject: [pypy-svn] r60807 - pypy/branch/oo-jit/pypy/annotation Message-ID: <20090105205340.38E2D16853A@codespeak.net> Author: fijal Date: Mon Jan 5 21:53:37 2009 New Revision: 60807 Modified: pypy/branch/oo-jit/pypy/annotation/builtin.py Log: raise a bit more specific error Modified: pypy/branch/oo-jit/pypy/annotation/builtin.py ============================================================================== --- pypy/branch/oo-jit/pypy/annotation/builtin.py (original) +++ pypy/branch/oo-jit/pypy/annotation/builtin.py Mon Jan 5 21:53:37 2009 @@ -144,6 +144,8 @@ r = SomeBool() if s_type.is_constant(): typ = s_type.const + if isinstance(typ, tuple): + raise AnnotatorError("isinstance(..., tuple) is not RPython") if issubclass(typ, pypy.rlib.rarithmetic.base_int): r.const = issubclass(s_obj.knowntype, typ) else: From fijal at codespeak.net Tue Jan 6 12:27:23 2009 From: fijal at codespeak.net (fijal at codespeak.net) Date: Tue, 6 Jan 2009 12:27:23 +0100 (CET) Subject: [pypy-svn] r60810 - pypy/branch/oo-jit/pypy/rlib Message-ID: <20090106112723.D07A3168055@codespeak.net> Author: fijal Date: Tue Jan 6 12:27:22 2009 New Revision: 60810 Modified: pypy/branch/oo-jit/pypy/rlib/debug.py Log: A simple wrapper that raises AnnotatorError when function is attempted to be annotated. Helps debugging Modified: pypy/branch/oo-jit/pypy/rlib/debug.py ============================================================================== --- pypy/branch/oo-jit/pypy/rlib/debug.py (original) +++ pypy/branch/oo-jit/pypy/rlib/debug.py Tue Jan 6 12:27:22 2009 @@ -1,5 +1,6 @@ import sys from pypy.rpython.extregistry import ExtRegistryEntry +from pypy.tool.error import AnnotatorError def ll_assert(x, msg): """After translation to C, this becomes an RPyAssert.""" @@ -98,3 +99,11 @@ hop.exception_cannot_occur() return hop.inputarg(hop.args_r[0], arg=0) +def make_sure_not_translated(func): + class Entry(ExtRegistryEntry): + _about_ = func + + def compute_result_annotation(self, *args): + raise AnnotatorError("Should not be here") + + return func From pypy-svn at codespeak.net Tue Jan 6 14:53:27 2009 From: pypy-svn at codespeak.net (pypy-svn at codespeak.net) Date: Tue, 6 Jan 2009 14:53:27 +0100 (CET) Subject: [pypy-svn] Jessica Alba giving good head Message-ID: <20090106135327.EB8CA16849B@codespeak.net> An HTML attachment was scrubbed... URL: From pypy-svn at codespeak.net Tue Jan 6 10:02:10 2009 From: pypy-svn at codespeak.net (Online Viagra) Date: Tue, 6 Jan 2009 11:02:10 +0200 Subject: [pypy-svn] hnkpm pypy-svn@codespeak.net; Have you changed your number? purk Message-ID: An HTML attachment was scrubbed... URL: From fijal at codespeak.net Thu Jan 8 13:21:50 2009 From: fijal at codespeak.net (fijal at codespeak.net) Date: Thu, 8 Jan 2009 13:21:50 +0100 (CET) Subject: [pypy-svn] r60841 - pypy/branch/oo-jit/pypy/rpython/lltypesystem Message-ID: <20090108122150.40E8116857F@codespeak.net> Author: fijal Date: Thu Jan 8 13:21:49 2009 New Revision: 60841 Modified: pypy/branch/oo-jit/pypy/rpython/lltypesystem/ll2ctypes.py Log: oops, missing import Modified: pypy/branch/oo-jit/pypy/rpython/lltypesystem/ll2ctypes.py ============================================================================== --- pypy/branch/oo-jit/pypy/rpython/lltypesystem/ll2ctypes.py (original) +++ pypy/branch/oo-jit/pypy/rpython/lltypesystem/ll2ctypes.py Thu Jan 8 13:21:49 2009 @@ -18,6 +18,7 @@ from pypy.rpython.llinterp import LLInterpreter from pypy.rpython.lltypesystem.rclass import OBJECT from pypy.rpython.annlowlevel import base_ptr_lltype +from pypy.rpython import raddress def uaddressof(obj): return fixid(ctypes.addressof(obj)) From pedronis at codespeak.net Fri Jan 9 10:33:20 2009 From: pedronis at codespeak.net (pedronis at codespeak.net) Date: Fri, 9 Jan 2009 10:33:20 +0100 (CET) Subject: [pypy-svn] r60848 - pypy/build/bot2 Message-ID: <20090109093320.76882168572@codespeak.net> Author: pedronis Date: Fri Jan 9 10:33:19 2009 New Revision: 60848 Modified: pypy/build/bot2/TODO Log: (bea, pedronis) gardening of the todos Modified: pypy/build/bot2/TODO ============================================================================== --- pypy/build/bot2/TODO (original) +++ pypy/build/bot2/TODO Fri Jan 9 10:33:19 2009 @@ -1,23 +1,22 @@ -- buildbot Nightly scheduler that can pick a uniform revision server side and with support - for specifying possibly branches - -- some kind of progress information for a run - -- support for better information in case of runner-level killed hanging tests - -- pypy-c py.test -A support IN-PROGRESS - -- have a way for the involved tool to avoid color escapes even when there's a tty (because of buildbot pty usage) +Issues (in descending priority order) +---------------------------------------- +- it seems there is no timeout detection anymore for the lib-python tests (?) ! -- move most buildbots to be over python 2.5 (?) +- slave for own test need pexect (seems not to be there on wyvern's python?) -- wire windows slave IN-PROGRESS +- move most buildbots to be over python 2.5 or 2.6 (LIKELY) -- slave for own test need pexect (seems not to be there on wyvern's python?) +- buildbot Nightly scheduler that can pick a uniform revision server side and with support + for specifying possibly branches - convention for naming and coalescing alternative builders for the same build +Nice to have +--------------- + - implement pre-switch logic to avoid the full checkouts when running non default branches -- it seems there is no timeout detection anymore for the lib-python tests (?) +- some kind of progress information for a run + +- have a way for the involved tool to avoid color escapes even when there's a tty (because of buildbot pty usage) From pedronis at codespeak.net Fri Jan 9 14:24:00 2009 From: pedronis at codespeak.net (pedronis at codespeak.net) Date: Fri, 9 Jan 2009 14:24:00 +0100 (CET) Subject: [pypy-svn] r60856 - pypy/build/bot2/pypybuildbot Message-ID: <20090109132400.429A316847F@codespeak.net> Author: pedronis Date: Fri Jan 9 14:23:59 2009 New Revision: 60856 Modified: pypy/build/bot2/pypybuildbot/master.py Log: (bea, pedronis) run the py.test -A tests on linux nightly as well Modified: pypy/build/bot2/pypybuildbot/master.py ============================================================================== --- pypy/build/bot2/pypybuildbot/master.py (original) +++ pypy/build/bot2/pypybuildbot/master.py Fri Jan 9 14:23:59 2009 @@ -44,7 +44,8 @@ 'change_source': [], 'schedulers': [ - Nightly("nightly", [LINUX32, CPYLINUX32], hour=4, minute=45), + Nightly("nightly", [LINUX32, CPYLINUX32, APPLVLLINUX32], + hour=4, minute=45), ], 'status': [status], From pedronis at codespeak.net Fri Jan 9 14:26:59 2009 From: pedronis at codespeak.net (pedronis at codespeak.net) Date: Fri, 9 Jan 2009 14:26:59 +0100 (CET) Subject: [pypy-svn] r60857 - pypy/trunk/pypy Message-ID: <20090109132659.B538F168480@codespeak.net> Author: pedronis Date: Fri Jan 9 14:26:59 2009 New Revision: 60857 Modified: pypy/trunk/pypy/pytest-A.cfg Log: (bea, pedronis) run also the lib and module tests in the nighlty py.test -A runs Modified: pypy/trunk/pypy/pytest-A.cfg ============================================================================== --- pypy/trunk/pypy/pytest-A.cfg (original) +++ pypy/trunk/pypy/pytest-A.cfg Fri Jan 9 14:26:59 2009 @@ -1,4 +1,4 @@ -cherrypick = ['interpreter', 'objspace/std'] +cherrypick = ['interpreter', 'objspace/std', 'module', 'lib'] interp = ['translator/goal/pypy-c'] test_driver = ['test_all.py', '-A'] From pedronis at codespeak.net Fri Jan 9 14:47:38 2009 From: pedronis at codespeak.net (pedronis at codespeak.net) Date: Fri, 9 Jan 2009 14:47:38 +0100 (CET) Subject: [pypy-svn] r60858 - pypy/trunk/pypy/module/__builtin__/test Message-ID: <20090109134738.845C21684A7@codespeak.net> Author: pedronis Date: Fri Jan 9 14:47:37 2009 New Revision: 60858 Modified: pypy/trunk/pypy/module/__builtin__/test/test_builtin.py Log: (bea, pedronis) this test exhaust all memory right now when run with py.test -A with a stackless build, for now check for that situation and skip it then Modified: pypy/trunk/pypy/module/__builtin__/test/test_builtin.py ============================================================================== --- pypy/trunk/pypy/module/__builtin__/test/test_builtin.py (original) +++ pypy/trunk/pypy/module/__builtin__/test/test_builtin.py Fri Jan 9 14:47:37 2009 @@ -307,6 +307,11 @@ raises(RuntimeError, cmp, c1, c2) def test_cmp_cyclic(self): + import sys + if hasattr(sys, 'pypy_translation_info'): + if sys.pypy_translation_info.get('translation.stackless'): + skip("this consumes all memory with stackless") + if not self.sane_lookup: skip("underlying Python implementation has insane dict lookup") a = []; a.append(a) From pedronis at codespeak.net Fri Jan 9 14:56:37 2009 From: pedronis at codespeak.net (pedronis at codespeak.net) Date: Fri, 9 Jan 2009 14:56:37 +0100 (CET) Subject: [pypy-svn] r60859 - pypy/trunk/pypy Message-ID: <20090109135637.3CB6E1684A7@codespeak.net> Author: pedronis Date: Fri Jan 9 14:56:35 2009 New Revision: 60859 Added: pypy/trunk/pypy/pytest-A-stackless.cfg (contents, props changed) Log: (bea, pedronis) extra testrunner config file to run py.test -A tests with a stackless build, run single files in some dir where we expect fatal errors because of current stackless issues Added: pypy/trunk/pypy/pytest-A-stackless.cfg ============================================================================== --- (empty file) +++ pypy/trunk/pypy/pytest-A-stackless.cfg Fri Jan 9 14:56:35 2009 @@ -0,0 +1,10 @@ +# run for some directories a file at a time + +def collect_one_testdir(testdirs, reldir, tests): + if (reldir.startswith('module/_stackless/') or + reldir.startswith('lib')): + testdirs.extend(tests) + else: + testdirs.append(reldir) + + From pedronis at codespeak.net Fri Jan 9 15:07:28 2009 From: pedronis at codespeak.net (pedronis at codespeak.net) Date: Fri, 9 Jan 2009 15:07:28 +0100 (CET) Subject: [pypy-svn] r60860 - pypy/build/bot2/pypybuildbot Message-ID: <20090109140728.0B7D61684B2@codespeak.net> Author: pedronis Date: Fri Jan 9 15:07:27 2009 New Revision: 60860 Modified: pypy/build/bot2/pypybuildbot/builds.py pypy/build/bot2/pypybuildbot/master.py Log: (bea, pedronis) attempt at a py.test -A stackless builder, not scheduled nightly for now Modified: pypy/build/bot2/pypybuildbot/builds.py ============================================================================== --- pypy/build/bot2/pypybuildbot/builds.py (original) +++ pypy/build/bot2/pypybuildbot/builds.py Fri Jan 9 15:07:27 2009 @@ -144,6 +144,29 @@ timeout = 4000, env={"PYTHONPATH": ['.']})) + +class PyPyStacklessTranslatedAppLevelTestFactory(factory.BuildFactory): + + def __init__(self, *a, **kw): + platform = kw.pop('platform', 'linux') + factory.BuildFactory.__init__(self, *a, **kw) + + setup_steps(platform, self) + + self.addStep(Translate(["-O2", "--stackless"], [])) + + self.addStep(ShellCmd( + description="app-level (-A) test", + command=["python", "testrunner/runner.py", + "--logfile=pytest-A.log", + "--config=pypy/pytest-A.cfg", + "--config=pypy/pytest-A-stackless.cfg", + "--root=pypy", "--timeout=1800"], + logfiles={'pytestLog': 'pytest-A.log'}, + timeout = 4000, + env={"PYTHONPATH": ['.']})) + + class PyPyTranslatedScratchboxTestFactory(factory.BuildFactory): def __init__(self, *a, **kw): USERNAME = 'buildbot' Modified: pypy/build/bot2/pypybuildbot/master.py ============================================================================== --- pypy/build/bot2/pypybuildbot/master.py (original) +++ pypy/build/bot2/pypybuildbot/master.py Fri Jan 9 15:07:27 2009 @@ -31,12 +31,15 @@ pypyTranslatedAppLevelTestFactory = pypybuilds.PyPyTranslatedAppLevelTestFactory() +pypyStacklessTranslatedAppLevelTestFactory = pypybuilds.PyPyStacklessTranslatedAppLevelTestFactory() + LINUX32 = "own-linux-x86-32" CPYLINUX32 = "pypy-c-lib-python-linux-x86-32" CPYWIN32 = "pypy-c-lib-python-win-32" CPYLINUX32_VM = 'pypy-c-lib-python-linux-x86-32vm' CPYMAEMO = "pypy-c-lib-python-maemo" APPLVLLINUX32 = "pypy-c-app-level-linux-x86-32" +STACKLESSAPPLVLLINUX32 = "pypy-c-stackless-app-level-linux-x86-32" CPYFREEBSD64 = 'pypy-c-lib-python-freebsd-7-x86-64' BuildmasterConfig = { @@ -68,7 +71,12 @@ "slavenames": ["wyvern", "cobra"], "builddir": APPLVLLINUX32, "factory": pypyTranslatedAppLevelTestFactory - }, + }, + {"name": STACKLESSAPPLVLLINUX32, + "slavenames": ["wyvern", "cobra"], + "builddir": STACKLESSAPPLVLLINUX32, + "factory": pypyStacklessTranslatedAppLevelTestFactory + }, {"name" : CPYLINUX32_VM, "slavenames": ['bigdogvm1'], "builddir": CPYLINUX32_VM, From pedronis at codespeak.net Sat Jan 10 13:37:19 2009 From: pedronis at codespeak.net (pedronis at codespeak.net) Date: Sat, 10 Jan 2009 13:37:19 +0100 (CET) Subject: [pypy-svn] r60867 - pypy/trunk/pypy/objspace/test Message-ID: <20090110123719.01CCE168445@codespeak.net> Author: pedronis Date: Sat Jan 10 13:37:17 2009 New Revision: 60867 Added: pypy/trunk/pypy/objspace/test/test_binop_overriding.py (contents, props changed) Log: issue412 in-progress tests about issue412, they pass on cpython but fails on PyPy, made most of them run only with py.test -A because they are quite exhaistive but slow Added: pypy/trunk/pypy/objspace/test/test_binop_overriding.py ============================================================================== --- (empty file) +++ pypy/trunk/pypy/objspace/test/test_binop_overriding.py Sat Jan 10 13:37:17 2009 @@ -0,0 +1,175 @@ +# test about the binop operation rule, see issue 412 +from pypy.conftest import option + +class AppTestBinopCombinations: + + def setup_class(cls): + w_helpers = cls.space.appexec([], """(): + class Base(object): + def __init__(self, name): + self.name = name + + def lookup_where(obj, name): + mro = type(obj).__mro__ + for t in mro: + if name in t.__dict__: + return t.__dict__[name], t + return None, None + + def refop(x, y, opname, ropname): + # this has been validated by running the tests on top of cpython + # so for the space of possibilities that the tests touch it is known + # to behave like cpython as long as the latter doesn't change its own + # algorithm + t1 = type(x) + t2 = type(y) + op, where1 = lookup_where(x, opname) + rop, where2 = lookup_where(y, ropname) + if op is None and rop is not None: + return rop(y, x) + if rop and where1 is not where2: + if (issubclass(t2, t1) and not issubclass(where1, where2) + and not issubclass(t1, where2) + ): + return rop(y, x) + if op is None: + return "TypeError" + return op(x,y) + + def do_test(X, Y, name, impl): + x = X('x') + y = Y('y') + opname = '__%s__' % name + ropname = '__r%s__' % name + + count = [0] + fail = [] + + def check(z1, z2): + ref = refop(z1, z2, opname, ropname) + try: + v = impl(z1, z2) + except TypeError: + v = "TypeError" + if v != ref: + fail.append(count[0]) + + def override_in_hier(n=6): + if n == 0: + count[0] += 1 + check(x, y) + check(y, x) + return + + f = lambda self, other: (n, self.name, other.name) + if n%2 == 0: + name = opname + else: + name = ropname + + for C in Y.__mro__: + if name in C.__dict__: + continue + if C is not object: + setattr(C, name, f) + override_in_hier(n-1) + if C is not object: + delattr(C, name) + + override_in_hier() + #print count[0] + return fail + + return Base, do_test +""") + cls.w_helpers = w_helpers + cls.w_appdirect = cls.space.wrap(option.runappdirect) + + def test_overriding_base_binop_explict(self): + if not self.appdirect: + skip("fails, issue412") + class MulBase(object): + def __init__(self, value): + self.value = value + def __mul__(self, other): + return self.value * other.value + def __rmul__(self, other): + return other.value * self.value + class DoublerBase(MulBase): + def __mul__(self, other): + return 2 * (self.value * other.value) + class AnotherDoubler(DoublerBase): + pass + res = DoublerBase(2) * AnotherDoubler(3) + assert res == 12 + + def test_binop_combinations_mul(self): + if not self.appdirect: + skip("slow test, should be run as appdirect test") + Base, do_test = self.helpers + + class X(Base): + pass + class Y(X): + pass + + fail = do_test(X, Y, 'mul', lambda x,y: x*y) + #print len(fail) + assert not fail + + def test_binop_combinations_sub(self): + if not self.appdirect: + skip("fails, issue412") + Base, do_test = self.helpers + class X(Base): + pass + class Y(X): + pass + + fail = do_test(X, Y, 'sub', lambda x,y: x-y) + #print len(fail) + assert not fail + + def test_binop_combinations_pow(self): + if not self.appdirect: + skip("slow test, should be run as appdirect test") + Base, do_test = self.helpers + + class X(Base): + pass + class Y(X): + pass + + fail = do_test(X, Y, 'pow', lambda x,y: x**y) + #print len(fail) + assert not fail + + def test_binop_combinations_more_exhaustive(self): + if not self.appdirect: + skip("very slow test, should be run as appdirect test") + Base, do_test = self.helpers + + class X(Base): + pass + + class B1(object): + pass + + class B2(object): + pass + + class X1(B1, X, B2): + pass + + class C1(object): + pass + + class C2(object): + pass + + class Y(C1, X1, C2): + pass + + fail = do_test(X, Y, 'sub', lambda x,y: x-y) + #print len(fail) + assert not fail From pedronis at codespeak.net Sat Jan 10 13:53:26 2009 From: pedronis at codespeak.net (pedronis at codespeak.net) Date: Sat, 10 Jan 2009 13:53:26 +0100 (CET) Subject: [pypy-svn] r60868 - pypy/trunk/pypy Message-ID: <20090110125326.DEA9916844B@codespeak.net> Author: pedronis Date: Sat Jan 10 13:53:24 2009 New Revision: 60868 Modified: pypy/trunk/pypy/pytest-A.cfg Log: objspace/test has also some relevant applevel tests Modified: pypy/trunk/pypy/pytest-A.cfg ============================================================================== --- pypy/trunk/pypy/pytest-A.cfg (original) +++ pypy/trunk/pypy/pytest-A.cfg Sat Jan 10 13:53:24 2009 @@ -1,4 +1,4 @@ -cherrypick = ['interpreter', 'objspace/std', 'module', 'lib'] +cherrypick = ['interpreter', 'objspace/test', 'objspace/std', 'module', 'lib'] interp = ['translator/goal/pypy-c'] test_driver = ['test_all.py', '-A'] From pedronis at codespeak.net Sat Jan 10 14:30:50 2009 From: pedronis at codespeak.net (pedronis at codespeak.net) Date: Sat, 10 Jan 2009 14:30:50 +0100 (CET) Subject: [pypy-svn] r60869 - pypy/trunk/pypy/translator/c/src Message-ID: <20090110133050.375B9168031@codespeak.net> Author: pedronis Date: Sat Jan 10 14:30:48 2009 New Revision: 60869 Modified: pypy/trunk/pypy/translator/c/src/main.h pypy/trunk/pypy/translator/c/src/obmalloc.c Log: behave more like CPython does and abort(), this in particular should give us an exitcode that is not 1 which is what py.test uses for some tests have failed, which results in our nightly testrunner believing that some test file passed with some failures when what really happened is that pypy-c failed fatally :( Modified: pypy/trunk/pypy/translator/c/src/main.h ============================================================================== --- pypy/trunk/pypy/translator/c/src/main.h (original) +++ pypy/trunk/pypy/translator/c/src/main.h Sat Jan 10 14:30:48 2009 @@ -41,7 +41,7 @@ fprintf(stderr, "Fatal RPython error: %s\n", RPyFetchExceptionType()->ov_name->items); #endif - exitcode = 1; + abort(); } return exitcode; @@ -51,7 +51,7 @@ #ifndef AVR fprintf(stderr, "Fatal error during initialization: %s\n", errmsg); #endif - return 1; + abort(); } #endif /* PYPY_NOT_MAIN_FILE */ Modified: pypy/trunk/pypy/translator/c/src/obmalloc.c ============================================================================== --- pypy/trunk/pypy/translator/c/src/obmalloc.c (original) +++ pypy/trunk/pypy/translator/c/src/obmalloc.c Sat Jan 10 14:30:48 2009 @@ -898,7 +898,7 @@ void Py_FatalError(const char *msg) { fprintf(stderr, "Py_FatalError() called in obmalloc!\n%s\n", msg); - exit(1); + abort(); } #define PyOS_snprintf snprintf /* end of XXX */ From pedronis at codespeak.net Sat Jan 10 14:41:23 2009 From: pedronis at codespeak.net (pedronis at codespeak.net) Date: Sat, 10 Jan 2009 14:41:23 +0100 (CET) Subject: [pypy-svn] r60870 - pypy/trunk/pypy/objspace Message-ID: <20090110134123.E8C24168456@codespeak.net> Author: pedronis Date: Sat Jan 10 14:41:23 2009 New Revision: 60870 Modified: pypy/trunk/pypy/objspace/descroperation.py Log: these don't use the binop rule as such in CPython, though the right and left variants are the same so this should anyway not be too wrong and there's little point on applying the more complicated logic that the binop rule demands because of issue412 Modified: pypy/trunk/pypy/objspace/descroperation.py ============================================================================== --- pypy/trunk/pypy/objspace/descroperation.py (original) +++ pypy/trunk/pypy/objspace/descroperation.py Sat Jan 10 14:41:23 2009 @@ -365,7 +365,7 @@ w_right_impl = None else: w_right_src, w_right_impl = space.lookup_in_type_where(w_typ2, '__coerce__') - if (w_left_src is not w_right_src # XXX see binop_impl + if (w_left_src is not w_right_src and space.is_true(space.issubtype(w_typ2, w_typ1))): w_obj1, w_obj2 = w_obj2, w_obj1 w_left_impl, w_right_impl = w_right_impl, w_left_impl @@ -423,7 +423,7 @@ w_right_impl = None else: w_right_src, w_right_impl = space.lookup_in_type_where(w_typ2, '__cmp__') - if (w_left_src is not w_right_src # XXX see binop_impl + if (w_left_src is not w_right_src and space.is_true(space.issubtype(w_typ2, w_typ1))): w_obj1, w_obj2 = w_obj2, w_obj1 w_left_impl, w_right_impl = w_right_impl, w_left_impl From pedronis at codespeak.net Sat Jan 10 15:10:06 2009 From: pedronis at codespeak.net (pedronis at codespeak.net) Date: Sat, 10 Jan 2009 15:10:06 +0100 (CET) Subject: [pypy-svn] r60872 - pypy/trunk/pypy/objspace/std/test Message-ID: <20090110141006.8DADE16844C@codespeak.net> Author: pedronis Date: Sat Jan 10 15:10:06 2009 New Revision: 60872 Modified: pypy/trunk/pypy/objspace/std/test/test_set.py Log: I have seen order dep issues in the repr tests on one of my machines Modified: pypy/trunk/pypy/objspace/std/test/test_set.py ============================================================================== --- pypy/trunk/pypy/objspace/std/test/test_set.py (original) +++ pypy/trunk/pypy/objspace/std/test/test_set.py Sat Jan 10 15:10:06 2009 @@ -81,6 +81,8 @@ s = set([1, 2, 3]) s.add(A(s)) + # xxx this seems to have order dependency issues + # "set([set(...), 1, 2, 3])" have been spotted too assert repr(s) == "set([1, 2, 3, set(...)])" def test_recursive_repr_frozenset(self): @@ -90,6 +92,8 @@ a = A() s = frozenset([1, 2, 3, a]) a.s = s + # xxx this seems to have order dependency issues + # "frozenset([frozenset(...), 1, 2, 3])" have been spotted too assert repr(s) == "frozenset([1, 2, 3, frozenset(...)])" def test_keyerror_has_key(self): From pedronis at codespeak.net Sat Jan 10 15:12:03 2009 From: pedronis at codespeak.net (pedronis at codespeak.net) Date: Sat, 10 Jan 2009 15:12:03 +0100 (CET) Subject: [pypy-svn] r60873 - pypy/trunk/pypy/objspace/std/test Message-ID: <20090110141203.55D6716844C@codespeak.net> Author: pedronis Date: Sat Jan 10 15:12:00 2009 New Revision: 60873 Modified: pypy/trunk/pypy/objspace/std/test/test_set.py Log: oops, typos Modified: pypy/trunk/pypy/objspace/std/test/test_set.py ============================================================================== --- pypy/trunk/pypy/objspace/std/test/test_set.py (original) +++ pypy/trunk/pypy/objspace/std/test/test_set.py Sat Jan 10 15:12:00 2009 @@ -82,7 +82,7 @@ s = set([1, 2, 3]) s.add(A(s)) # xxx this seems to have order dependency issues - # "set([set(...), 1, 2, 3])" have been spotted too + # "set([set(...), 1, 2, 3])" has been spotted too assert repr(s) == "set([1, 2, 3, set(...)])" def test_recursive_repr_frozenset(self): @@ -93,7 +93,7 @@ s = frozenset([1, 2, 3, a]) a.s = s # xxx this seems to have order dependency issues - # "frozenset([frozenset(...), 1, 2, 3])" have been spotted too + # "frozenset([frozenset(...), 1, 2, 3])" has been spotted too assert repr(s) == "frozenset([1, 2, 3, frozenset(...)])" def test_keyerror_has_key(self): From fijal at codespeak.net Sat Jan 10 19:00:09 2009 From: fijal at codespeak.net (fijal at codespeak.net) Date: Sat, 10 Jan 2009 19:00:09 +0100 (CET) Subject: [pypy-svn] r60876 - pypy/trunk/pypy/config Message-ID: <20090110180009.89FE4168477@codespeak.net> Author: fijal Date: Sat Jan 10 19:00:06 2009 New Revision: 60876 Modified: pypy/trunk/pypy/config/pypyoption.py pypy/trunk/pypy/config/translationoption.py Log: A couple of hints for sandboxed interpreter (no all modules and choose generation gc instead of hybrid) Modified: pypy/trunk/pypy/config/pypyoption.py ============================================================================== --- pypy/trunk/pypy/config/pypyoption.py (original) +++ pypy/trunk/pypy/config/pypyoption.py Sat Jan 10 19:00:06 2009 @@ -385,6 +385,8 @@ modules = working_oo_modules else: modules = working_modules + if config.translation.sandbox: + modules = default_modules # ignore names from 'essential_modules', notably 'exceptions', which # may not be present in config.objspace.usemodules at all modules = [name for name in modules if name not in essential_modules] Modified: pypy/trunk/pypy/config/translationoption.py ============================================================================== --- pypy/trunk/pypy/config/translationoption.py (original) +++ pypy/trunk/pypy/config/translationoption.py Sat Jan 10 19:00:06 2009 @@ -103,7 +103,8 @@ default=False, cmdline="--thread"), BoolOption("sandbox", "Produce a fully-sandboxed executable", default=False, cmdline="--sandbox", - requires=[("translation.thread", False)]), + requires=[("translation.thread", False)], + suggests=[("translation.gc", "generation")]), BoolOption("rweakref", "The backend supports RPython-level weakrefs", default=True), @@ -340,6 +341,8 @@ gc = words.pop(0) # set the GC (only meaningful with lltype) + if config.translation.sandbox and gc == 'hybrid': + gc = 'generation' config.translation.suggest(gc=gc) # set the backendopts From fijal at codespeak.net Sat Jan 10 21:08:16 2009 From: fijal at codespeak.net (fijal at codespeak.net) Date: Sat, 10 Jan 2009 21:08:16 +0100 (CET) Subject: [pypy-svn] r60877 - pypy/extradoc/talk/wroclaw2009 Message-ID: <20090110200816.BBC5B168447@codespeak.net> Author: fijal Date: Sat Jan 10 21:08:13 2009 New Revision: 60877 Added: pypy/extradoc/talk/wroclaw2009/ pypy/extradoc/talk/wroclaw2009/abstract.txt (contents, props changed) Log: Abstract for my talk before sprint Added: pypy/extradoc/talk/wroclaw2009/abstract.txt ============================================================================== --- (empty file) +++ pypy/extradoc/talk/wroclaw2009/abstract.txt Sat Jan 10 21:08:13 2009 @@ -0,0 +1,8 @@ +PyPy - interpreter pythona napisany w pythonie. Celem projektu jest +dostarczenie lepszego i szybszego interpretera pythona niz CPython, +jednoczesnie nie uzywajac C ani zadnego niskopoziomowego jezyka. +Prezentacja bedzie pokrywac motywacje, dlaczego nowy interpreter +pythona, wysokopoziomowy rzut oka na architekture oraz na mozliwosci +szybkiej interpretacji dynamicznych jezykow. Jednym z ciekawszych +aspektow bedzie prezentacja dynamicznej kompilacji pythona (JIT - just +in time compilation), ktory sam jest napisany w pythonie. From fijal at codespeak.net Sat Jan 10 21:10:16 2009 From: fijal at codespeak.net (fijal at codespeak.net) Date: Sat, 10 Jan 2009 21:10:16 +0100 (CET) Subject: [pypy-svn] r60878 - pypy/extradoc/talk/wroclaw2009 Message-ID: <20090110201016.7AEC8168447@codespeak.net> Author: fijal Date: Sat Jan 10 21:10:15 2009 New Revision: 60878 Modified: pypy/extradoc/talk/wroclaw2009/abstract.txt Log: expand Modified: pypy/extradoc/talk/wroclaw2009/abstract.txt ============================================================================== --- pypy/extradoc/talk/wroclaw2009/abstract.txt (original) +++ pypy/extradoc/talk/wroclaw2009/abstract.txt Sat Jan 10 21:10:15 2009 @@ -5,4 +5,6 @@ pythona, wysokopoziomowy rzut oka na architekture oraz na mozliwosci szybkiej interpretacji dynamicznych jezykow. Jednym z ciekawszych aspektow bedzie prezentacja dynamicznej kompilacji pythona (JIT - just -in time compilation), ktory sam jest napisany w pythonie. +in time compilation), ktory sam jest napisany w pythonie. Prezentacja +nie zaklada uprzedniej znajomosci pythona i jest skierowana do wszystkich +zainteresowanych implementacja dynamicznych jezykow. From fijal at codespeak.net Sat Jan 10 21:31:23 2009 From: fijal at codespeak.net (fijal at codespeak.net) Date: Sat, 10 Jan 2009 21:31:23 +0100 (CET) Subject: [pypy-svn] r60879 - pypy/extradoc/talk/wroclaw2009 Message-ID: <20090110203123.06029168441@codespeak.net> Author: fijal Date: Sat Jan 10 21:31:22 2009 New Revision: 60879 Modified: pypy/extradoc/talk/wroclaw2009/abstract.txt Log: extend a bit Modified: pypy/extradoc/talk/wroclaw2009/abstract.txt ============================================================================== --- pypy/extradoc/talk/wroclaw2009/abstract.txt (original) +++ pypy/extradoc/talk/wroclaw2009/abstract.txt Sat Jan 10 21:31:22 2009 @@ -8,3 +8,6 @@ in time compilation), ktory sam jest napisany w pythonie. Prezentacja nie zaklada uprzedniej znajomosci pythona i jest skierowana do wszystkich zainteresowanych implementacja dynamicznych jezykow. + +W dniach 7-14 lutego odbedzie sie na terenie politechniki Wroclawskiej +sprint PyPy. Sprint jest to XXX From getxsick at codespeak.net Sat Jan 10 21:50:35 2009 From: getxsick at codespeak.net (getxsick at codespeak.net) Date: Sat, 10 Jan 2009 21:50:35 +0100 (CET) Subject: [pypy-svn] r60881 - pypy/extradoc/talk/wroclaw2009 Message-ID: <20090110205035.9FB1E168476@codespeak.net> Author: getxsick Date: Sat Jan 10 21:50:35 2009 New Revision: 60881 Modified: pypy/extradoc/talk/wroclaw2009/abstract.txt Log: added polish characters and fixed typos Modified: pypy/extradoc/talk/wroclaw2009/abstract.txt ============================================================================== --- pypy/extradoc/talk/wroclaw2009/abstract.txt (original) +++ pypy/extradoc/talk/wroclaw2009/abstract.txt Sat Jan 10 21:50:35 2009 @@ -1,13 +1,13 @@ PyPy - interpreter pythona napisany w pythonie. Celem projektu jest -dostarczenie lepszego i szybszego interpretera pythona niz CPython, -jednoczesnie nie uzywajac C ani zadnego niskopoziomowego jezyka. -Prezentacja bedzie pokrywac motywacje, dlaczego nowy interpreter -pythona, wysokopoziomowy rzut oka na architekture oraz na mozliwosci -szybkiej interpretacji dynamicznych jezykow. Jednym z ciekawszych -aspektow bedzie prezentacja dynamicznej kompilacji pythona (JIT - just -in time compilation), ktory sam jest napisany w pythonie. Prezentacja -nie zaklada uprzedniej znajomosci pythona i jest skierowana do wszystkich -zainteresowanych implementacja dynamicznych jezykow. +dostarczenie lepszego i szybszego interpretera pythona ni? CPython, +jednocze?nie nie u?ywaj?c C ani ?adnego niskopoziomowego j?zyka. +Prezentacja b?dzie pokrywa? motywacje, dlaczego nowy interpreter +pythona, wysokopoziomowy rzut oka na architektur? oraz na mo?liwo?ci +szybkiej interpretacji dynamicznych j?zyk?w. Jednym z ciekawszych +aspekt?w b?dzie prezentacja dynamicznej kompilacji pythona (JIT - just +in time compilation), kt?ry sam jest napisany w pythonie. Prezentacja +nie zak?ada uprzedniej znajomo?ci pythona i jest skierowana do wszystkich +zainteresowanych implementacj? dynamicznych jezyk?w. -W dniach 7-14 lutego odbedzie sie na terenie politechniki Wroclawskiej +W dniach 7-14 lutego odb?dzie si? na terenie Politechniki Wroclawskiej sprint PyPy. Sprint jest to XXX From getxsick at codespeak.net Sat Jan 10 22:36:10 2009 From: getxsick at codespeak.net (getxsick at codespeak.net) Date: Sat, 10 Jan 2009 22:36:10 +0100 (CET) Subject: [pypy-svn] r60882 - pypy/extradoc/talk/wroclaw2009 Message-ID: <20090110213610.47314168425@codespeak.net> Author: getxsick Date: Sat Jan 10 22:36:09 2009 New Revision: 60882 Modified: pypy/extradoc/talk/wroclaw2009/abstract.txt Log: some parts of abstract are rewritten Modified: pypy/extradoc/talk/wroclaw2009/abstract.txt ============================================================================== --- pypy/extradoc/talk/wroclaw2009/abstract.txt (original) +++ pypy/extradoc/talk/wroclaw2009/abstract.txt Sat Jan 10 22:36:09 2009 @@ -1,13 +1,13 @@ PyPy - interpreter pythona napisany w pythonie. Celem projektu jest dostarczenie lepszego i szybszego interpretera pythona ni? CPython, jednocze?nie nie u?ywaj?c C ani ?adnego niskopoziomowego j?zyka. -Prezentacja b?dzie pokrywa? motywacje, dlaczego nowy interpreter -pythona, wysokopoziomowy rzut oka na architektur? oraz na mo?liwo?ci -szybkiej interpretacji dynamicznych j?zyk?w. Jednym z ciekawszych -aspekt?w b?dzie prezentacja dynamicznej kompilacji pythona (JIT - just -in time compilation), kt?ry sam jest napisany w pythonie. Prezentacja -nie zak?ada uprzedniej znajomo?ci pythona i jest skierowana do wszystkich -zainteresowanych implementacj? dynamicznych jezyk?w. +Prezentacja przedstawi motywacje towarzysz?ce stworzeniu nowego +interpretera pythona, wysokopoziomowy rzut oka na architektur? oraz +na mo?liwo?ci szybkiej interpretacji dynamicznych j?zyk?w. Jednym +z ciekawszych aspekt?w b?dzie prezentacja dynamicznej kompilacji pythona +(JIT - just in time compilation), kt?ra sama napisana jest w pythonie. +Prezentacja nie zak?ada uprzedniej znajomo?ci pythona i jest skierowana +do wszystkich zainteresowanych implementacj? dynamicznych jezyk?w. W dniach 7-14 lutego odb?dzie si? na terenie Politechniki Wroclawskiej sprint PyPy. Sprint jest to XXX From getxsick at codespeak.net Sun Jan 11 00:20:46 2009 From: getxsick at codespeak.net (getxsick at codespeak.net) Date: Sun, 11 Jan 2009 00:20:46 +0100 (CET) Subject: [pypy-svn] r60884 - pypy/extradoc/talk/wroclaw2009 Message-ID: <20090110232046.853DB168449@codespeak.net> Author: getxsick Date: Sun Jan 11 00:20:44 2009 New Revision: 60884 Modified: pypy/extradoc/talk/wroclaw2009/abstract.txt Log: info about the sprint Modified: pypy/extradoc/talk/wroclaw2009/abstract.txt ============================================================================== --- pypy/extradoc/talk/wroclaw2009/abstract.txt (original) +++ pypy/extradoc/talk/wroclaw2009/abstract.txt Sun Jan 11 00:20:44 2009 @@ -11,3 +11,5 @@ W dniach 7-14 lutego odb?dzie si? na terenie Politechniki Wroclawskiej sprint PyPy. Sprint jest to XXX +Lokalizacja sprintu, Zintegrowane Centrum Studenckie, Wybrze?e +Wyspia?skiego 23-25, budynek C-13, sala 3.01. From fijal at codespeak.net Sun Jan 11 00:25:44 2009 From: fijal at codespeak.net (fijal at codespeak.net) Date: Sun, 11 Jan 2009 00:25:44 +0100 (CET) Subject: [pypy-svn] r60885 - pypy/extradoc/talk/wroclaw2009 Message-ID: <20090110232544.7AEDF168449@codespeak.net> Author: fijal Date: Sun Jan 11 00:25:44 2009 New Revision: 60885 Modified: pypy/extradoc/talk/wroclaw2009/abstract.txt Log: Add some info what the sprint is Modified: pypy/extradoc/talk/wroclaw2009/abstract.txt ============================================================================== --- pypy/extradoc/talk/wroclaw2009/abstract.txt (original) +++ pypy/extradoc/talk/wroclaw2009/abstract.txt Sun Jan 11 00:25:44 2009 @@ -10,6 +10,8 @@ do wszystkich zainteresowanych implementacj? dynamicznych jezyk?w. W dniach 7-14 lutego odb?dzie si? na terenie Politechniki Wroclawskiej -sprint PyPy. Sprint jest to XXX +sprint PyPy. Sprint jest to krotka (w tym wypadku tydzien) sesja intensywnego +programowania, czesto w wykonaniu pair programming. Jest to rowniez +wysmienita okazja do spotkania z developerami i wdrozenia sie do projektu. Lokalizacja sprintu, Zintegrowane Centrum Studenckie, Wybrze?e Wyspia?skiego 23-25, budynek C-13, sala 3.01. From getxsick at codespeak.net Sun Jan 11 00:29:30 2009 From: getxsick at codespeak.net (getxsick at codespeak.net) Date: Sun, 11 Jan 2009 00:29:30 +0100 (CET) Subject: [pypy-svn] r60886 - pypy/extradoc/talk/wroclaw2009 Message-ID: <20090110232930.4067C168449@codespeak.net> Author: getxsick Date: Sun Jan 11 00:29:29 2009 New Revision: 60886 Modified: pypy/extradoc/talk/wroclaw2009/abstract.txt Log: added polish characters Modified: pypy/extradoc/talk/wroclaw2009/abstract.txt ============================================================================== --- pypy/extradoc/talk/wroclaw2009/abstract.txt (original) +++ pypy/extradoc/talk/wroclaw2009/abstract.txt Sun Jan 11 00:29:29 2009 @@ -10,8 +10,8 @@ do wszystkich zainteresowanych implementacj? dynamicznych jezyk?w. W dniach 7-14 lutego odb?dzie si? na terenie Politechniki Wroclawskiej -sprint PyPy. Sprint jest to krotka (w tym wypadku tydzien) sesja intensywnego -programowania, czesto w wykonaniu pair programming. Jest to rowniez -wysmienita okazja do spotkania z developerami i wdrozenia sie do projektu. +sprint PyPy. Sprint jest to kr?tka (w tym wypadku tydzie?) sesja intensywnego +programowania, cz?sto w wykonaniu pair programming. Jest to r?wnie? +wy?mienita okazja do spotkania z developerami i wdro?enia si? do projektu. Lokalizacja sprintu, Zintegrowane Centrum Studenckie, Wybrze?e Wyspia?skiego 23-25, budynek C-13, sala 3.01. From getxsick at codespeak.net Sun Jan 11 01:21:19 2009 From: getxsick at codespeak.net (getxsick at codespeak.net) Date: Sun, 11 Jan 2009 01:21:19 +0100 (CET) Subject: [pypy-svn] r60887 - pypy/extradoc/sprintinfo/wroclaw2009 Message-ID: <20090111002119.CAFB516841A@codespeak.net> Author: getxsick Date: Sun Jan 11 01:21:17 2009 New Revision: 60887 Added: pypy/extradoc/sprintinfo/wroclaw2009/ Log: creating a directory about sprint information From getxsick at codespeak.net Sun Jan 11 01:44:36 2009 From: getxsick at codespeak.net (getxsick at codespeak.net) Date: Sun, 11 Jan 2009 01:44:36 +0100 (CET) Subject: [pypy-svn] r60888 - pypy/extradoc/sprintinfo/wroclaw2009 Message-ID: <20090111004436.4B13D16843D@codespeak.net> Author: getxsick Date: Sun Jan 11 01:44:35 2009 New Revision: 60888 Added: pypy/extradoc/sprintinfo/wroclaw2009/announcement.txt Log: first draft. location, native speaks, registration and other common information added Added: pypy/extradoc/sprintinfo/wroclaw2009/announcement.txt ============================================================================== --- (empty file) +++ pypy/extradoc/sprintinfo/wroclaw2009/announcement.txt Sun Jan 11 01:44:35 2009 @@ -0,0 +1,69 @@ +======================================================== +Wroc?aw PyPy sprint 7-14th February, 2009 +======================================================== + +-------- +Location +-------- + +Wroc?aw University of Technology, Poland +Wybrze?e Wyspia?skiego 23-25, Wroc?aw +building: C-13 (picture: http://tinyurl.com/6vvzwq) +room: 3.01 (3rd floor) +opening-hours: 8-21 (but the building is opened 24h/7) +campus map: http://www.pwr.wroc.pl/upload_module/images/english/campus_map.png +city map: http://tinyurl.com/7q3tfx + +--------------- +Native speakers +--------------- + +Official language in Poland is polish. There shouldn't be any problem with +english (especially during hotel booking etc) but if you need any help, +here is a list of native speakers whose participate the spring. Feel free +to contact with any of them: + + * Maciej Fija?kowski ( fijall at gmail.com ) + * Bartosz Skowron ( getxsick at gmail.com ) + * Jakub Gustak ( jgustak at gmail.com ) + +------------ +Registration +------------ + +If you'd like to come, please subscribe to the `pypy-sprint mailing list`_ +and drop a note about your interests and post any questions. More +organisational information will be sent to that list. + +Please register by adding yourself on the following list (via svn): + + http://codespeak.net/svn/pypy/extradoc/sprintinfo/wroclaw2009/people.txt + +or announce yourself on the pypy-sprint mailing list if you do not +yet have check-in rights: + + http://codespeak.net/mailman/listinfo/pypy-sprint + +-------------------------------------- +Preparation (if you feel it is needed) +-------------------------------------- + +* read the `getting-started`_ pages on http://codespeak.net/pypy + +* for inspiration, overview and technical status you are welcome to + read `the technical reports available and other relevant documentation`_ + +* please direct any technical and/or development oriented questions to + pypy-dev at codespeak.net and any sprint organizing/logistical + questions to pypy-sprint at codespeak.net + +We are looking forward to meet you at the Wroc?aw PyPy sprint! + +The PyPy team + +.. See also .. + +.. _getting-started: http://codespeak.net/pypy/dist/pypy/doc/getting-started.html +.. _`pypy-sprint mailing list`: http://codespeak.net/mailman/listinfo/pypy-sprint +.. _`the technical reports available and other relevant documentation`: http://codespeak.net/pypy/dist/pypy/doc/index.html + From getxsick at codespeak.net Sun Jan 11 01:53:14 2009 From: getxsick at codespeak.net (getxsick at codespeak.net) Date: Sun, 11 Jan 2009 01:53:14 +0100 (CET) Subject: [pypy-svn] r60889 - pypy/extradoc/sprintinfo/wroclaw2009 Message-ID: <20090111005314.8AA0816843D@codespeak.net> Author: getxsick Date: Sun Jan 11 01:53:10 2009 New Revision: 60889 Added: pypy/extradoc/sprintinfo/wroclaw2009/people.txt Modified: pypy/extradoc/sprintinfo/wroclaw2009/announcement.txt Log: fixed text and people list added Modified: pypy/extradoc/sprintinfo/wroclaw2009/announcement.txt ============================================================================== --- pypy/extradoc/sprintinfo/wroclaw2009/announcement.txt (original) +++ pypy/extradoc/sprintinfo/wroclaw2009/announcement.txt Sun Jan 11 01:53:10 2009 @@ -19,8 +19,8 @@ --------------- Official language in Poland is polish. There shouldn't be any problem with -english (especially during hotel booking etc) but if you need any help, -here is a list of native speakers whose participate the spring. Feel free +english at all (especially during hotel booking etc) but if you need any help, +here is a list of native speakers who participate the spring. Feel free to contact with any of them: * Maciej Fija?kowski ( fijall at gmail.com ) Added: pypy/extradoc/sprintinfo/wroclaw2009/people.txt ============================================================================== --- (empty file) +++ pypy/extradoc/sprintinfo/wroclaw2009/people.txt Sun Jan 11 01:53:10 2009 @@ -0,0 +1,54 @@ +People coming to the PyPy sprint 7-14th of February, 2009 +===================================================================== + +People who have a ``?`` in their arrive/depart or accomodation +column are known to be coming but there are no details +available yet from them. + +==================== ============== ============================ + Name Arrive/Depart Accomodation +==================== ============== ============================ + +==================== ============== ============================ + +People on the following list were present at previous sprints: + +==================== ============== ===================== + Name Arrive/Depart Accomodation +==================== ============== ===================== +Antonio Cuni ? ? +Holger Krekel ? ? +Maciej Fijalkowski ? ? +Jakub Gustak ? ? +Stephan Diehl ? ? +Samuele Pedroni ? ? +Carl Friedrich Bolz ? ? +Alexander Schremmer ? ? +Holger Krekel ? ? +Toon Verwaest ? ? +Camillo Bruni ? ? +Christian Tismer ? ? +Michael Hudson ? ? +Anders Lehmann ? ? +Niklaus Haldimann ? ? +Lene Wagner ? ? +Amaury Forgeot d'Arc ? ? +Valentino Volonghi ? ? +Boris Feigin ? ? +Andrew Thompson ? ? +Bert Freudenberg ? ? +Beatrice Duering ? ? +Richard Emslie ? ? +Johan Hahn ? ? +Niko Matsakis ? ? +Anders Chrigstroem ? ? +Eric van Riet Paap ? ? +Jacob Hallen ? ? +Laura Creighton ? ? +Guido Wesdorp ? ? +Leonardo Santagada ? ? +Alexandre Fayolle ? ? +Sylvain Th?nault ? ? +Toby Watson ? ? +Paul deGrandis ? ? +==================== ============== ===================== From fijal at codespeak.net Sun Jan 11 14:04:30 2009 From: fijal at codespeak.net (fijal at codespeak.net) Date: Sun, 11 Jan 2009 14:04:30 +0100 (CET) Subject: [pypy-svn] r60890 - pypy/branch/oo-jit/pypy/jit/codegen/i386 Message-ID: <20090111130430.1C24816844A@codespeak.net> Author: fijal Date: Sun Jan 11 14:04:28 2009 New Revision: 60890 Modified: pypy/branch/oo-jit/pypy/jit/codegen/i386/ri386.py Log: A tiny fix for prebuilt imms Modified: pypy/branch/oo-jit/pypy/jit/codegen/i386/ri386.py ============================================================================== --- pypy/branch/oo-jit/pypy/jit/codegen/i386/ri386.py (original) +++ pypy/branch/oo-jit/pypy/jit/codegen/i386/ri386.py Sun Jan 11 14:04:28 2009 @@ -1,5 +1,5 @@ from pypy.rlib.rarithmetic import intmask - +from pypy.rlib.objectmodel import ComputedIntSymbolic class OPERAND(object): _attrs_ = [] @@ -244,6 +244,9 @@ rel32 = REL32 def imm(value): + if isinstance(value, ComputedIntSymbolic): + value = value.compute_fn() + assert isinstance(value, int) if single_byte(value): return imm8(value) else: From pedronis at codespeak.net Sun Jan 11 23:12:48 2009 From: pedronis at codespeak.net (pedronis at codespeak.net) Date: Sun, 11 Jan 2009 23:12:48 +0100 (CET) Subject: [pypy-svn] r60892 - in pypy/build/testrunner: . test Message-ID: <20090111221248.ABB84168432@codespeak.net> Author: pedronis Date: Sun Jan 11 23:12:46 2009 New Revision: 60892 Modified: pypy/build/testrunner/runner.py pypy/build/testrunner/test/test_runner.py Log: trying to avoid double line endings in the web pages of logs produced on windows Modified: pypy/build/testrunner/runner.py ============================================================================== --- pypy/build/testrunner/runner.py (original) +++ pypy/build/testrunner/runner.py Sun Jan 11 23:12:46 2009 @@ -17,12 +17,17 @@ win32api.CloseHandle(proch) except pywintypes.error, e: pass + + READ_MODE = 'rU' + WRITE_MODE = 'wb' else: def _kill(pid, sig): try: os.kill(pid, sig) except OSError: pass + READ_MODE = 'r' + WRITE_MODE = 'w' EXECUTEFAILED = -1001 RUNFAILED = -1000 @@ -144,11 +149,11 @@ exitcode = EXECUTEFAILED if one_output.check(file=1): - output = one_output.read() + output = one_output.read(READ_MODE) else: output = "" if logfname.check(file=1): - logdata = logfname.read() + logdata = logfname.read(READ_MODE) else: logdata = "" @@ -293,11 +298,11 @@ print "no logfile specified" sys.exit(2) - logfile = open(opts.logfile, "w") + logfile = open(opts.logfile, WRITE_MODE) if opts.output == '-': out = sys.stdout else: - out = open(opts.output, "w") + out = open(opts.output, WRITE_MODE) root = py.path.local(opts.root) Modified: pypy/build/testrunner/test/test_runner.py ============================================================================== --- pypy/build/testrunner/test/test_runner.py (original) +++ pypy/build/testrunner/test/test_runner.py Sun Jan 11 23:12:46 2009 @@ -169,9 +169,15 @@ assert res - assert out.getvalue() - - log_lines = log.getvalue().splitlines() + out = out.getvalue() + assert out + assert '\r\n' not in out + assert '\n' in out + + log = log.getvalue() + assert '\r\n' not in log + assert '\n' in log + log_lines = log.splitlines() assert log_lines[0] == ". test_normal/test_example.py:test_one" nfailures = 0 From pedronis at codespeak.net Sun Jan 11 23:31:35 2009 From: pedronis at codespeak.net (pedronis at codespeak.net) Date: Sun, 11 Jan 2009 23:31:35 +0100 (CET) Subject: [pypy-svn] r60893 - in pypy/build/bot2/pypybuildbot: . test Message-ID: <20090111223135.A69B6168428@codespeak.net> Author: pedronis Date: Sun Jan 11 23:31:34 2009 New Revision: 60893 Modified: pypy/build/bot2/pypybuildbot/summary.py pypy/build/bot2/pypybuildbot/test/test_summary.py Log: try to support tracebacks with non-ascii in them (utf-8 or latin-1) Modified: pypy/build/bot2/pypybuildbot/summary.py ============================================================================== --- pypy/build/bot2/pypybuildbot/summary.py (original) +++ pypy/build/bot2/pypybuildbot/summary.py Sun Jan 11 23:31:34 2009 @@ -54,6 +54,11 @@ self.failed.add(namekey) if longrepr: + try: + longrepr = longrepr.decode("utf-8") + except UnicodeDecodeError: + longrepr = longrepr.decode("latin-1") + self.longreprs[namekey] = longrepr @property Modified: pypy/build/bot2/pypybuildbot/test/test_summary.py ============================================================================== --- pypy/build/bot2/pypybuildbot/test/test_summary.py (original) +++ pypy/build/bot2/pypybuildbot/test/test_summary.py Sun Jan 11 23:31:34 2009 @@ -69,6 +69,24 @@ res = rev_outcome_set.get_longrepr(("a.b", "test_one")) assert res == "some\ntraceback\n" + def test_populate_encodings(self): + rev_outcome_set = summary.RevisionOutcomeSet(50000) + log = StringIO("""F a/b.py:test_one + \xe5 foo +F a/b.py:test_two + \xc3\xa5 bar +""") + + rev_outcome_set.populate(log) + + assert len(rev_outcome_set.failed) == 2 + assert rev_outcome_set.numpassed == 0 + + assert rev_outcome_set.longreprs == { +("a.b","test_one"): u"\xe5 foo\n", +("a.b", "test_two"): u"\xe5 bar\n" + } + def test_populate_special(self): rev_outcome_set = summary.RevisionOutcomeSet(50000) log = StringIO("""F a/b.py From pedronis at codespeak.net Mon Jan 12 01:39:55 2009 From: pedronis at codespeak.net (pedronis at codespeak.net) Date: Mon, 12 Jan 2009 01:39:55 +0100 (CET) Subject: [pypy-svn] r60897 - in pypy/build/bot2/pypybuildbot: . test Message-ID: <20090112003955.D73531683F9@codespeak.net> Author: pedronis Date: Mon Jan 12 01:39:53 2009 New Revision: 60897 Modified: pypy/build/bot2/pypybuildbot/summary.py pypy/build/bot2/pypybuildbot/test/test_summary.py Log: tentative support for disambiguating multiple repos, avoiding implicitly named trunk in the summary Modified: pypy/build/bot2/pypybuildbot/summary.py ============================================================================== --- pypy/build/bot2/pypybuildbot/summary.py (original) +++ pypy/build/bot2/pypybuildbot/summary.py Mon Jan 12 01:39:53 2009 @@ -497,6 +497,7 @@ def __init__(self): HtmlResource.__init__(self) self.putChild('longrepr', LongRepr()) + self._defaultBranchCache = {} def getTitle(self, request): status = self.getStatus(request) @@ -509,6 +510,30 @@ for rev in sorted(runs.keys())[:-cutnum]: del runs[rev] + def _fish_defaultBranch(self, status, builderName): + try: + return self._defaultBranchCache[builderName] + except KeyError: + pass + builder = status.botmaster.builders[builderName] + branch = None + for _, kw in builder.buildFactory.steps: + if 'defaultBranch' in kw: + if kw.get('explicitBranch'): + branch = kw['defaultBranch'] + break + self._defaultBranchCache[builderName] = branch + return branch + + def _get_branch(self, status, build): + branch = getProp(build, 'explicitBranch') + # fish + if branch is None: + builderName = build.getBuilder().getName() + branch = self._fish_defaultBranch(status, builderName) + branch = branch or getProp(build, 'branch') + return branch + def recentRuns(self, status, only_recentrevs=None, only_branches=None, only_builder=None, only_builds=None): test_rev = make_test(only_recentrevs) @@ -533,7 +558,7 @@ builditer = builderStatus.generateFinishedBuilds(num_builds=5*N) for build in builditer: - branch = getProp(build, 'branch') + branch = self._get_branch(status, build) if not test_branch(branch): continue got_rev = getProp(build, 'got_revision', None) Modified: pypy/build/bot2/pypybuildbot/test/test_summary.py ============================================================================== --- pypy/build/bot2/pypybuildbot/test/test_summary.py (original) +++ pypy/build/bot2/pypybuildbot/test/test_summary.py Mon Jan 12 01:39:53 2009 @@ -1,6 +1,8 @@ from zope.interface import implements from buildbot import interfaces as buildbot_intefaces from buildbot.status import builder as status_builder +from buildbot.process import builder as process_builder +from buildbot.process import factory as process_factory from pypybuildbot import summary from StringIO import StringIO import re @@ -267,10 +269,11 @@ res = summary.show_elapsed(90*60) assert res == "1h30" -class _BuilderToStatus(object): +def _BuilderToStatus(status): - def __init__(self, status): - self.builder_status = status + setup = {'name': 'builder', 'builddir': 'BUILDDIR', + 'factory': process_factory.BuildFactory() } + return process_builder.Builder(setup, status) class FakeRequest(object): From fijal at codespeak.net Mon Jan 12 01:49:27 2009 From: fijal at codespeak.net (fijal at codespeak.net) Date: Mon, 12 Jan 2009 01:49:27 +0100 (CET) Subject: [pypy-svn] r60898 - pypy/trunk/pypy Message-ID: <20090112004927.9C4F916841F@codespeak.net> Author: fijal Date: Mon Jan 12 01:49:26 2009 New Revision: 60898 Modified: pypy/trunk/pypy/conftest.py Log: two trivial methods Modified: pypy/trunk/pypy/conftest.py ============================================================================== --- pypy/trunk/pypy/conftest.py (original) +++ pypy/trunk/pypy/conftest.py Mon Jan 12 01:49:26 2009 @@ -143,6 +143,12 @@ def call_method(self, obj, name, *args, **kwds): return getattr(obj, name)(*args, **kwds) + def getattr(self, obj, name): + return getattr(obj, name) + + def setattr(self, obj, name, value): + setattr(obj, name, value) + def translation_test_so_skip_if_appdirect(): if option.runappdirect: py.test.skip("translation test, skipped for appdirect") From fijal at codespeak.net Mon Jan 12 11:22:06 2009 From: fijal at codespeak.net (fijal at codespeak.net) Date: Mon, 12 Jan 2009 11:22:06 +0100 (CET) Subject: [pypy-svn] r60899 - pypy/trunk/pypy/module/sys Message-ID: <20090112102206.885AC168416@codespeak.net> Author: fijal Date: Mon Jan 12 11:22:03 2009 New Revision: 60899 Modified: pypy/trunk/pypy/module/sys/version.py Log: issue420 resolved (santagada) adapt a bit for cpython's sys.version Modified: pypy/trunk/pypy/module/sys/version.py ============================================================================== --- pypy/trunk/pypy/module/sys/version.py (original) +++ pypy/trunk/pypy/module/sys/version.py Mon Jan 12 11:22:03 2009 @@ -20,6 +20,12 @@ pypydir = os.path.dirname(os.path.abspath(pypy.__file__)) del pypy +import time as t +gmtime = t.gmtime() +date = t.strftime("%b %d %Y", gmtime) +time = t.strftime("%H:%M:%S", gmtime) +del t + # ____________________________________________________________ def get_api_version(space): @@ -29,14 +35,16 @@ return space.wrap(CPYTHON_VERSION) def get_version(space): - return space.wrap("Python %d.%d.%d (pypy %d.%d.%d build %d)" % ( + return space.wrap("%d.%d.%d (%d, %s, %s) \n[PyPy %d.%d.%d]" % ( CPYTHON_VERSION[0], CPYTHON_VERSION[1], CPYTHON_VERSION[2], + svn_revision(), + date, + time, PYPY_VERSION[0], PYPY_VERSION[1], - PYPY_VERSION[2], - svn_revision())) + PYPY_VERSION[2])) def get_hexversion(space): return space.wrap(tuple2hex(CPYTHON_VERSION)) From arigo at codespeak.net Mon Jan 12 11:38:08 2009 From: arigo at codespeak.net (arigo at codespeak.net) Date: Mon, 12 Jan 2009 11:38:08 +0100 (CET) Subject: [pypy-svn] r60900 - in pypy/branch/oo-jit/pypy/translator/c: . src Message-ID: <20090112103808.E40E516841F@codespeak.net> Author: arigo Date: Mon Jan 12 11:38:08 2009 New Revision: 60900 Modified: pypy/branch/oo-jit/pypy/translator/c/funcgen.py pypy/branch/oo-jit/pypy/translator/c/src/rtyper.h pypy/branch/oo-jit/pypy/translator/c/src/support.h Log: Fix debug_print of strings, broken now that the RPython strings are no longer zero-terminated. Requires copying the RPython strings into a non-movable, zero-terminated buffer. Modified: pypy/branch/oo-jit/pypy/translator/c/funcgen.py ============================================================================== --- pypy/branch/oo-jit/pypy/translator/c/funcgen.py (original) +++ pypy/branch/oo-jit/pypy/translator/c/funcgen.py Mon Jan 12 11:38:08 2009 @@ -714,7 +714,7 @@ format.append(''.join(arg.value.chars).replace('%', '%%')) else: format.append('%s') - argv.append('RPyString_AsString(%s)' % self.expr(arg)) + argv.append('RPyString_AsCharP(%s)' % self.expr(arg)) continue elif T == Signed: format.append('%ld') @@ -747,7 +747,7 @@ format.append(msg.replace('%', '%%')) continue argv.append(self.expr(arg)) - return "fprintf(stderr, %s%s);" % ( + return "fprintf(stderr, %s%s); RPyString_FreeCache();" % ( c_string_constant(' '.join(format) + '\n\000'), ''.join([', ' + s for s in argv])) Modified: pypy/branch/oo-jit/pypy/translator/c/src/rtyper.h ============================================================================== --- pypy/branch/oo-jit/pypy/translator/c/src/rtyper.h (original) +++ pypy/branch/oo-jit/pypy/translator/c/src/rtyper.h Mon Jan 12 11:38:08 2009 @@ -5,11 +5,12 @@ #define RPyString_Size(rps) ((rps)->rs_chars.length) -#define RPyString_AsString(rps) ((rps)->rs_chars.items) /* prototypes */ +char *RPyString_AsCharP(RPyString *rps); +void RPyString_FreeCache(void); RPyString *RPyString_FromString(char *buf); @@ -17,11 +18,39 @@ #ifndef PYPY_NOT_MAIN_FILE +struct _RPyString_dump_t { + struct _RPyString_dump_t *next; + char data[1]; +} *_RPyString_dump = NULL; + +char *RPyString_AsCharP(RPyString *rps) +{ + long len = RPyString_Size(rps); + struct _RPyString_dump_t *dump = \ + malloc(sizeof(struct _RPyString_dump_t) + len); + if (!dump) + return "(out of memory!)"; + dump->next = _RPyString_dump; + _RPyString_dump = dump; + memcpy(dump->data, rps->rs_chars.items, len); + dump->data[len] = 0; + return dump->data; +} + +void RPyString_FreeCache(void) +{ + while (_RPyString_dump) { + struct _RPyString_dump_t *dump = _RPyString_dump; + _RPyString_dump = dump->next; + free(dump); + } +} + RPyString *RPyString_FromString(char *buf) { int length = strlen(buf); RPyString *rps = RPyString_New(length); - memcpy(RPyString_AsString(rps), buf, length); + memcpy(rps->rs_chars.items, buf, length); return rps; } Modified: pypy/branch/oo-jit/pypy/translator/c/src/support.h ============================================================================== --- pypy/branch/oo-jit/pypy/translator/c/src/support.h (original) +++ pypy/branch/oo-jit/pypy/translator/c/src/support.h Mon Jan 12 11:38:08 2009 @@ -20,12 +20,12 @@ #define FAIL_ZER(msg) FAIL_EXCEPTION(PyExc_ZeroDivisionError, msg) #define CFAIL() RPyConvertExceptionFromCPython() -#define PyString_FromRPyString(rpystr) \ - PyString_FromStringAndSize(RPyString_AsString(rpystr), RPyString_Size(rpystr)) +/* #define PyString_FromRPyString(rpystr) \ */ +/* PyString_FromStringAndSize(RPyString_AsString(rpystr), RPyString_Size(rpystr)) */ -#define PyString_ToRPyString(s, rpystr) \ - memcpy(RPyString_AsString(rpystr), PyString_AS_STRING(s), \ - RPyString_Size(rpystr)) +/* #define PyString_ToRPyString(s, rpystr) \ */ +/* memcpy(RPyString_AsString(rpystr), PyString_AS_STRING(s), \ */ +/* RPyString_Size(rpystr)) */ /* Extra checks can be enabled with the RPY_ASSERT or RPY_LL_ASSERT * macros. They differ in the level at which the tests are made. From pedronis at codespeak.net Mon Jan 12 14:11:25 2009 From: pedronis at codespeak.net (pedronis at codespeak.net) Date: Mon, 12 Jan 2009 14:11:25 +0100 (CET) Subject: [pypy-svn] r60901 - pypy/extradoc/sprintinfo/wroclaw2009 Message-ID: <20090112131125.E658F168454@codespeak.net> Author: pedronis Date: Mon Jan 12 14:11:24 2009 New Revision: 60901 Modified: pypy/extradoc/sprintinfo/wroclaw2009/announcement.txt Log: typo Modified: pypy/extradoc/sprintinfo/wroclaw2009/announcement.txt ============================================================================== --- pypy/extradoc/sprintinfo/wroclaw2009/announcement.txt (original) +++ pypy/extradoc/sprintinfo/wroclaw2009/announcement.txt Mon Jan 12 14:11:24 2009 @@ -20,7 +20,7 @@ Official language in Poland is polish. There shouldn't be any problem with english at all (especially during hotel booking etc) but if you need any help, -here is a list of native speakers who participate the spring. Feel free +here is a list of native speakers who participate in the sprint. Feel free to contact with any of them: * Maciej Fija?kowski ( fijall at gmail.com ) From fijal at codespeak.net Mon Jan 12 15:59:19 2009 From: fijal at codespeak.net (fijal at codespeak.net) Date: Mon, 12 Jan 2009 15:59:19 +0100 (CET) Subject: [pypy-svn] r60902 - pypy/extradoc/talk/wroclaw2009 Message-ID: <20090112145919.87A411683EE@codespeak.net> Author: fijal Date: Mon Jan 12 15:59:17 2009 New Revision: 60902 Modified: pypy/extradoc/talk/wroclaw2009/abstract.txt Log: Make it run on top of pypy-c (well, not really...) Modified: pypy/extradoc/talk/wroclaw2009/abstract.txt ============================================================================== --- pypy/extradoc/talk/wroclaw2009/abstract.txt (original) +++ pypy/extradoc/talk/wroclaw2009/abstract.txt Mon Jan 12 15:59:17 2009 @@ -1,3 +1,19 @@ + +XXX: wstawic polskie literki + +========================================================================== +PyPy - nowe podejscie do tworzenia maszyn wirtualnych jezykow dynamicznych +========================================================================== + +Data: 22.I.2008 +--------------- + +Miejsce: XXX sala +----------------- + +Prelegent: Maciej Fijalkowski +----------------------------- + PyPy - interpreter pythona napisany w pythonie. Celem projektu jest dostarczenie lepszego i szybszego interpretera pythona ni? CPython, jednocze?nie nie u?ywaj?c C ani ?adnego niskopoziomowego j?zyka. @@ -5,13 +21,31 @@ interpretera pythona, wysokopoziomowy rzut oka na architektur? oraz na mo?liwo?ci szybkiej interpretacji dynamicznych j?zyk?w. Jednym z ciekawszych aspekt?w b?dzie prezentacja dynamicznej kompilacji pythona -(JIT - just in time compilation), kt?ra sama napisana jest w pythonie. +(*JIT* - just in time compilation), kt?ra sama napisana jest w pythonie. Prezentacja nie zak?ada uprzedniej znajomo?ci pythona i jest skierowana do wszystkich zainteresowanych implementacj? dynamicznych jezyk?w. W dniach 7-14 lutego odb?dzie si? na terenie Politechniki Wroclawskiej -sprint PyPy. Sprint jest to kr?tka (w tym wypadku tydzie?) sesja intensywnego +sprint PyPy. *Sprint( jest to kr?tka (w tym wypadku tydzie?) sesja intensywnego programowania, cz?sto w wykonaniu pair programming. Jest to r?wnie? wy?mienita okazja do spotkania z developerami i wdro?enia si? do projektu. Lokalizacja sprintu, Zintegrowane Centrum Studenckie, Wybrze?e Wyspia?skiego 23-25, budynek C-13, sala 3.01. + +XXX: skopiowac BIO z merlinux.de + +Linki: +------ + +PyPy - http://codespeak.net/pypy +blog - http://morepypy.blogspot.com +Sprint - http://en.wikipedia.org/wiki/Hackathon#Sprints +JIT - http://en.wikipedia.org/wiki/Just-in-time_compilation + +Wiecej do czytania: +------------------- + +psyco - Just in time compiler dla pythona, projekt poprzedzajacy PyPy, +tworzony przez tych samych ludzi: http://psyco.sourceforge.net/ + +XXX linki do papierow o tracing JIT, chyba nie.... From fijal at codespeak.net Mon Jan 12 16:06:58 2009 From: fijal at codespeak.net (fijal at codespeak.net) Date: Mon, 12 Jan 2009 16:06:58 +0100 (CET) Subject: [pypy-svn] r60903 - pypy/extradoc/sprintinfo/wroclaw2009 Message-ID: <20090112150658.16A7116841F@codespeak.net> Author: fijal Date: Mon Jan 12 16:06:57 2009 New Revision: 60903 Modified: pypy/extradoc/sprintinfo/wroclaw2009/announcement.txt Log: some update Modified: pypy/extradoc/sprintinfo/wroclaw2009/announcement.txt ============================================================================== --- pypy/extradoc/sprintinfo/wroclaw2009/announcement.txt (original) +++ pypy/extradoc/sprintinfo/wroclaw2009/announcement.txt Mon Jan 12 16:06:57 2009 @@ -2,6 +2,14 @@ Wroc?aw PyPy sprint 7-14th February, 2009 ======================================================== +The next PyPy sprint will be held in Wroc?aw, Poland. This is fully public +sprint and all newcomers are welcomed. Preceeding the sprint there +will be a talk at University of Technology in Warsaw held at 22nd of January. + +Worth noting is that this is a perfect time and place to go cross country +skiing either before or after sprint, so if anyone wants to participate in +such activity, we can organize something. + -------- Location -------- @@ -44,6 +52,15 @@ http://codespeak.net/mailman/listinfo/pypy-sprint +------- +Flights +------- + +You can either fly directly to Wroclaw, with many international connections +(like one to Dortmund and one to Duesseldorf). Details are available on +airport's webpage: http://www.airport.wroclaw.pl/en/. You can also fly to: +Warsaw (5h by train), Berlin (6h by train) or Poznan (2h by train). + -------------------------------------- Preparation (if you feel it is needed) -------------------------------------- From getxsick at codespeak.net Mon Jan 12 17:04:01 2009 From: getxsick at codespeak.net (getxsick at codespeak.net) Date: Mon, 12 Jan 2009 17:04:01 +0100 (CET) Subject: [pypy-svn] r60904 - pypy/extradoc/sprintinfo/wroclaw2009 Message-ID: <20090112160401.9D9A31683EF@codespeak.net> Author: getxsick Date: Mon Jan 12 17:03:59 2009 New Revision: 60904 Modified: pypy/extradoc/sprintinfo/wroclaw2009/announcement.txt Log: typo Modified: pypy/extradoc/sprintinfo/wroclaw2009/announcement.txt ============================================================================== --- pypy/extradoc/sprintinfo/wroclaw2009/announcement.txt (original) +++ pypy/extradoc/sprintinfo/wroclaw2009/announcement.txt Mon Jan 12 17:03:59 2009 @@ -4,7 +4,7 @@ The next PyPy sprint will be held in Wroc?aw, Poland. This is fully public sprint and all newcomers are welcomed. Preceeding the sprint there -will be a talk at University of Technology in Warsaw held at 22nd of January. +will be a talk at University of Technology in Wroc?aw held at 22nd of January. Worth noting is that this is a perfect time and place to go cross country skiing either before or after sprint, so if anyone wants to participate in From getxsick at codespeak.net Mon Jan 12 17:06:13 2009 From: getxsick at codespeak.net (getxsick at codespeak.net) Date: Mon, 12 Jan 2009 17:06:13 +0100 (CET) Subject: [pypy-svn] r60905 - pypy/extradoc/sprintinfo/wroclaw2009 Message-ID: <20090112160613.439E316841C@codespeak.net> Author: getxsick Date: Mon Jan 12 17:06:12 2009 New Revision: 60905 Modified: pypy/extradoc/sprintinfo/wroclaw2009/announcement.txt Log: more info about flights Modified: pypy/extradoc/sprintinfo/wroclaw2009/announcement.txt ============================================================================== --- pypy/extradoc/sprintinfo/wroclaw2009/announcement.txt (original) +++ pypy/extradoc/sprintinfo/wroclaw2009/announcement.txt Mon Jan 12 17:06:12 2009 @@ -56,10 +56,11 @@ Flights ------- -You can either fly directly to Wroclaw, with many international connections +You can either fly directly to Wroc?aw, with many international connections (like one to Dortmund and one to Duesseldorf). Details are available on airport's webpage: http://www.airport.wroclaw.pl/en/. You can also fly to: -Warsaw (5h by train), Berlin (6h by train) or Poznan (2h by train). +Warsaw (5h by train), Berlin (6h by train), Poznan (2h by train), +Katowice (3h by train) or Krak?w (4h by train). -------------------------------------- Preparation (if you feel it is needed) From antocuni at codespeak.net Mon Jan 12 17:58:01 2009 From: antocuni at codespeak.net (antocuni at codespeak.net) Date: Mon, 12 Jan 2009 17:58:01 +0100 (CET) Subject: [pypy-svn] r60907 - pypy/trunk/lib-python/modified-2.5.2/test Message-ID: <20090112165801.1408B16842C@codespeak.net> Author: antocuni Date: Mon Jan 12 17:57:59 2009 New Revision: 60907 Modified: pypy/trunk/lib-python/modified-2.5.2/test/test_compile.py Log: (antocuni, arigato around) mark this test as impl detail, as pypy is less strict Modified: pypy/trunk/lib-python/modified-2.5.2/test/test_compile.py ============================================================================== --- pypy/trunk/lib-python/modified-2.5.2/test/test_compile.py (original) +++ pypy/trunk/lib-python/modified-2.5.2/test/test_compile.py Mon Jan 12 17:57:59 2009 @@ -2,6 +2,7 @@ import warnings import sys from test import test_support +from test.test_support import check_impl_detail class TestSpecifics(unittest.TestCase): @@ -76,12 +77,13 @@ self.assertEqual(m.results, ('z', g)) exec 'z = locals()' in g, m self.assertEqual(m.results, ('z', m)) - try: - exec 'z = b' in m - except NameError: - pass - else: - self.fail('PyPy should accept not real dict globals ') + if check_impl_detail: + try: + exec 'z = b' in m + except TypeError: + pass + else: + self.fail('Did not validate globals as a real dict') class A: "Non-mapping" From getxsick at codespeak.net Mon Jan 12 22:25:40 2009 From: getxsick at codespeak.net (getxsick at codespeak.net) Date: Mon, 12 Jan 2009 22:25:40 +0100 (CET) Subject: [pypy-svn] r60908 - pypy/extradoc/talk/wroclaw2009 Message-ID: <20090112212540.28438168423@codespeak.net> Author: getxsick Date: Mon Jan 12 22:25:38 2009 New Revision: 60908 Modified: pypy/extradoc/talk/wroclaw2009/abstract.txt Log: update info Modified: pypy/extradoc/talk/wroclaw2009/abstract.txt ============================================================================== --- pypy/extradoc/talk/wroclaw2009/abstract.txt (original) +++ pypy/extradoc/talk/wroclaw2009/abstract.txt Mon Jan 12 22:25:38 2009 @@ -1,17 +1,14 @@ - -XXX: wstawic polskie literki - ========================================================================== -PyPy - nowe podejscie do tworzenia maszyn wirtualnych jezykow dynamicznych +PyPy - nowe podej?cie do tworzenia maszyn wirtualnych j?zyk?w dynamicznych ========================================================================== -Data: 22.I.2008 ---------------- +Data: 22.I.2008 19:00 +--------------------- -Miejsce: XXX sala ------------------ +Miejsce: Politechnika Wroc?awska, budynek C-13, sala 0.31 +--------------------------------------------------------- -Prelegent: Maciej Fijalkowski +Prelegent: Maciej Fija?kowski ----------------------------- PyPy - interpreter pythona napisany w pythonie. Celem projektu jest @@ -26,13 +23,18 @@ do wszystkich zainteresowanych implementacj? dynamicznych jezyk?w. W dniach 7-14 lutego odb?dzie si? na terenie Politechniki Wroclawskiej -sprint PyPy. *Sprint( jest to kr?tka (w tym wypadku tydzie?) sesja intensywnego -programowania, cz?sto w wykonaniu pair programming. Jest to r?wnie? -wy?mienita okazja do spotkania z developerami i wdro?enia si? do projektu. -Lokalizacja sprintu, Zintegrowane Centrum Studenckie, Wybrze?e -Wyspia?skiego 23-25, budynek C-13, sala 3.01. +sprint PyPy. *Sprint* - jest to kr?tka (w tym wypadku tydzie?) sesja +intensywnego programowania, cz?sto w wykonaniu pair programming. Jest +to r?wnie? wy?mienita okazja do spotkania z developerami i wdro?enia si? +do projektu. Lokalizacja sprintu, Politechnika Wroc?awska, Zintegrowane +Centrum Studenckie, Wybrze?e Wyspia?skiego 23-25, budynek C-13, sala 3.01. + +Maciej Fija?kowski: +------------------- -XXX: skopiowac BIO z merlinux.de +Maciek jest core developerem projektu PyPy. Uczestniczy i rozwija wiele +aspekt?w zwi?zanych z projektem. Jest pracownikiem Merlinux GmbH od +2006 roku. Maciek ma tak?e du?y wk?ad w bibliotek? py.test. Linki: ------ From fijal at codespeak.net Mon Jan 12 22:29:51 2009 From: fijal at codespeak.net (fijal at codespeak.net) Date: Mon, 12 Jan 2009 22:29:51 +0100 (CET) Subject: [pypy-svn] r60909 - pypy/extradoc/talk/wroclaw2009 Message-ID: <20090112212951.6C682168425@codespeak.net> Author: fijal Date: Mon Jan 12 22:29:50 2009 New Revision: 60909 Modified: pypy/extradoc/talk/wroclaw2009/abstract.txt Log: shameless self-ad Modified: pypy/extradoc/talk/wroclaw2009/abstract.txt ============================================================================== --- pypy/extradoc/talk/wroclaw2009/abstract.txt (original) +++ pypy/extradoc/talk/wroclaw2009/abstract.txt Mon Jan 12 22:29:50 2009 @@ -32,9 +32,9 @@ Maciej Fija?kowski: ------------------- -Maciek jest core developerem projektu PyPy. Uczestniczy i rozwija wiele -aspekt?w zwi?zanych z projektem. Jest pracownikiem Merlinux GmbH od -2006 roku. Maciek ma tak?e du?y wk?ad w bibliotek? py.test. +Maciej jest core developerem projektu PyPy. Uczestniczy i rozwija wiele +aspekt?w zwi?zanych z projektem. Wyglaszal wyklady na wielu miedzynarodowych +konferencjach pythonowych, miedzy innymi PyCon, RuPy czy EuroPython. Linki: ------ @@ -49,5 +49,3 @@ psyco - Just in time compiler dla pythona, projekt poprzedzajacy PyPy, tworzony przez tych samych ludzi: http://psyco.sourceforge.net/ - -XXX linki do papierow o tracing JIT, chyba nie.... From getxsick at codespeak.net Tue Jan 13 01:08:00 2009 From: getxsick at codespeak.net (getxsick at codespeak.net) Date: Tue, 13 Jan 2009 01:08:00 +0100 (CET) Subject: [pypy-svn] r60911 - pypy/extradoc/talk/wroclaw2009 Message-ID: <20090113000800.A94EF1683E4@codespeak.net> Author: getxsick Date: Tue Jan 13 01:07:58 2009 New Revision: 60911 Modified: pypy/extradoc/talk/wroclaw2009/abstract.txt Log: added polish characters Modified: pypy/extradoc/talk/wroclaw2009/abstract.txt ============================================================================== --- pypy/extradoc/talk/wroclaw2009/abstract.txt (original) +++ pypy/extradoc/talk/wroclaw2009/abstract.txt Tue Jan 13 01:07:58 2009 @@ -33,8 +33,8 @@ ------------------- Maciej jest core developerem projektu PyPy. Uczestniczy i rozwija wiele -aspekt?w zwi?zanych z projektem. Wyglaszal wyklady na wielu miedzynarodowych -konferencjach pythonowych, miedzy innymi PyCon, RuPy czy EuroPython. +aspekt?w zwi?zanych z projektem. Wyg?asza? wyk?ady na wielu mi?dzynarodowych +konferencjach pythonowych, mi?dzy innymi PyCon, RuPy czy EuroPython. Linki: ------ @@ -44,8 +44,8 @@ Sprint - http://en.wikipedia.org/wiki/Hackathon#Sprints JIT - http://en.wikipedia.org/wiki/Just-in-time_compilation -Wiecej do czytania: +Wi?cej do czytania: ------------------- -psyco - Just in time compiler dla pythona, projekt poprzedzajacy PyPy, +psyco - Just in time compiler dla pythona, projekt poprzedzaj?cy PyPy, tworzony przez tych samych ludzi: http://psyco.sourceforge.net/ From antocuni at codespeak.net Tue Jan 13 14:20:34 2009 From: antocuni at codespeak.net (antocuni at codespeak.net) Date: Tue, 13 Jan 2009 14:20:34 +0100 (CET) Subject: [pypy-svn] r60915 - in pypy/trunk/pypy: interpreter/astcompiler module/__builtin__/test Message-ID: <20090113132034.68C481683E5@codespeak.net> Author: antocuni Date: Tue Jan 13 14:20:32 2009 New Revision: 60915 Modified: pypy/trunk/pypy/interpreter/astcompiler/pycodegen.py pypy/trunk/pypy/module/__builtin__/test/test_builtin.py Log: a failing test and the corresponding fix. I don't really understand why the code called SET_LINENO, but since it's in the compiler I assume it was bogus :-). Tests passes, this should fix a failure in lib-python/test_compile Modified: pypy/trunk/pypy/interpreter/astcompiler/pycodegen.py ============================================================================== --- pypy/trunk/pypy/interpreter/astcompiler/pycodegen.py (original) +++ pypy/trunk/pypy/interpreter/astcompiler/pycodegen.py Tue Jan 13 14:20:32 2009 @@ -265,7 +265,6 @@ self.parseSymbols(node) assert node.scope is not None self.scope = node.scope - self.emitop_int('SET_LINENO', 0) if not space.is_w(node.w_doc, space.w_None): self.setDocstring(node.w_doc) self.set_lineno(node) Modified: pypy/trunk/pypy/module/__builtin__/test/test_builtin.py ============================================================================== --- pypy/trunk/pypy/module/__builtin__/test/test_builtin.py (original) +++ pypy/trunk/pypy/module/__builtin__/test/test_builtin.py Tue Jan 13 14:20:32 2009 @@ -473,6 +473,14 @@ raises(TypeError, hasattr, x, 42) raises(UnicodeError, hasattr, x, u'\u5678') # cannot encode attr name + def test_compile_leading_newlines(self): + src = """ +def fn(): pass +""" + co = compile(src, 'mymod', 'exec') + firstlineno = co.co_firstlineno + assert firstlineno == 2 + class AppTestBuiltinOptimized(object): def setup_class(cls): from pypy.conftest import gettestobjspace @@ -528,7 +536,7 @@ exec s in ns res = ns["test"]([2,3,4]) assert res == 18 - + class TestInternal: From antocuni at codespeak.net Tue Jan 13 14:36:59 2009 From: antocuni at codespeak.net (antocuni at codespeak.net) Date: Tue, 13 Jan 2009 14:36:59 +0100 (CET) Subject: [pypy-svn] r60916 - pypy/trunk/lib-python/modified-2.5.2/test Message-ID: <20090113133659.602B7168495@codespeak.net> Author: antocuni Date: Tue Jan 13 14:36:58 2009 New Revision: 60916 Modified: pypy/trunk/lib-python/modified-2.5.2/test/test_compile.py Log: (antocuni, arigo and cfbolz around) mark this as an impl detail Modified: pypy/trunk/lib-python/modified-2.5.2/test/test_compile.py ============================================================================== --- pypy/trunk/lib-python/modified-2.5.2/test/test_compile.py (original) +++ pypy/trunk/lib-python/modified-2.5.2/test/test_compile.py Tue Jan 13 14:36:58 2009 @@ -2,7 +2,7 @@ import warnings import sys from test import test_support -from test.test_support import check_impl_detail +from test.test_support import check_impl_detail, impl_detail class TestSpecifics(unittest.TestCase): @@ -38,6 +38,7 @@ def test_syntax_error(self): self.assertRaises(SyntaxError, compile, "1+*3", "filename", "exec") + @impl_detail() def test_none_keyword_arg(self): self.assertRaises(SyntaxError, compile, "f(None=1)", "", "exec") From antocuni at codespeak.net Tue Jan 13 15:21:56 2009 From: antocuni at codespeak.net (antocuni at codespeak.net) Date: Tue, 13 Jan 2009 15:21:56 +0100 (CET) Subject: [pypy-svn] r60917 - in pypy/trunk/pypy/interpreter/astcompiler: . test Message-ID: <20090113142156.6E3A11684B5@codespeak.net> Author: antocuni Date: Tue Jan 13 15:21:54 2009 New Revision: 60917 Modified: pypy/trunk/pypy/interpreter/astcompiler/opt.py pypy/trunk/pypy/interpreter/astcompiler/test/test_compiler.py Log: a bit of hack to make sure that -2147483648 is of type int, not long Modified: pypy/trunk/pypy/interpreter/astcompiler/opt.py ============================================================================== --- pypy/trunk/pypy/interpreter/astcompiler/opt.py (original) +++ pypy/trunk/pypy/interpreter/astcompiler/opt.py Tue Jan 13 15:21:54 2009 @@ -88,10 +88,15 @@ return node def _visitUnaryOp(self, node, constant_fold): + import sys expr = node.expr if isinstance(expr, ast.Const): try: w_newvalue = constant_fold(self.space, expr.value) + # special case for -x, where x is -sys.maxint + w_minint = self.space.wrap(-sys.maxint-1) + if self.space.eq_w(w_newvalue, w_minint): + w_newvalue = w_minint # be sure it's of type 'int', not 'long' except OperationError: pass else: Modified: pypy/trunk/pypy/interpreter/astcompiler/test/test_compiler.py ============================================================================== --- pypy/trunk/pypy/interpreter/astcompiler/test/test_compiler.py (original) +++ pypy/trunk/pypy/interpreter/astcompiler/test/test_compiler.py Tue Jan 13 15:21:54 2009 @@ -67,6 +67,11 @@ for c in expressions.constants: yield (self.simple_test, "x="+c, "x", eval(c)) + def test_neg_sys_maxint(self): + import sys + stmt = "x = %s" % (-sys.maxint-1) + self.simple_test(stmt, "type(x)", int) + def test_tuple_assign(self): yield self.simple_test, "x,= 1,", "x", 1 yield self.simple_test, "x,y = 1,2", "x,y", (1, 2) @@ -625,4 +630,3 @@ """) decl = str(decl) + '\n' yield self.simple_test, decl, 'r', None - From arigo at codespeak.net Tue Jan 13 15:45:01 2009 From: arigo at codespeak.net (arigo at codespeak.net) Date: Tue, 13 Jan 2009 15:45:01 +0100 (CET) Subject: [pypy-svn] r60919 - pypy/trunk/lib-python/modified-2.5.2/test Message-ID: <20090113144501.157C61684D3@codespeak.net> Author: arigo Date: Tue Jan 13 15:45:00 2009 New Revision: 60919 Modified: pypy/trunk/lib-python/modified-2.5.2/test/string_tests.py pypy/trunk/lib-python/modified-2.5.2/test/test_coercion.py pypy/trunk/lib-python/modified-2.5.2/test/test_compile.py pypy/trunk/lib-python/modified-2.5.2/test/test_descr.py pypy/trunk/lib-python/modified-2.5.2/test/test_format.py pypy/trunk/lib-python/modified-2.5.2/test/test_import.py pypy/trunk/lib-python/modified-2.5.2/test/test_itertools.py pypy/trunk/lib-python/modified-2.5.2/test/test_support.py pypy/trunk/lib-python/modified-2.5.2/test/test_weakref.py Log: Semi-experimental: update to the new proposed interface to CPython's test-skipping mechanism. Modified: pypy/trunk/lib-python/modified-2.5.2/test/string_tests.py ============================================================================== --- pypy/trunk/lib-python/modified-2.5.2/test/string_tests.py (original) +++ pypy/trunk/lib-python/modified-2.5.2/test/string_tests.py Tue Jan 13 15:45:00 2009 @@ -936,7 +936,7 @@ self.checkequal('abc', 'abc', '__mul__', 1) self.checkequal('abcabcabc', 'abc', '__mul__', 3) self.checkraises(TypeError, 'abc', '__mul__') - if test_support.check_impl_detail: + if test_support.check_impl_detail(): self.checkraises(TypeError, 'abc', '__mul__', '') # XXX: on a 64-bit system, this doesn't raise an overflow error, # but either raises a MemoryError, or succeeds (if you have 54TiB) @@ -1149,7 +1149,7 @@ self.assert_(s1 is not s2) self.assert_(type(s2) is t) - if test_support.check_impl_detail: + if test_support.check_impl_detail(): s1 = t("abcd") s2 = t().join([s1]) self.assert_(s1 is s2) Modified: pypy/trunk/lib-python/modified-2.5.2/test/test_coercion.py ============================================================================== --- pypy/trunk/lib-python/modified-2.5.2/test/test_coercion.py (original) +++ pypy/trunk/lib-python/modified-2.5.2/test/test_coercion.py Tue Jan 13 15:45:00 2009 @@ -306,7 +306,7 @@ self.assertNotEquals(cmp(u'fish', evil_coercer), 0) self.assertNotEquals(cmp(slice(1), evil_coercer), 0) # ...but that this still works - if check_impl_detail: + if check_impl_detail(): # NB. I (arigo) would consider the following as implementation- # specific. For example, in CPython, if we replace 42 with 42.0 # both below and in CoerceTo() above, then the test fails. This Modified: pypy/trunk/lib-python/modified-2.5.2/test/test_compile.py ============================================================================== --- pypy/trunk/lib-python/modified-2.5.2/test/test_compile.py (original) +++ pypy/trunk/lib-python/modified-2.5.2/test/test_compile.py Tue Jan 13 15:45:00 2009 @@ -78,7 +78,7 @@ self.assertEqual(m.results, ('z', g)) exec 'z = locals()' in g, m self.assertEqual(m.results, ('z', m)) - if check_impl_detail: + if check_impl_detail(): try: exec 'z = b' in m except TypeError: Modified: pypy/trunk/lib-python/modified-2.5.2/test/test_descr.py ============================================================================== --- pypy/trunk/lib-python/modified-2.5.2/test/test_descr.py (original) +++ pypy/trunk/lib-python/modified-2.5.2/test/test_descr.py Tue Jan 13 15:45:00 2009 @@ -381,7 +381,7 @@ # Two essentially featureless objects, just inheriting stuff from # object. vereq(dir(NotImplemented), dir(Ellipsis)) - if check_impl_detail: # None might differ: it can have __nonzero__ + if check_impl_detail(): # None might differ: it can have __nonzero__ vereq(dir(None), dir(Ellipsis)) # Nasty test case for proxied objects @@ -1109,7 +1109,7 @@ callable(*args) except exc, msg: # the exact msg is generally considered an implementation detail - if check_impl_detail and not str(msg).startswith(expected): + if check_impl_detail() and not str(msg).startswith(expected): raise TestFailed, "Message %r, expected %r" % (str(msg), expected) else: @@ -1321,7 +1321,7 @@ # Test lookup leaks [SF bug 572567] import sys,gc - if check_impl_detail: # no gc.get_objects() on non-CPython + if check_impl_detail(): # no gc.get_objects() on non-CPython # implementations, but no leaks either :-) class G(object): def __cmp__(self, other): @@ -1984,7 +1984,7 @@ unsafecmp(1, 1L) unsafecmp(1L, 1) - if check_impl_detail: + if check_impl_detail(): class Letter(str): def __new__(cls, letter): if letter == 'EPS': @@ -3659,7 +3659,7 @@ gc_collect() vereq(len(C.container), 1) del C.container[-1] - if check_impl_detail: + if check_impl_detail(): vereq(len(C.container), 1) vereq(C.container[-1].attr, 42) @@ -3688,7 +3688,7 @@ pass class C(A,B) : __slots__=() - if check_impl_detail: + if check_impl_detail(): vereq(C.__basicsize__, B.__basicsize__) verify(hasattr(C, '__dict__')) verify(hasattr(C, '__weakref__')) Modified: pypy/trunk/lib-python/modified-2.5.2/test/test_format.py ============================================================================== --- pypy/trunk/lib-python/modified-2.5.2/test/test_format.py (original) +++ pypy/trunk/lib-python/modified-2.5.2/test/test_format.py Tue Jan 13 15:45:00 2009 @@ -251,7 +251,7 @@ # Returning a non-string should not blow up. return self + 1 -if check_impl_detail: +if check_impl_detail(): test_exc('%o', Foobar(), TypeError, "expected string or Unicode object, long found") Modified: pypy/trunk/lib-python/modified-2.5.2/test/test_import.py ============================================================================== --- pypy/trunk/lib-python/modified-2.5.2/test/test_import.py (original) +++ pypy/trunk/lib-python/modified-2.5.2/test/test_import.py Tue Jan 13 15:45:00 2009 @@ -233,5 +233,5 @@ finally: sys.path.pop(0) -if check_impl_detail: +if check_impl_detail(): test_infinite_reload() Modified: pypy/trunk/lib-python/modified-2.5.2/test/test_itertools.py ============================================================================== --- pypy/trunk/lib-python/modified-2.5.2/test/test_itertools.py (original) +++ pypy/trunk/lib-python/modified-2.5.2/test/test_itertools.py Tue Jan 13 15:45:00 2009 @@ -195,7 +195,7 @@ zip('abc', 'def')) self.assertEqual([pair for pair in izip('abc', 'def')], zip('abc', 'def')) - if test_support.check_impl_detail: + if test_support.check_impl_detail(): # izip "reuses" the same tuple object each time when it can ids = map(id, izip('abc', 'def')) self.assertEqual(min(ids), max(ids)) @@ -363,7 +363,7 @@ self.assertRaises(TypeError, tee, [1,2], 3, 'x') # tee object should be instantiable - if test_support.check_impl_detail: + if test_support.check_impl_detail(): # XXX I (arigo) would argue that 'type(a)(iterable)' has # ill-defined semantics: it always return a fresh tee object, # but depending on whether 'iterable' is itself a tee object Modified: pypy/trunk/lib-python/modified-2.5.2/test/test_support.py ============================================================================== --- pypy/trunk/lib-python/modified-2.5.2/test/test_support.py (original) +++ pypy/trunk/lib-python/modified-2.5.2/test/test_support.py Tue Jan 13 15:45:00 2009 @@ -532,24 +532,55 @@ #======================================================================= # distinguishing between language-level tests and implementation details -# Use the following flag to guard CPython's implementation-specific tests. -check_impl_detail = (hasattr(sys, 'subversion') and - sys.subversion[0] == 'CPython') +def get_running_vm(): + return sys.subversion[0].lower() -def impl_detail(reason="CPython-specific implementation detail"): +def _decode_vm(guards): + # Returns a tuple ({platform_name: run_me}, default_value) + if not guards: + return ({'cpython': True}, False) + is_true = guards.values()[0] + assert guards.values() == [is_true] * len(guards) # all True or all False + return (guards, not is_true) + +# Use the following check to guard CPython's implementation-specific tests -- +# or to run them only on the implementation(s) guarded by the arguments. +def check_impl_detail(**guards): + """This function returns True or False depending on the host platform. + Examples: + if check_impl_detail(): # only on CPython (default) + if check_impl_detail(jython=True): # only on Jython + if check_impl_detail(cpython=False): # everywhere except on CPython + """ + guards, default = _decode_vm(guards) + return guards.get(get_running_vm(), default) + +def impl_detail(msg=None, **guards): """A decorator to skip a whole function if not running on top of CPython. + Examples: + @impl_detail() # only on CPython (default) + @impl_detail(jython=True) # only on Jython + @impl_detail(cpython=False) # everywhere except on CPython """ - assert isinstance(reason, basestring) + assert msg is None or isinstance(msg, basestring) def decorator(f): - if check_impl_detail: + if check_impl_detail(**guards): return f - else: - def _skip_check_impl_detail(*args, **kwds): - if verbose: - sys.stderr.write("Skipping %s: %s\n" % (f.__name__, - reason)) + def _skip_check_impl_detail(*args, **kwds): + if not verbose: return - return _skip_check_impl_detail + msg1 = msg + if msg1 is None: + guardnames, default = _decode_vm(guards) + if default == False: + msg1 = "implementation detail specific to %s" + else: + msg1 = "implementation detail not running on %s" + guardnames = guardnames.keys() + guardnames.sort() + msg1 = msg1 % (' or '.join(guardnames),) + sys.stderr.write("Skipping %s: %s\n" % (f.__name__, msg1)) + return _skip_check_impl_detail return decorator def gc_collect(): Modified: pypy/trunk/lib-python/modified-2.5.2/test/test_weakref.py ============================================================================== --- pypy/trunk/lib-python/modified-2.5.2/test/test_weakref.py (original) +++ pypy/trunk/lib-python/modified-2.5.2/test/test_weakref.py Tue Jan 13 15:45:00 2009 @@ -108,7 +108,7 @@ self.assertRaises(weakref.ReferenceError, check, ref1) self.assertRaises(weakref.ReferenceError, check, ref2) - if test_support.check_impl_detail: + if test_support.check_impl_detail(): # Works only with refcounting self.assertRaises(weakref.ReferenceError, bool, weakref.proxy(C())) self.assert_(self.cbcalled == 2) @@ -625,14 +625,11 @@ def test_gc_during_proxy_creation(self): self.check_gc_during_creation(weakref.proxy) + @test_support.impl_detail() def check_gc_during_creation(self, makeref): - # gc.get/set_threshold does not exist in pypy - # The tests calling this function probaly don't test anything - # usefull anymore - - if not test_support.check_impl_detail: - return - + # gc.get/set_threshold does not exist e.g. in pypy + thresholds = gc.get_threshold() + gc.set_threshold(1, 1, 1) gc.collect() class A: pass From antocuni at codespeak.net Tue Jan 13 15:54:13 2009 From: antocuni at codespeak.net (antocuni at codespeak.net) Date: Tue, 13 Jan 2009 15:54:13 +0100 (CET) Subject: [pypy-svn] r60920 - in pypy/trunk/pypy: interpreter/pyparser module/__builtin__/test Message-ID: <20090113145413.B36331684C9@codespeak.net> Author: antocuni Date: Tue Jan 13 15:54:13 2009 New Revision: 60920 Modified: pypy/trunk/pypy/interpreter/pyparser/pythonparse.py pypy/trunk/pypy/module/__builtin__/test/test_builtin.py Log: raise SyntaxError if you try to compile() an unicode string that contains an explicit encoding declaration Modified: pypy/trunk/pypy/interpreter/pyparser/pythonparse.py ============================================================================== --- pypy/trunk/pypy/interpreter/pyparser/pythonparse.py (original) +++ pypy/trunk/pypy/interpreter/pyparser/pythonparse.py Tue Jan 13 15:54:13 2009 @@ -100,6 +100,10 @@ if textsrc[:3] == '\xEF\xBB\xBF': textsrc = textsrc[3:] enc = 'utf-8' + # check that there is no explicit encoding declared + decl_enc = _check_for_encoding(textsrc) + if decl_enc is not None: + raise SyntaxError("encoding declaration in Unicode string") else: enc = _normalize_encoding(_check_for_encoding(textsrc)) if enc is not None and enc not in ('utf-8', 'iso-8859-1'): Modified: pypy/trunk/pypy/module/__builtin__/test/test_builtin.py ============================================================================== --- pypy/trunk/pypy/module/__builtin__/test/test_builtin.py (original) +++ pypy/trunk/pypy/module/__builtin__/test/test_builtin.py Tue Jan 13 15:54:13 2009 @@ -410,6 +410,10 @@ compile(u'-', '?', 'eval') except SyntaxError, e: assert e.lineno == 1 + + def test_unicode_encoding_compile(self): + code = u"# -*- coding: utf-8 -*-\npass\n" + raises(SyntaxError, compile, code, "tmp", "exec") def test_isinstance(self): assert isinstance(5, int) From cfbolz at codespeak.net Tue Jan 13 15:59:25 2009 From: cfbolz at codespeak.net (cfbolz at codespeak.net) Date: Tue, 13 Jan 2009 15:59:25 +0100 (CET) Subject: [pypy-svn] r60921 - in pypy/trunk/pypy: module/sys translator/goal Message-ID: <20090113145925.85AE81684DB@codespeak.net> Author: cfbolz Date: Tue Jan 13 15:59:23 2009 New Revision: 60921 Modified: pypy/trunk/pypy/module/sys/version.py pypy/trunk/pypy/translator/goal/app_main.py Log: (arigo, cfbolz): Make -V output comply more to CPython's to fix a test. Nicefication in sys module. Modified: pypy/trunk/pypy/module/sys/version.py ============================================================================== --- pypy/trunk/pypy/module/sys/version.py (original) +++ pypy/trunk/pypy/module/sys/version.py Tue Jan 13 15:59:23 2009 @@ -35,7 +35,7 @@ return space.wrap(CPYTHON_VERSION) def get_version(space): - return space.wrap("%d.%d.%d (%d, %s, %s) \n[PyPy %d.%d.%d]" % ( + return space.wrap("%d.%d.%d (%d, %s, %s)\n[PyPy %d.%d.%d]" % ( CPYTHON_VERSION[0], CPYTHON_VERSION[1], CPYTHON_VERSION[2], Modified: pypy/trunk/pypy/translator/goal/app_main.py ============================================================================== --- pypy/trunk/pypy/translator/goal/app_main.py (original) +++ pypy/trunk/pypy/translator/goal/app_main.py Tue Jan 13 15:59:23 2009 @@ -236,7 +236,7 @@ elif arg == '-O': pass elif arg == '--version' or arg == '-V': - print sys.version + print "Python", sys.version return 0 elif arg == '--info': print_info() From antocuni at codespeak.net Tue Jan 13 15:59:45 2009 From: antocuni at codespeak.net (antocuni at codespeak.net) Date: Tue, 13 Jan 2009 15:59:45 +0100 (CET) Subject: [pypy-svn] r60922 - pypy/trunk/lib-python Message-ID: <20090113145945.DD9151684DD@codespeak.net> Author: antocuni Date: Tue Jan 13 15:59:45 2009 New Revision: 60922 Modified: pypy/trunk/lib-python/failure_list.txt Log: I think this test is fixed now, add a note to remember to check it Modified: pypy/trunk/lib-python/failure_list.txt ============================================================================== --- pypy/trunk/lib-python/failure_list.txt (original) +++ pypy/trunk/lib-python/failure_list.txt Tue Jan 13 15:59:45 2009 @@ -15,7 +15,7 @@ test_codecs ! unknown test_coding ! hah. fix buildbot :-/ test_commands ! unknown -test_compile ! test_leading_newlines: impl detail; the rest: not good +test_compile ! test_leading_newlines: impl detail; the rest: not good SHOULD BE FIXED NOW, check the nightly tests test_compiler ! unknown test_ctypes ! implementation details but also some real crashes test_decimal missing decimal.ROUND_05UP From cfbolz at codespeak.net Tue Jan 13 16:19:03 2009 From: cfbolz at codespeak.net (cfbolz at codespeak.net) Date: Tue, 13 Jan 2009 16:19:03 +0100 (CET) Subject: [pypy-svn] r60923 - pypy/trunk/lib-python/modified-2.5.2/test Message-ID: <20090113151903.82C181684D1@codespeak.net> Author: cfbolz Date: Tue Jan 13 16:19:01 2009 New Revision: 60923 Added: pypy/trunk/lib-python/modified-2.5.2/test/test_new.py - copied, changed from r60770, pypy/trunk/lib-python/2.5.2/test/test_new.py Log: this is an implementation detail Copied: pypy/trunk/lib-python/modified-2.5.2/test/test_new.py (from r60770, pypy/trunk/lib-python/2.5.2/test/test_new.py) ============================================================================== --- pypy/trunk/lib-python/2.5.2/test/test_new.py (original) +++ pypy/trunk/lib-python/modified-2.5.2/test/test_new.py Tue Jan 13 16:19:01 2009 @@ -1,4 +1,4 @@ -from test.test_support import verbose, verify, TestFailed +from test.test_support import verbose, verify, TestFailed, check_impl_detail import sys import new @@ -50,12 +50,13 @@ im = new.instancemethod(break_yolks, c) im() verify(c.get_yolks() == -1) -try: - new.instancemethod(break_yolks, None) -except TypeError: - pass -else: - raise TestFailed, "dangerous instance method creation allowed" +if check_impl_detail(): + try: + new.instancemethod(break_yolks, None) + except TypeError: + pass + else: + raise TestFailed, "dangerous instance method creation allowed" # Verify that instancemethod() doesn't allow keyword args try: From antocuni at codespeak.net Tue Jan 13 16:44:04 2009 From: antocuni at codespeak.net (antocuni at codespeak.net) Date: Tue, 13 Jan 2009 16:44:04 +0100 (CET) Subject: [pypy-svn] r60924 - in pypy/trunk/pypy/module/sha: . test Message-ID: <20090113154404.770741684C0@codespeak.net> Author: antocuni Date: Tue Jan 13 16:44:04 2009 New Revision: 60924 Modified: pypy/trunk/pypy/module/sha/interp_sha.py pypy/trunk/pypy/module/sha/test/test_sha.py Log: add a default_size field to all sha.sha() objects Modified: pypy/trunk/pypy/module/sha/interp_sha.py ============================================================================== --- pypy/trunk/pypy/module/sha/interp_sha.py (original) +++ pypy/trunk/pypy/module/sha/interp_sha.py Tue Jan 13 16:44:04 2009 @@ -47,6 +47,7 @@ digest = interp2app(W_SHA.digest_w, unwrap_spec=['self']), hexdigest = interp2app(W_SHA.hexdigest_w, unwrap_spec=['self']), copy = interp2app(W_SHA.copy_w, unwrap_spec=['self']), + digest_size = 20, __doc__ = """sha(arg) -> return new sha object. If arg is present, the method call update(arg) is made.""") Modified: pypy/trunk/pypy/module/sha/test/test_sha.py ============================================================================== --- pypy/trunk/pypy/module/sha/test/test_sha.py (original) +++ pypy/trunk/pypy/module/sha/test/test_sha.py Tue Jan 13 16:44:04 2009 @@ -27,6 +27,8 @@ assert self.sha.blocksize == 1 assert self.sha.digest_size == 20 assert self.sha.digestsize == 20 + d = self.sha.sha() + assert d.digest_size == 20 def test_SHAType(self): From antocuni at codespeak.net Tue Jan 13 17:10:37 2009 From: antocuni at codespeak.net (antocuni at codespeak.net) Date: Tue, 13 Jan 2009 17:10:37 +0100 (CET) Subject: [pypy-svn] r60925 - pypy/trunk/pypy/lib Message-ID: <20090113161037.B7DD41684DF@codespeak.net> Author: antocuni Date: Tue Jan 13 17:10:36 2009 New Revision: 60925 Modified: pypy/trunk/pypy/lib/_hashlib.py Log: (antocuni, arigato around) on some systems EVP_MD_CTX_block_size is a macro, so we can't really call it through ctypes. Instead, hardcode the result, as it is fixed given the hash function Modified: pypy/trunk/pypy/lib/_hashlib.py ============================================================================== --- pypy/trunk/pypy/lib/_hashlib.py (original) +++ pypy/trunk/pypy/lib/_hashlib.py Tue Jan 13 17:10:36 2009 @@ -115,7 +115,17 @@ digestsize = digest_size # deprecated, was once defined by sha module def block_size(self): - return lib.EVP_MD_CTX_block_size(byref(self._obj)) + # XXX This isn't the nicest way, but the EVP_MD_CTX_block_size OpenSSL function + # XXX is defined as a C macro on some systems and would be significantly + # XXX harder to implement in another way. + return { + 'md5': 64, + 'sha1': 64, + 'sha224': 64, + 'sha256': 64, + 'sha384': 128, + 'sha512': 128, + }.get(self.name, 0) block_size = property(block_size, None, None) def update(self, string): From antocuni at codespeak.net Tue Jan 13 17:13:08 2009 From: antocuni at codespeak.net (antocuni at codespeak.net) Date: Tue, 13 Jan 2009 17:13:08 +0100 (CET) Subject: [pypy-svn] r60926 - pypy/trunk/lib-python Message-ID: <20090113161308.227A31684DE@codespeak.net> Author: antocuni Date: Tue Jan 13 17:13:07 2009 New Revision: 60926 Modified: pypy/trunk/lib-python/failure_list.txt Log: another test file that has probably been fixed Modified: pypy/trunk/lib-python/failure_list.txt ============================================================================== --- pypy/trunk/lib-python/failure_list.txt (original) +++ pypy/trunk/lib-python/failure_list.txt Tue Jan 13 17:13:07 2009 @@ -37,7 +37,7 @@ test_genexps ! Fatal RPython error: InternalCompilerError :-( test_gettext ! check this use of unicode() test_grammar implementation detail -test_hmac ! looks bad! +test_hmac ! looks bad! SHOULD BE FIXED NOW, check the nightly tests test_import importing from pyc-files-without-py-file disabled by default test_importhooks ! unknown test_inspect ! test_wrapped_decorator: try to fix; isbuiltin([].append): cry and maaaybe try to fix From cfbolz at codespeak.net Tue Jan 13 17:33:27 2009 From: cfbolz at codespeak.net (cfbolz at codespeak.net) Date: Tue, 13 Jan 2009 17:33:27 +0100 (CET) Subject: [pypy-svn] r60927 - in pypy/trunk/pypy/module/_random: . test Message-ID: <20090113163327.C8CBF1684BB@codespeak.net> Author: cfbolz Date: Tue Jan 13 17:33:26 2009 New Revision: 60927 Modified: pypy/trunk/pypy/module/_random/interp_random.py pypy/trunk/pypy/module/_random/test/test_random.py Log: fix a test Modified: pypy/trunk/pypy/module/_random/interp_random.py ============================================================================== --- pypy/trunk/pypy/module/_random/interp_random.py (original) +++ pypy/trunk/pypy/module/_random/interp_random.py Tue Jan 13 17:33:26 2009 @@ -1,13 +1,15 @@ from pypy.interpreter.error import OperationError from pypy.interpreter.typedef import TypeDef from pypy.interpreter.gateway import ObjSpace, W_Root, NoneNotWrapped, interp2app +from pypy.interpreter.gateway import Arguments from pypy.interpreter.baseobjspace import Wrappable from pypy.rlib.rarithmetic import r_uint, intmask from pypy.rlib import rrandom import time -def descr_new__(space, w_subtype, w_anything=None): +def descr_new__(space, w_subtype, args): + w_anything = args.firstarg() x = space.allocate_instance(W_Random, w_subtype) x = space.interp_w(W_Random, x) W_Random.__init__(x, space, w_anything) @@ -23,7 +25,7 @@ return space.newfloat(self._rnd.random()) random.unwrap_spec = ['self', ObjSpace] - def seed(self, space, w_n=None): + def seed(self, space, w_n=NoneNotWrapped): if w_n is None: w_n = space.newint(int(time.time())) else: @@ -111,7 +113,7 @@ W_Random.typedef = TypeDef("Random", - __new__ = interp2app(descr_new__), + __new__ = interp2app(descr_new__, unwrap_spec=[ObjSpace, W_Root, Arguments]), random = interp2app(W_Random.random), seed = interp2app(W_Random.seed), getstate = interp2app(W_Random.getstate), Modified: pypy/trunk/pypy/module/_random/test/test_random.py ============================================================================== --- pypy/trunk/pypy/module/_random/test/test_random.py (original) +++ pypy/trunk/pypy/module/_random/test/test_random.py Tue Jan 13 17:33:26 2009 @@ -79,3 +79,11 @@ for n in range(1, 10) + range(10, 1000, 15): k = rnd.getrandbits(n) assert 0 <= k < 2 ** n + + def test_subclass(self): + import _random + class R(_random.Random): + def __init__(self, x=1): + self.x = x + r = R(x=15) + assert r.x == 15 From cfbolz at codespeak.net Tue Jan 13 17:34:08 2009 From: cfbolz at codespeak.net (cfbolz at codespeak.net) Date: Tue, 13 Jan 2009 17:34:08 +0100 (CET) Subject: [pypy-svn] r60928 - pypy/trunk/lib-python/modified-2.5.2 Message-ID: <20090113163408.9F66E1684BB@codespeak.net> Author: cfbolz Date: Tue Jan 13 17:34:08 2009 New Revision: 60928 Added: pypy/trunk/lib-python/modified-2.5.2/random.py - copied, changed from r60922, pypy/trunk/lib-python/2.5.2/random.py Log: (cfbolz, arigo) fix completely implementation-specific funniness in random.py Copied: pypy/trunk/lib-python/modified-2.5.2/random.py (from r60922, pypy/trunk/lib-python/2.5.2/random.py) ============================================================================== --- pypy/trunk/lib-python/2.5.2/random.py (original) +++ pypy/trunk/lib-python/modified-2.5.2/random.py Tue Jan 13 17:34:08 2009 @@ -39,7 +39,6 @@ """ from warnings import warn as _warn -from types import MethodType as _MethodType, BuiltinMethodType as _BuiltinMethodType from math import log as _log, exp as _exp, pi as _pi, e as _e, ceil as _ceil from math import sqrt as _sqrt, acos as _acos, cos as _cos, sin as _sin from os import urandom as _urandom @@ -214,28 +213,24 @@ return self.randrange(a, b+1) - def _randbelow(self, n, _log=_log, int=int, _maxwidth=1L< n-1 > 2**(k-2) + k = int(1.00001 + _log(n-1, 2.0)) # 2**k > n-1 > 2**(k-2) + r = getrandbits(k) + while r >= n: r = getrandbits(k) - while r >= n: - r = getrandbits(k) - return r + return r if n >= _maxwidth: _warn("Underlying random() generator does not supply \n" "enough bits to choose from a population range this large") From antocuni at codespeak.net Tue Jan 13 17:35:16 2009 From: antocuni at codespeak.net (antocuni at codespeak.net) Date: Tue, 13 Jan 2009 17:35:16 +0100 (CET) Subject: [pypy-svn] r60929 - pypy/trunk/pypy/interpreter/pyparser Message-ID: <20090113163516.AAA0B1684BB@codespeak.net> Author: antocuni Date: Tue Jan 13 17:35:16 2009 New Revision: 60929 Modified: pypy/trunk/pypy/interpreter/pyparser/asthelper.py Log: use a more precise error message for cases like "x = yield = y". This should fix some doctest errors in test_generators.py Modified: pypy/trunk/pypy/interpreter/pyparser/asthelper.py ============================================================================== --- pypy/trunk/pypy/interpreter/pyparser/asthelper.py (original) +++ pypy/trunk/pypy/interpreter/pyparser/asthelper.py Tue Jan 13 17:35:16 2009 @@ -396,6 +396,9 @@ else: raise SyntaxError("can't assign to function call", lineno) + elif isinstance(ast_node, ast.Yield): + raise SyntaxError("assignment to yield expression not possible", + lineno) else: raise SyntaxError("can't assign to non-lvalue", lineno) From cfbolz at codespeak.net Tue Jan 13 17:47:36 2009 From: cfbolz at codespeak.net (cfbolz at codespeak.net) Date: Tue, 13 Jan 2009 17:47:36 +0100 (CET) Subject: [pypy-svn] r60930 - in pypy/trunk/pypy/lang/prolog/interpreter: . test Message-ID: <20090113164736.0F9691680B8@codespeak.net> Author: cfbolz Date: Tue Jan 13 17:47:35 2009 New Revision: 60930 Removed: pypy/trunk/pypy/lang/prolog/interpreter/test/test_jit.py Modified: pypy/trunk/pypy/lang/prolog/interpreter/engine.py pypy/trunk/pypy/lang/prolog/interpreter/term.py Log: Kill JIT hints, as the new JIT will need different hacks (had this in my checkout for a while). Modified: pypy/trunk/pypy/lang/prolog/interpreter/engine.py ============================================================================== --- pypy/trunk/pypy/lang/prolog/interpreter/engine.py (original) +++ pypy/trunk/pypy/lang/prolog/interpreter/engine.py Tue Jan 13 17:47:35 2009 @@ -3,9 +3,7 @@ from pypy.lang.prolog.interpreter.error import UnificationFailed, FunctionNotFound, \ CutException from pypy.lang.prolog.interpreter import error -from pypy.rlib.jit import hint, we_are_jitted, _is_early_constant, purefunction -from pypy.rlib.objectmodel import specialize -from pypy.rlib.unroll import unrolling_iterable +from pypy.rlib.jit import purefunction DEBUG = False @@ -90,11 +88,8 @@ #import pdb;pdb.set_trace() while self: uh = self.rule.unify_hash - hint(uh, concrete=True) - uh = hint(uh, deepfreeze=True) j = 0 while j < len(uh): - hint(j, concrete=True) hash1 = uh[j] hash2 = uh2[j] if hash1 != 0 and hash2 * (hash2 - hash1) != 0: @@ -139,9 +134,6 @@ self.signature2function = {} self.parser = None self.operations = None - #XXX circular imports hack - from pypy.lang.prolog.builtin import builtins_list - globals()['unrolling_builtins'] = unrolling_iterable(builtins_list) def add_rule(self, rule, end=True): from pypy.lang.prolog import builtin @@ -162,11 +154,8 @@ if signature in builtin.builtins: error.throw_permission_error( "modify", "static_procedure", rule.head.get_prolog_signature()) - function = self.signature2function.get(signature, None) - if function is not None: - self.signature2function[signature].add_rule(rule, end) - else: - self.signature2function[signature] = Function(rule) + function = self._lookup(signature) + function.add_rule(rule, end) def run(self, query, continuation=DONOTHING): if not isinstance(query, Callable): @@ -197,16 +186,6 @@ return self.main_loop(CALL, query, continuation) def _call(self, query, continuation): - signature = query.signature - from pypy.lang.prolog.builtin import builtins - builtins = hint(builtins, deepfreeze=True) - signature = hint(signature, promote=True) - for bsig, builtin in unrolling_builtins: - if signature == bsig: - return builtin.call(self, query, continuation) - return self.user_call(query, continuation, choice_point=False) - - def _opaque_call(self, query, continuation): from pypy.lang.prolog.builtin import builtins signature = query.signature builtin = builtins.get(signature, None) @@ -217,32 +196,27 @@ def main_loop(self, where, query, continuation, rule=None): next = (DONE, None, None, None) - hint(where, concrete=True) - hint(rule, concrete=True) while 1: if where == DONE: return next next = self.dispatch_bytecode(where, query, continuation, rule) where, query, continuation, rule = next - where = hint(where, promote=True) def dispatch_bytecode(self, where, query, continuation, rule): if where == CALL: next = self._call(query, continuation) elif where == TRY_RULE: - rule = hint(rule, promote=True) next = self._try_rule(rule, query, continuation) elif where == USER_CALL: next = self._user_call(query, continuation) elif where == CONTINUATION: - hint(continuation.__class__, promote=True) next = continuation._call(self) else: raise Exception("unknown bytecode") return next @purefunction - def _jit_lookup(self, signature): + def _lookup(self, signature): signature2function = self.signature2function function = signature2function.get(signature, None) if function is None: @@ -255,10 +229,9 @@ return self.main_loop(USER_CALL, query, continuation) def _user_call(self, query, continuation): - signature = hint(query.signature, promote=True) - function = self._jit_lookup(signature) + signature = query.signature + function = self._lookup(signature) startrulechain = function.rulechain - startrulechain = hint(startrulechain, promote=True) if startrulechain is None: error.throw_existence_error( "procedure", query.get_prolog_signature()) @@ -277,7 +250,6 @@ choice_point = rulechain is not None else: choice_point = False - hint(rule, concrete=True) if rule.contains_cut: continuation = LimitedScopeContinuation(continuation) try: @@ -292,13 +264,11 @@ continuation) raise else: - inline = rule.body is None # inline facts try: # for the last rule (rulechain is None), this will always - # return, because choice_point is False + # return immediately, because choice_point is False result = self.try_rule(rule, query, continuation, - choice_point=choice_point, - inline=inline) + choice_point=choice_point) self.heap.discard(oldstate) return result except UnificationFailed: @@ -307,48 +277,12 @@ rule = rulechain.rule rulechain = rulechain.next - def try_rule(self, rule, query, continuation=DONOTHING, choice_point=True, - inline=False): + def try_rule(self, rule, query, continuation=DONOTHING, choice_point=True): if not choice_point: return (TRY_RULE, query, continuation, rule) - if not we_are_jitted(): - return self.portal_try_rule(rule, query, continuation, choice_point) - if inline: - return self.main_loop(TRY_RULE, query, continuation, rule) - #if _is_early_constant(rule): - # rule = hint(rule, promote=True) - # return self.portal_try_rule(rule, query, continuation, choice_point) - return self._opaque_try_rule(rule, query, continuation, choice_point) - - def _opaque_try_rule(self, rule, query, continuation, choice_point): - return self.portal_try_rule(rule, query, continuation, choice_point) - - def portal_try_rule(self, rule, query, continuation, choice_point): - hint(None, global_merge_point=True) - hint(choice_point, concrete=True) - if not choice_point: - return self._try_rule(rule, query, continuation) - where = TRY_RULE - next = (DONE, None, None, None) - hint(where, concrete=True) - hint(rule, concrete=True) - signature = hint(query.signature, promote=True) - while 1: - hint(None, global_merge_point=True) - if where == DONE: - return next - if rule is not None: - assert rule.signature == signature - next = self.dispatch_bytecode(where, query, continuation, rule) - where, query, continuation, rule = next - rule = hint(rule, promote=True) - if query is not None: - signature = hint(query.signature, promote=True) - where = hint(where, promote=True) + return self.main_loop(TRY_RULE, query, continuation, rule) def _try_rule(self, rule, query, continuation): - rule = hint(rule, deepfreeze=True) - hint(self, concrete=True) # standardizing apart nextcall = rule.clone_and_unify_head(self.heap, query) if nextcall is not None: Modified: pypy/trunk/pypy/lang/prolog/interpreter/term.py ============================================================================== --- pypy/trunk/pypy/lang/prolog/interpreter/term.py (original) +++ pypy/trunk/pypy/lang/prolog/interpreter/term.py Tue Jan 13 17:47:35 2009 @@ -4,9 +4,7 @@ from pypy.rlib.rarithmetic import intmask from pypy.lang.prolog.interpreter.error import UnificationFailed, UncatchableError from pypy.lang.prolog.interpreter import error -from pypy.rlib.jit import hint from pypy.rlib.objectmodel import specialize -from pypy.rlib.jit import we_are_jitted, hint, purefunction DEBUG = False @@ -116,7 +114,6 @@ self.binding = value def copy(self, heap, memo): - hint(self, concrete=True) try: return memo[self] except KeyError: @@ -124,8 +121,6 @@ return newvar def copy_and_unify(self, other, heap, memo): - hint(self, concrete=True) - self = hint(self, deepfreeze=True) try: seen_value = memo[self] except KeyError: @@ -242,7 +237,6 @@ return self def copy_and_basic_unify(self, other, heap, memo): - hint(self, concrete=True) if isinstance(other, Atom) and (self is other or other.name == self.name): return self @@ -250,8 +244,7 @@ raise UnificationFailed def get_unify_hash(self, heap): - name = hint(self.name, promote=True) - return intmask(hash(name) << TAGBITS | self.TAG) + return intmask(hash(self.name) << TAGBITS | self.TAG) def unify_hash_of_children(self, heap): return [] @@ -260,7 +253,6 @@ return Term("/", [self, NUMBER_0]) @staticmethod - @purefunction def newatom(name): result = Atom.cache.get(name, None) if result is not None: @@ -294,7 +286,6 @@ return self def copy_and_basic_unify(self, other, heap, memo): - hint(self, concrete=True) if isinstance(other, Number) and other.num == self.num: return self else: @@ -331,7 +322,6 @@ return self def copy_and_basic_unify(self, other, heap, memo): - hint(self, concrete=True) if isinstance(other, Float) and other.floatval == self.floatval: return self else: @@ -374,7 +364,6 @@ return self def copy_and_basic_unify(self, other, heap, memo): - hint(self, concrete=True) if self is other: return self else: @@ -422,26 +411,20 @@ raise UnificationFailed def copy(self, heap, memo): - hint(self, concrete=True) - self = hint(self, deepfreeze=True) newargs = [] i = 0 while i < len(self.args): - hint(i, concrete=True) arg = self.args[i].copy(heap, memo) newargs.append(arg) i += 1 return Term(self.name, newargs, self.signature) def copy_and_basic_unify(self, other, heap, memo): - hint(self, concrete=True) - self = hint(self, deepfreeze=True) if (isinstance(other, Term) and self.signature == other.signature): newargs = [None] * len(self.args) i = 0 while i < len(self.args): - hint(i, concrete=True) arg = self.args[i].copy_and_unify(other.args[i], heap, memo) newargs[i] = arg i += 1 @@ -467,8 +450,7 @@ return self def get_unify_hash(self, heap): - signature = hint(self.signature, promote=True) - return intmask(hash(signature) << TAGBITS | self.TAG) + return intmask(hash(self.signature) << TAGBITS | self.TAG) def unify_hash_of_children(self, heap): unify_hash = [] @@ -489,15 +471,7 @@ def eval_arithmetic(self, engine): from pypy.lang.prolog.interpreter.arithmetic import arithmetic_functions - from pypy.lang.prolog.interpreter.arithmetic import arithmetic_functions_list - if we_are_jitted(): - signature = hint(self.signature, promote=True) - func = None - for sig, func in arithmetic_functions_list: - if sig == signature: - break - else: - func = arithmetic_functions.get(self.signature, None) + func = arithmetic_functions.get(self.signature, None) if func is None: error.throw_type_error("evaluable", self.get_prolog_signature()) return func(engine, self) @@ -537,18 +511,15 @@ def clone_and_unify_head(self, heap, head): memo = {} h2 = self.head - hint(h2, concrete=True) if isinstance(h2, Term): assert isinstance(head, Term) i = 0 while i < len(h2.args): - i = hint(i, concrete=True) arg2 = h2.args[i] arg1 = head.args[i] arg2.copy_and_unify(arg1, heap, memo) i += 1 body = self.body - hint(body, concrete=True) if body is None: return None return body.copy(heap, memo) From cfbolz at codespeak.net Tue Jan 13 18:03:55 2009 From: cfbolz at codespeak.net (cfbolz at codespeak.net) Date: Tue, 13 Jan 2009 18:03:55 +0100 (CET) Subject: [pypy-svn] r60931 - pypy/trunk/pypy/rpython/lltypesystem Message-ID: <20090113170355.72BB616805C@codespeak.net> Author: cfbolz Date: Tue Jan 13 18:03:53 2009 New Revision: 60931 Modified: pypy/trunk/pypy/rpython/lltypesystem/rlist.py Log: Incredible optimization: don't allocate Arrays of length 0 for lists that are being shrunk to size 0. Modified: pypy/trunk/pypy/rpython/lltypesystem/rlist.py ============================================================================== --- pypy/trunk/pypy/rpython/lltypesystem/rlist.py (original) +++ pypy/trunk/pypy/rpython/lltypesystem/rlist.py Tue Jan 13 18:03:53 2009 @@ -200,8 +200,9 @@ # The growth pattern is: 0, 4, 8, 16, 25, 35, 46, 58, 72, 88, ... if newsize <= 0: ll_assert(newsize == 0, "negative list length") - new_allocated = 0 - # XXX why not use _ll_prebuilt_empty_array here? + l.length = 0 + l.items = _ll_new_empty_item_array(typeOf(l).TO) + return else: if newsize < 9: some = 3 @@ -295,13 +296,16 @@ return malloc(LISTITEM, 0) _ll_prebuilt_empty_array._annspecialcase_ = 'specialize:memo' +def _ll_new_empty_item_array(LIST): + if INITIAL_EMPTY_LIST_ALLOCATION > 0: + return malloc(LIST.items.TO, INITIAL_EMPTY_LIST_ALLOCATION) + else: + return _ll_prebuilt_empty_array(LIST.items.TO) + def ll_newemptylist(LIST): l = malloc(LIST) l.length = 0 - if INITIAL_EMPTY_LIST_ALLOCATION > 0: - l.items = malloc(LIST.items.TO, INITIAL_EMPTY_LIST_ALLOCATION) - else: - l.items = _ll_prebuilt_empty_array(LIST.items.TO) + l.items = _ll_new_empty_item_array(LIST) return l ll_newemptylist = typeMethod(ll_newemptylist) ll_newemptylist.oopspec = 'newlist(0)' From cfbolz at codespeak.net Tue Jan 13 18:07:46 2009 From: cfbolz at codespeak.net (cfbolz at codespeak.net) Date: Tue, 13 Jan 2009 18:07:46 +0100 (CET) Subject: [pypy-svn] r60932 - pypy/trunk/pypy/objspace/std Message-ID: <20090113170746.510DC1684D4@codespeak.net> Author: cfbolz Date: Tue Jan 13 18:07:45 2009 New Revision: 60932 Modified: pypy/trunk/pypy/objspace/std/typeobject.py Log: tiny cleanup in the C3 algo Modified: pypy/trunk/pypy/objspace/std/typeobject.py ============================================================================== --- pypy/trunk/pypy/objspace/std/typeobject.py (original) +++ pypy/trunk/pypy/objspace/std/typeobject.py Tue Jan 13 18:07:45 2009 @@ -688,26 +688,25 @@ while orderlists: for candidatelist in orderlists: candidate = candidatelist[0] - if mro_blockinglist(candidate, orderlists) is GOODCANDIDATE: + if mro_blockinglist(candidate, orderlists) is None: break # good candidate else: return mro_error(space, orderlists) # no candidate found assert candidate not in order order.append(candidate) for i in range(len(orderlists)-1, -1, -1): - if orderlists[i][0] == candidate: + if orderlists[i][0] is candidate: del orderlists[i][0] if len(orderlists[i]) == 0: del orderlists[i] return order -GOODCANDIDATE = [] def mro_blockinglist(candidate, orderlists): for lst in orderlists: if candidate in lst[1:]: return lst - return GOODCANDIDATE # good candidate + return None # good candidate def mro_error(space, orderlists): cycle = [] From arigo at codespeak.net Tue Jan 13 18:55:35 2009 From: arigo at codespeak.net (arigo at codespeak.net) Date: Tue, 13 Jan 2009 18:55:35 +0100 (CET) Subject: [pypy-svn] r60933 - in pypy/trunk/pypy/translator/goal: . test2 Message-ID: <20090113175535.93FCD1683F2@codespeak.net> Author: arigo Date: Tue Jan 13 18:55:32 2009 New Revision: 60933 Modified: pypy/trunk/pypy/translator/goal/app_main.py pypy/trunk/pypy/translator/goal/test2/test_app_main.py Log: Not only this should work: "pypy-c -c foobar" but also this: "pypy-c -cfoobar" Fixed and slightly sanitize the situation of app_main.py. Modified: pypy/trunk/pypy/translator/goal/app_main.py ============================================================================== --- pypy/trunk/pypy/translator/goal/app_main.py (original) +++ pypy/trunk/pypy/translator/goal/app_main.py Tue Jan 13 18:55:32 2009 @@ -124,6 +124,9 @@ print 'usage: %s [options]' % (sys.executable,) print __doc__ +class CommandLineError(Exception): + pass + def print_error(msg): print >> sys.stderr, msg print >> sys.stderr, 'usage: %s [options]' % (sys.executable,) @@ -159,7 +162,19 @@ else: IS_WINDOWS = False -def entry_point(executable, argv, nanos): +def get_argument(option, argv, i): + arg = argv[i] + if len(arg) > 2: + return arg[2:], i + else: + i += 1 + if i >= len(argv): + raise CommandLineError('Argument expected for the %s option' % + option) + return argv[i], i + + +def setup_initial_paths(executable, nanos): # a substituted os if we are translated global os os = nanos @@ -209,8 +224,10 @@ if dir not in _seen: sys.path.append(dir) _seen[dir] = True - del newpath, _seen + return executable + +def parse_command_line(argv): go_interactive = False run_command = False import_site = True @@ -225,10 +242,9 @@ break if arg == '-i': go_interactive = True - elif arg == '-c': - if i+1 >= len(argv): - print_error('Argument expected for the -c option') - return 2 + elif arg.startswith('-c'): + cmd, i = get_argument('-c', argv, i) + argv[i] = '-c' run_command = True break elif arg == '-u': @@ -237,46 +253,46 @@ pass elif arg == '--version' or arg == '-V': print "Python", sys.version - return 0 + return elif arg == '--info': print_info() - return 0 + return elif arg == '-h' or arg == '--help': print_help() - return 0 + return elif arg == '-S': import_site = False elif arg == '-': run_stdin = True break # not an option but a file name representing stdin - elif arg == '-m': - i += 1 - if i >= len(argv): - print_error('Argument expected for the -m option') - return 2 + elif arg.startswith('-m'): + module, i = get_argument('-m', argv, i) + argv[i] = module run_module = True break elif arg.startswith('-W'): - arg = arg[2:] - if not arg: - i += 1 - if i >= len(argv): - print_error('Argument expected for the -W option') - return 2 - arg = argv[i] - warnoptions = arg + warnoptions, i = get_argument('-W', argv, i) elif arg == '--': i += 1 break # terminates option list else: - print_error('unrecognized option %r' % (arg,)) - return 2 + raise CommandLineError('unrecognized option %r' % (arg,)) i += 1 sys.argv = argv[i:] if not sys.argv: sys.argv.append('') run_stdin = True + return locals() +def run_command_line(go_interactive, + run_command, + import_site, + run_module, + run_stdin, + warnoptions, + unbuffered, + cmd=None, + **ignored): # with PyPy in top of CPython we can only have around 100 # but we need more in the translated PyPy for the compiler package sys.setrecursionlimit(5000) @@ -332,7 +348,6 @@ try: if run_command: # handle the "-c" command - cmd = sys.argv.pop(1) def run_it(): exec cmd in mainmodule.__dict__ success = run_toplevel(run_it) @@ -408,6 +423,18 @@ print ('Type "help", "copyright", "credits" or ' '"license" for more information.') +def entry_point(executable, argv, nanos): + executable = setup_initial_paths(executable, nanos) + try: + cmdline = parse_command_line(argv) + except CommandLineError, e: + print_error(str(e)) + return 2 + if cmdline is None: + return 0 + else: + return run_command_line(**cmdline) + if __name__ == '__main__': import autopath Modified: pypy/trunk/pypy/translator/goal/test2/test_app_main.py ============================================================================== --- pypy/trunk/pypy/translator/goal/test2/test_app_main.py (original) +++ pypy/trunk/pypy/translator/goal/test2/test_app_main.py Tue Jan 13 18:55:32 2009 @@ -328,6 +328,13 @@ child.sendline('Not at all. They could be carried.') child.expect('A five ounce bird could not carry a one pound coconut.') + def test_no_space_before_argument(self): + child = self.spawn(['-cprint "hel" + "lo"']) + child.expect('hello') + + child = self.spawn(['-mpypy.translator.goal.test2.mymodule']) + child.expect('mymodule running') + class TestNonInteractive: From hpk at codespeak.net Wed Jan 14 11:13:10 2009 From: hpk at codespeak.net (hpk at codespeak.net) Date: Wed, 14 Jan 2009 11:13:10 +0100 (CET) Subject: [pypy-svn] r60935 - pypy/extradoc/pypy.org Message-ID: <20090114101310.46B061684AB@codespeak.net> Author: hpk Date: Wed Jan 14 11:13:08 2009 New Revision: 60935 Added: pypy/extradoc/pypy.org/index.html pypy/extradoc/pypy.org/index2.txt (props changed) - copied unchanged from r59912, pypy/extradoc/pypy.org/index.txt Removed: pypy/extradoc/pypy.org/index.txt Log: for now, redirect pypy.org to codespeak.net/pypy. the outdated EU-project info doesn't make sense as it stands. Added: pypy/extradoc/pypy.org/index.html ============================================================================== --- (empty file) +++ pypy/extradoc/pypy.org/index.html Wed Jan 14 11:13:08 2009 @@ -0,0 +1,16 @@ + + + + + + + + +

+ you should be redirected to + + http://codespeak.net/pypy/dist/pypy/ +

+ + From fijal at codespeak.net Wed Jan 14 11:30:53 2009 From: fijal at codespeak.net (fijal at codespeak.net) Date: Wed, 14 Jan 2009 11:30:53 +0100 (CET) Subject: [pypy-svn] r60938 - pypy/trunk/pypy/lib Message-ID: <20090114103053.0474A1684BB@codespeak.net> Author: fijal Date: Wed Jan 14 11:30:53 2009 New Revision: 60938 Modified: pypy/trunk/pypy/lib/_locale.py Log: Kill a lot of code and make one test pass. progress Modified: pypy/trunk/pypy/lib/_locale.py ============================================================================== --- pypy/trunk/pypy/lib/_locale.py (original) +++ pypy/trunk/pypy/lib/_locale.py Wed Jan 14 11:30:53 2009 @@ -48,26 +48,8 @@ del LocaleConfigure del locale_config -_LANGINFO_CONSTANTS = ( - 'RADIXCHAR', - 'THOUSEP', -) - -class LanginfoConfigure: - _compilation_info_ = ExternalCompilationInfo(includes=['langinfo.h']) - nl_item = SimpleType('nl_item') -for key in _LANGINFO_CONSTANTS: - setattr(LanginfoConfigure, key, ConstantInteger(key)) - -config = configure(LanginfoConfigure) -nl_item = config['nl_item'] -for key in _LANGINFO_CONSTANTS: - globals()[key] = config[key] -del LanginfoConfigure -del config HAS_LANGINFO = True - # Ubuntu Gusty i386 structure class lconv(Structure): _fields_ = ( @@ -305,88 +287,42 @@ raise NotImplementedError() if HAS_LANGINFO: + # this is incomplete list + langinfo_names = ('CODESET D_T_FMT D_FMT T_FMT RADIXCHAR THOUSEP ' + 'YESEXPR NOEXPR CRNCYSTR').split(" ") + for i in range(1, 8): + langinfo_names.append("DAY_%d" % i) + langinfo_names.append("ABDAY_%d" % i) + for i in range(1, 13): + langinfo_names.append("MON_%d" % i) + langinfo_names.append("ABMON_%d" % i) + + class LanginfoConfigure: + _compilation_info_ = ExternalCompilationInfo(includes=['langinfo.h']) + nl_item = SimpleType('nl_item') + for key in langinfo_names: + setattr(LanginfoConfigure, key, ConstantInteger(key)) + + config = configure(LanginfoConfigure) + nl_item = config['nl_item'] + for key in langinfo_names: + globals()[key] = config[key] + del LanginfoConfigure + del config + _nl_langinfo = libc.nl_langinfo _nl_langinfo.argtypes = (nl_item,) _nl_langinfo.restype = c_char_p - def _NL_ITEM(category, index): - return (category << 16) | index - - langinfo_constants = { - # LC_TIME category: date and time formatting. - - # Abbreviated days of the week. - "ABDAY_1": _NL_ITEM (LC_TIME, 0), - "ABDAY_2": _NL_ITEM (LC_TIME, 1), - "ABDAY_3": _NL_ITEM (LC_TIME, 2), - "ABDAY_4": _NL_ITEM (LC_TIME, 3), - "ABDAY_5": _NL_ITEM (LC_TIME, 4), - "ABDAY_6": _NL_ITEM (LC_TIME, 5), - "ABDAY_7": _NL_ITEM (LC_TIME, 6), - - # Long-named days of the week. - "DAY_1": _NL_ITEM (LC_TIME, 7), - "DAY_2": _NL_ITEM (LC_TIME, 8), - "DAY_3": _NL_ITEM (LC_TIME, 9), - "DAY_4": _NL_ITEM (LC_TIME, 10), - "DAY_5": _NL_ITEM (LC_TIME, 11), - "DAY_6": _NL_ITEM (LC_TIME, 12), - "DAY_7": _NL_ITEM (LC_TIME, 13), - - # Abbreviated month names. - "ABMON_1": _NL_ITEM (LC_TIME, 14), - "ABMON_2": _NL_ITEM (LC_TIME, 15), - "ABMON_3": _NL_ITEM (LC_TIME, 16), - "ABMON_4": _NL_ITEM (LC_TIME, 17), - "ABMON_5": _NL_ITEM (LC_TIME, 18), - "ABMON_6": _NL_ITEM (LC_TIME, 19), - "ABMON_7": _NL_ITEM (LC_TIME, 20), - "ABMON_8": _NL_ITEM (LC_TIME, 21), - "ABMON_9": _NL_ITEM (LC_TIME, 22), - "ABMON_10": _NL_ITEM (LC_TIME, 23), - "ABMON_11": _NL_ITEM (LC_TIME, 24), - "ABMON_12": _NL_ITEM (LC_TIME, 25), - - # Long month names. - "MON_1": _NL_ITEM (LC_TIME, 26), - "MON_2": _NL_ITEM (LC_TIME, 27), - "MON_3": _NL_ITEM (LC_TIME, 28), - "MON_4": _NL_ITEM (LC_TIME, 29), - "MON_5": _NL_ITEM (LC_TIME, 30), - "MON_6": _NL_ITEM (LC_TIME, 31), - "MON_7": _NL_ITEM (LC_TIME, 32), - "MON_8": _NL_ITEM (LC_TIME, 33), - "MON_9": _NL_ITEM (LC_TIME, 34), - "MON_10": _NL_ITEM (LC_TIME, 35), - "MON_11": _NL_ITEM (LC_TIME, 36), - "MON_12": _NL_ITEM (LC_TIME, 37), - - #TODO: .............. - #TODO: .............. this list - #TODO: .............. is really long - #TODO: .............. i'm lazy - #TODO: .............. so if you - #TODO: .............. want the full - #TODO: .............. list you have to - #TODO: .............. write it your own - #TODO: .............. - } - def nl_langinfo(key): """nl_langinfo(key) -> string Return the value for the locale information associated with key.""" # Check whether this is a supported constant. GNU libc sometimes # returns numeric values in the char* return value, which would # crash PyString_FromString. - for name, value in langinfo_constants.iteritems(): - if value == key: - # Check NULL as a workaround for GNU libc's returning NULL - # instead of an empty string for nl_langinfo(ERA). - result = _nl_langinfo(key) - if result is not None: - return result - else: - return "" + result = _nl_langinfo(key) + if result is not None: + return result raise ValueError("unsupported langinfo constant") def gettext(msg): @@ -432,7 +368,7 @@ 'setlocale', 'localeconv', 'strxfrm', 'strcoll', 'gettext', 'dgettext', 'dcgettext', 'textdomain', 'bindtextdomain', 'CHAR_MAX', -) + _CONSTANTS + _LANGINFO_CONSTANTS +) + _CONSTANTS + tuple(langinfo_names) if _bind_textdomain_codeset: __all__ += ('bind_textdomain_codeset',) if HAS_LANGINFO: From antocuni at codespeak.net Wed Jan 14 11:41:56 2009 From: antocuni at codespeak.net (antocuni at codespeak.net) Date: Wed, 14 Jan 2009 11:41:56 +0100 (CET) Subject: [pypy-svn] r60939 - pypy/trunk/lib-python/modified-2.5.2/test Message-ID: <20090114104156.415031683DD@codespeak.net> Author: antocuni Date: Wed Jan 14 11:41:55 2009 New Revision: 60939 Modified: pypy/trunk/lib-python/modified-2.5.2/test/test_genexps.py Log: I hate doctests. Fix error messages to match pypy's one Modified: pypy/trunk/lib-python/modified-2.5.2/test/test_genexps.py ============================================================================== --- pypy/trunk/lib-python/modified-2.5.2/test/test_genexps.py (original) +++ pypy/trunk/lib-python/modified-2.5.2/test/test_genexps.py Wed Jan 14 11:41:55 2009 @@ -84,10 +84,10 @@ Verify that parenthesis are required when used as a keyword argument value - >>> dict(a = i for i in xrange(10)) + >>> dict(a = i for i in xrange(10)) #doctest: +ELLIPSIS Traceback (most recent call last): ... - SyntaxError: invalid syntax + SyntaxError: invalid syntax... Verify that parenthesis are required when used as a keyword argument value @@ -109,7 +109,7 @@ Traceback (most recent call last): File "", line 1, in -toplevel- (i for i in 6) - TypeError: 'int' object is not iterable + TypeError: iteration over non-sequence Verify late binding for the outermost if-expression @@ -134,15 +134,15 @@ Verify that syntax error's are raised for genexps used as lvalues - >>> (y for y in (1,2)) = 10 + >>> (y for y in (1,2)) = 10 #doctest: +ELLIPSIS Traceback (most recent call last): ... - SyntaxError: assign to generator expression not possible + SyntaxError: assign to generator expression not possible... - >>> (y for y in (1,2)) += 10 + >>> (y for y in (1,2)) += 10 #doctest: +ELLIPSIS Traceback (most recent call last): ... - SyntaxError: augmented assign to tuple literal or generator expression not possible + SyntaxError: augmented assign to tuple literal or generator expression not possible... @@ -223,7 +223,7 @@ True >>> print g.next.__doc__ - x.next() -> the next value, or raise StopIteration + next() -> the next value, or raise StopIteration >>> import types >>> isinstance(g, types.GeneratorType) True From fijal at codespeak.net Wed Jan 14 11:44:33 2009 From: fijal at codespeak.net (fijal at codespeak.net) Date: Wed, 14 Jan 2009 11:44:33 +0100 (CET) Subject: [pypy-svn] r60940 - pypy/trunk/lib-python/modified-2.5.2/test Message-ID: <20090114104433.4A46C1683DD@codespeak.net> Author: fijal Date: Wed Jan 14 11:44:32 2009 New Revision: 60940 Added: pypy/trunk/lib-python/modified-2.5.2/test/test__locale.py - copied, changed from r60938, pypy/trunk/lib-python/2.5.2/test/test__locale.py Log: never ever use is to compare strings Copied: pypy/trunk/lib-python/modified-2.5.2/test/test__locale.py (from r60938, pypy/trunk/lib-python/2.5.2/test/test__locale.py) ============================================================================== --- pypy/trunk/lib-python/2.5.2/test/test__locale.py (original) +++ pypy/trunk/lib-python/modified-2.5.2/test/test__locale.py Wed Jan 14 11:44:32 2009 @@ -45,7 +45,7 @@ except Error: set_locale = "" known_value = known_numerics.get(used_locale, - ('', ''))[data_type is 'thousands_sep'] + ('', ''))[data_type == 'thousands_sep'] if known_value and calc_value: self.assertEquals(calc_value, known_value, self.lc_numeric_err_msg % ( From antocuni at codespeak.net Wed Jan 14 11:57:12 2009 From: antocuni at codespeak.net (antocuni at codespeak.net) Date: Wed, 14 Jan 2009 11:57:12 +0100 (CET) Subject: [pypy-svn] r60942 - pypy/trunk/pypy/interpreter/astcompiler Message-ID: <20090114105712.9C7A01684AB@codespeak.net> Author: antocuni Date: Wed Jan 14 11:57:09 2009 New Revision: 60942 Modified: pypy/trunk/pypy/interpreter/astcompiler/pycodegen.py Log: add precise line number for this kind of syntax error Modified: pypy/trunk/pypy/interpreter/astcompiler/pycodegen.py ============================================================================== --- pypy/trunk/pypy/interpreter/astcompiler/pycodegen.py (original) +++ pypy/trunk/pypy/interpreter/astcompiler/pycodegen.py Wed Jan 14 11:57:09 2009 @@ -1533,7 +1533,8 @@ self.main._visitSubscript(node, True) def visitYield(self, node): - raise SyntaxError("augmented assignment to yield expression not possible") + raise SyntaxError("augmented assignment to yield expression not possible", + node.lineno) class AugStoreVisitor(ast.ASTVisitor): def __init__(self, main_visitor): From fijal at codespeak.net Wed Jan 14 12:23:40 2009 From: fijal at codespeak.net (fijal at codespeak.net) Date: Wed, 14 Jan 2009 12:23:40 +0100 (CET) Subject: [pypy-svn] r60944 - pypy/trunk/lib-python Message-ID: <20090114112340.01C1416849A@codespeak.net> Author: fijal Date: Wed Jan 14 12:23:40 2009 New Revision: 60944 Modified: pypy/trunk/lib-python/conftest.py Log: Skip test_ast. Unless someone protests, I don't think we'll be supplying _ast module before doing something with a parser Modified: pypy/trunk/lib-python/conftest.py ============================================================================== --- pypy/trunk/lib-python/conftest.py (original) +++ pypy/trunk/lib-python/conftest.py Wed Jan 14 12:23:40 2009 @@ -121,6 +121,7 @@ RegrTest('test__locale.py'), RegrTest('test_aepack.py', skip=True), RegrTest('test_al.py', skip=True), + RegrTest('test_ast.py', skip="unsupported module _ast"), RegrTest('test_anydbm.py'), RegrTest('test_applesingle.py', skip=True), RegrTest('test_array.py', core=True, usemodules='struct'), From fijal at codespeak.net Wed Jan 14 12:23:56 2009 From: fijal at codespeak.net (fijal at codespeak.net) Date: Wed, 14 Jan 2009 12:23:56 +0100 (CET) Subject: [pypy-svn] r60945 - pypy/trunk/lib-python Message-ID: <20090114112356.D4219168043@codespeak.net> Author: fijal Date: Wed Jan 14 12:23:55 2009 New Revision: 60945 Modified: pypy/trunk/lib-python/failure_list.txt Log: update Modified: pypy/trunk/lib-python/failure_list.txt ============================================================================== --- pypy/trunk/lib-python/failure_list.txt (original) +++ pypy/trunk/lib-python/failure_list.txt Wed Jan 14 12:23:55 2009 @@ -1,12 +1,5 @@ test name !=must fix guess at failure cause or difficulty ------------------------------------------------------------------------------------------- -test__locale ! wrong locale installation on wyvern - install correct locale on wyvern :-) - I don't understand the above comment: - test__locale passes on python2.5 but fails - on pypy-c, so surely there is another problem? - -test_ast import _ast test_builtin this is our issue383 test_cProfile ! we still need to fix module/cProfile to respect builtin calls test_capi CPython only From fijal at codespeak.net Wed Jan 14 12:30:02 2009 From: fijal at codespeak.net (fijal at codespeak.net) Date: Wed, 14 Jan 2009 12:30:02 +0100 (CET) Subject: [pypy-svn] r60946 - pypy/trunk/lib-python Message-ID: <20090114113002.8731216849A@codespeak.net> Author: fijal Date: Wed Jan 14 12:30:02 2009 New Revision: 60946 Modified: pypy/trunk/lib-python/conftest.py pypy/trunk/lib-python/failure_list.txt Log: update, skip cpython-only test Modified: pypy/trunk/lib-python/conftest.py ============================================================================== --- pypy/trunk/lib-python/conftest.py (original) +++ pypy/trunk/lib-python/conftest.py Wed Jan 14 12:30:02 2009 @@ -380,6 +380,7 @@ RegrTest('test_strptime.py'), RegrTest('test_struct.py', usemodules='struct'), + RegrTest('test_structmembers.py', skip="CPython specific"), RegrTest('test_structseq.py'), RegrTest('test_subprocess.py', usemodules='signal'), RegrTest('test_sunaudiodev.py', skip=True), Modified: pypy/trunk/lib-python/failure_list.txt ============================================================================== --- pypy/trunk/lib-python/failure_list.txt (original) +++ pypy/trunk/lib-python/failure_list.txt Wed Jan 14 12:30:02 2009 @@ -27,7 +27,7 @@ test_format test checking for exact exception messages test_gc internal stuff, we may want to provide placeholders test_generators ! I really hate our bytecode compiler :-( -test_genexps ! Fatal RPython error: InternalCompilerError :-( +test_genexps ! failing doctests test_gettext ! check this use of unicode() test_grammar implementation detail test_hmac ! looks bad! SHOULD BE FIXED NOW, check the nightly tests @@ -69,7 +69,6 @@ test_sort implementation detail test_sqlite ! why no sqlite available? test_startfile what is os.startfile? -test_str arigo probably skip, investigate test_structmembers CPython-only test_subprocess ! missing resource.error. no clue about os.fpathconf(). test_syntax more small hacking here and there in the ast compiler From fijal at codespeak.net Wed Jan 14 12:39:21 2009 From: fijal at codespeak.net (fijal at codespeak.net) Date: Wed, 14 Jan 2009 12:39:21 +0100 (CET) Subject: [pypy-svn] r60947 - pypy/trunk/pypy/lib/app_test Message-ID: <20090114113921.283251684A9@codespeak.net> Author: fijal Date: Wed Jan 14 12:39:20 2009 New Revision: 60947 Modified: pypy/trunk/pypy/lib/app_test/test_binascii.py Log: a more direct test showcasing the problem with base64 for email module Modified: pypy/trunk/pypy/lib/app_test/test_binascii.py ============================================================================== --- pypy/trunk/pypy/lib/app_test/test_binascii.py (original) +++ pypy/trunk/pypy/lib/app_test/test_binascii.py Wed Jan 14 12:39:20 2009 @@ -146,3 +146,8 @@ f = getattr(binascii, n) f('') binascii.crc_hqx('', 0) + +def test_wrong_padding(): + skip("fails") + s = 'CSixpLDtKSC/7Liuvsax4iC6uLmwMcijIKHaILzSwd/H0SC8+LCjwLsgv7W/+Mj3IQ' + raises(binascii.Error, binascii.a2b_base64, s) From fijal at codespeak.net Wed Jan 14 13:24:25 2009 From: fijal at codespeak.net (fijal at codespeak.net) Date: Wed, 14 Jan 2009 13:24:25 +0100 (CET) Subject: [pypy-svn] r60948 - in pypy/trunk/pypy/lib: . app_test Message-ID: <20090114122425.550721684A9@codespeak.net> Author: fijal Date: Wed Jan 14 13:24:21 2009 New Revision: 60948 Modified: pypy/trunk/pypy/lib/app_test/test_binascii.py pypy/trunk/pypy/lib/binascii.py Log: * make a2b_base64 not O(n^2) * try to repeat when to report an incorrect padding Modified: pypy/trunk/pypy/lib/app_test/test_binascii.py ============================================================================== --- pypy/trunk/pypy/lib/app_test/test_binascii.py (original) +++ pypy/trunk/pypy/lib/app_test/test_binascii.py Wed Jan 14 13:24:21 2009 @@ -148,6 +148,5 @@ binascii.crc_hqx('', 0) def test_wrong_padding(): - skip("fails") s = 'CSixpLDtKSC/7Liuvsax4iC6uLmwMcijIKHaILzSwd/H0SC8+LCjwLsgv7W/+Mj3IQ' raises(binascii.Error, binascii.a2b_base64, s) Modified: pypy/trunk/pypy/lib/binascii.py ============================================================================== --- pypy/trunk/pypy/lib/binascii.py (original) +++ pypy/trunk/pypy/lib/binascii.py Wed Jan 14 13:24:21 2009 @@ -136,22 +136,36 @@ def a2b_base64(s): s = s.rstrip() # clean out all invalid characters, this also strips the final '=' padding + # check for correct padding + if not s or s.startswith('='): + count = 0 + else: + count = 0 + while s[len(s)-count-1] == '=': + count += 1 clean_s = [] for item in s: if item in table_a2b_base64: clean_s.append(item) + if len(clean_s) % 4 == 1: + if count != 2: + raise Error("incorrect padding") + if len(clean_s) % 4 == 2: + if count != 1: + raise Error("incorrect padding") s = ''.join(clean_s) - # Add '=' padding back into the string if len(s) % 4: s = s + ('=' * (4 - len(s) % 4)) + + # Add '=' padding back into the string def quadruplets_gen(s): - while s: + l = [s[i:i+4] for i in range(0, len(s), 4)] + for s in l: yield (table_a2b_base64[s[0]], table_a2b_base64[s[1]], table_a2b_base64[s[2]], table_a2b_base64[s[3]]) - s = s[4:] result = [ chr(A << 2 | ((B >> 4) & 0x3)) + From fijal at codespeak.net Wed Jan 14 13:28:46 2009 From: fijal at codespeak.net (fijal at codespeak.net) Date: Wed, 14 Jan 2009 13:28:46 +0100 (CET) Subject: [pypy-svn] r60949 - pypy/trunk/pypy/lib Message-ID: <20090114122846.E24921684AB@codespeak.net> Author: fijal Date: Wed Jan 14 13:28:46 2009 New Revision: 60949 Modified: pypy/trunk/pypy/lib/binascii.py Log: I think this comes this way... Modified: pypy/trunk/pypy/lib/binascii.py ============================================================================== --- pypy/trunk/pypy/lib/binascii.py (original) +++ pypy/trunk/pypy/lib/binascii.py Wed Jan 14 13:28:46 2009 @@ -148,10 +148,10 @@ if item in table_a2b_base64: clean_s.append(item) if len(clean_s) % 4 == 1: - if count != 2: + if count < 1: raise Error("incorrect padding") if len(clean_s) % 4 == 2: - if count != 1: + if count < 2: raise Error("incorrect padding") s = ''.join(clean_s) if len(s) % 4: From antocuni at codespeak.net Wed Jan 14 13:48:36 2009 From: antocuni at codespeak.net (antocuni at codespeak.net) Date: Wed, 14 Jan 2009 13:48:36 +0100 (CET) Subject: [pypy-svn] r60950 - in pypy/trunk/pypy/interpreter: . test Message-ID: <20090114124836.4DB53168494@codespeak.net> Author: antocuni Date: Wed Jan 14 13:48:35 2009 New Revision: 60950 Modified: pypy/trunk/pypy/interpreter/generator.py pypy/trunk/pypy/interpreter/test/test_generator.py Log: make sure to close() the generator object when it's finalized. Reviews welcome Modified: pypy/trunk/pypy/interpreter/generator.py ============================================================================== --- pypy/trunk/pypy/interpreter/generator.py (original) +++ pypy/trunk/pypy/interpreter/generator.py Wed Jan 14 13:48:35 2009 @@ -110,3 +110,6 @@ if w_retval is not None: msg = "generator ignored GeneratorExit" raise OperationError(space.w_RuntimeError, space.wrap(msg)) + + def __del__(self): + self.descr_close() Modified: pypy/trunk/pypy/interpreter/test/test_generator.py ============================================================================== --- pypy/trunk/pypy/interpreter/test/test_generator.py (original) +++ pypy/trunk/pypy/interpreter/test/test_generator.py Wed Jan 14 13:48:35 2009 @@ -156,6 +156,23 @@ g.next() raises(RuntimeError, g.close) + def test_close_on_collect(self): + ## we need to exec it, else it won't run on python2.4 + exec """ + def f(): + try: + yield + finally: + f.x = 42 + """.strip() in locals(), locals() + + g = f() + g.next() + del g + import gc + gc.collect() + assert f.x == 42 + def test_generator_raises_typeerror(self): def f(): yield 1 From fijal at codespeak.net Wed Jan 14 13:49:21 2009 From: fijal at codespeak.net (fijal at codespeak.net) Date: Wed, 14 Jan 2009 13:49:21 +0100 (CET) Subject: [pypy-svn] r60951 - in pypy/trunk/pypy/lib: . app_test Message-ID: <20090114124921.096021684A8@codespeak.net> Author: fijal Date: Wed Jan 14 13:49:20 2009 New Revision: 60951 Modified: pypy/trunk/pypy/lib/app_test/test_binascii.py pypy/trunk/pypy/lib/binascii.py Log: this is taken directly from cpython source. I'm fed up with trying to dig when the padding is correct and when it's not. It's actually simpler and more correct (and faster) and more rpython. Modified: pypy/trunk/pypy/lib/app_test/test_binascii.py ============================================================================== --- pypy/trunk/pypy/lib/app_test/test_binascii.py (original) +++ pypy/trunk/pypy/lib/app_test/test_binascii.py Wed Jan 14 13:49:20 2009 @@ -150,3 +150,7 @@ def test_wrong_padding(): s = 'CSixpLDtKSC/7Liuvsax4iC6uLmwMcijIKHaILzSwd/H0SC8+LCjwLsgv7W/+Mj3IQ' raises(binascii.Error, binascii.a2b_base64, s) + +def test_crap_after_padding(): + s = 'xxx=axxxx' + assert binascii.a2b_base64(s) == '\xc7\x1c' Modified: pypy/trunk/pypy/lib/binascii.py ============================================================================== --- pypy/trunk/pypy/lib/binascii.py (original) +++ pypy/trunk/pypy/lib/binascii.py Wed Jan 14 13:49:20 2009 @@ -130,6 +130,7 @@ '9': 61, '+': 62, '/': 63, + '=': 0, } @@ -137,67 +138,46 @@ s = s.rstrip() # clean out all invalid characters, this also strips the final '=' padding # check for correct padding - if not s or s.startswith('='): - count = 0 - else: - count = 0 - while s[len(s)-count-1] == '=': - count += 1 - clean_s = [] - for item in s: - if item in table_a2b_base64: - clean_s.append(item) - if len(clean_s) % 4 == 1: - if count < 1: - raise Error("incorrect padding") - if len(clean_s) % 4 == 2: - if count < 2: - raise Error("incorrect padding") - s = ''.join(clean_s) - if len(s) % 4: - s = s + ('=' * (4 - len(s) % 4)) - - # Add '=' padding back into the string - - def quadruplets_gen(s): - l = [s[i:i+4] for i in range(0, len(s), 4)] - for s in l: - yield (table_a2b_base64[s[0]], - table_a2b_base64[s[1]], - table_a2b_base64[s[2]], - table_a2b_base64[s[3]]) - - result = [ - chr(A << 2 | ((B >> 4) & 0x3)) + - chr((B & 0xf) << 4 | ((C >> 2 ) & 0xf)) + - chr((C & 0x3) << 6 | D ) - for A, B, C, D in quadruplets_gen(s[:-4])] - if s: - try: - final = s[-4:] - if final[2] == '=': - A = table_a2b_base64[final[0]] - B = table_a2b_base64[final[1]] - snippet = chr(A << 2 | ((B >> 4) & 0x3)) - elif final[3] == '=': - A = table_a2b_base64[final[0]] - B = table_a2b_base64[final[1]] - C = table_a2b_base64[final[2]] - snippet = chr(A << 2 | ((B >> 4) & 0x3)) + \ - chr((B & 0xf) << 4 | ((C >> 2 ) & 0xf)) + def next_valid_char(s, pos): + for i in range(pos + 1, len(s)): + c = s[i] + if c < '\x7f': + try: + table_a2b_base64[c] + return c + except KeyError: + pass + return None + + quad_pos = 0 + leftbits = 0 + leftchar = 0 + res = [] + for i, c in enumerate(s): + if c > '\x7f' or c == '\n' or c == '\r' or c == ' ': + continue + if c == '=': + if quad_pos < 2 or (quad_pos == 2 and next_valid_char(s, i) != '='): + continue else: - A = table_a2b_base64[final[0]] - B = table_a2b_base64[final[1]] - C = table_a2b_base64[final[2]] - D = table_a2b_base64[final[3]] - snippet = chr(A << 2 | ((B >> 4) & 0x3)) + \ - chr((B & 0xf) << 4 | ((C >> 2 ) & 0xf)) + \ - chr((C & 0x3) << 6 | D ) - result.append(snippet) + leftbits = 0 + break + try: + next_c = table_a2b_base64[c] except KeyError: - raise Error('Incorrect padding') - return ''.join(result) + continue + quad_pos = (quad_pos + 1) & 0x03 + leftchar = (leftchar << 6) | next_c + leftbits += 6 + if leftbits >= 8: + leftbits -= 8 + res.append((leftchar >> leftbits & 0xff)) + leftchar &= ((1 << leftbits) - 1) + if leftbits != 0: + raise Error('Incorrect padding') + + return ''.join([chr(i) for i in res]) table_b2a_base64 = \ "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/" From fijal at codespeak.net Wed Jan 14 14:08:30 2009 From: fijal at codespeak.net (fijal at codespeak.net) Date: Wed, 14 Jan 2009 14:08:30 +0100 (CET) Subject: [pypy-svn] r60952 - in pypy/trunk/pypy: module/__builtin__ objspace/std/test Message-ID: <20090114130830.4FB8F1684B4@codespeak.net> Author: fijal Date: Wed Jan 14 14:08:28 2009 New Revision: 60952 Modified: pypy/trunk/pypy/module/__builtin__/interp_classobj.py pypy/trunk/pypy/objspace/std/test/test_unicodeobject.py Log: a test and a fix for oldstyle classes __unicode__ Modified: pypy/trunk/pypy/module/__builtin__/interp_classobj.py ============================================================================== --- pypy/trunk/pypy/module/__builtin__/interp_classobj.py (original) +++ pypy/trunk/pypy/module/__builtin__/interp_classobj.py Wed Jan 14 14:08:28 2009 @@ -416,6 +416,12 @@ return self.descr_repr(space) return space.call_function(w_meth) + def descr_unicode(self, space): + w_meth = self.getattr(space, space.wrap('__unicode__'), False) + if w_meth is None: + return self.descr_repr(space) + return space.call_function(w_meth) + def descr_len(self, space): w_meth = self.getattr(space, space.wrap('__len__')) w_result = space.call_function(w_meth) @@ -696,6 +702,8 @@ unwrap_spec=['self', ObjSpace]), __str__ = interp2app(W_InstanceObject.descr_str, unwrap_spec=['self', ObjSpace]), + __unicode__ = interp2app(W_InstanceObject.descr_unicode, + unwrap_spec=['self', ObjSpace]), __len__ = interp2app(W_InstanceObject.descr_len, unwrap_spec=['self', ObjSpace]), __getitem__ = interp2app(W_InstanceObject.descr_getitem, Modified: pypy/trunk/pypy/objspace/std/test/test_unicodeobject.py ============================================================================== --- pypy/trunk/pypy/objspace/std/test/test_unicodeobject.py (original) +++ pypy/trunk/pypy/objspace/std/test/test_unicodeobject.py Wed Jan 14 14:08:28 2009 @@ -686,7 +686,6 @@ assert s == u'\u1234' def test_formatting_unicode__str__2(self): - skip('XXX: do we really want to have such behaviour? CPython has not tests for that') class A: def __str__(self): return u'baz' @@ -708,3 +707,22 @@ def __unicode__(self): return u"world" assert unicode(Foo9("hello")) == u"world" + + def test_class_with_both_str_and_unicode(self): + class A(object): + def __str__(self): + return 'foo' + + def __unicode__(self): + return u'bar' + + assert unicode(A()) == u'bar' + + class A: + def __str__(self): + return 'foo' + + def __unicode__(self): + return u'bar' + + assert unicode(A()) == u'bar' From antocuni at codespeak.net Wed Jan 14 14:22:12 2009 From: antocuni at codespeak.net (antocuni at codespeak.net) Date: Wed, 14 Jan 2009 14:22:12 +0100 (CET) Subject: [pypy-svn] r60953 - pypy/trunk/lib-python/modified-2.5.2/test Message-ID: <20090114132212.DBCB2168494@codespeak.net> Author: antocuni Date: Wed Jan 14 14:22:10 2009 New Revision: 60953 Added: pypy/trunk/lib-python/modified-2.5.2/test/test_generators.py - copied, changed from r60935, pypy/trunk/lib-python/2.5.2/test/test_generators.py Log: try to make test_generators passing on pypy Copied: pypy/trunk/lib-python/modified-2.5.2/test/test_generators.py (from r60935, pypy/trunk/lib-python/2.5.2/test/test_generators.py) ============================================================================== --- pypy/trunk/lib-python/2.5.2/test/test_generators.py (original) +++ pypy/trunk/lib-python/modified-2.5.2/test/test_generators.py Wed Jan 14 14:22:10 2009 @@ -190,7 +190,7 @@ File "", line 1, in ? File "", line 2, in g File "", line 2, in f - ZeroDivisionError: integer division or modulo by zero + ZeroDivisionError: integer division by zero >>> k.next() # and the generator cannot be resumed Traceback (most recent call last): File "", line 1, in ? @@ -384,7 +384,7 @@ >>> [s for s in dir(i) if not s.startswith('_')] ['close', 'gi_frame', 'gi_running', 'next', 'send', 'throw'] >>> print i.next.__doc__ -x.next() -> the next value, or raise StopIteration +next() -> the next value, or raise StopIteration >>> iter(i) is i True >>> import types @@ -733,7 +733,7 @@ ... yield 1 Traceback (most recent call last): .. -SyntaxError: 'return' with argument inside generator (, line 3) +SyntaxError: 'return' with argument inside generator (, line 2) >>> def f(): ... yield 1 @@ -878,7 +878,7 @@ ... if 0: ... yield 2 # because it's a generator (line 10) Traceback (most recent call last): -SyntaxError: 'return' with argument inside generator (, line 10) +SyntaxError: 'return' with argument inside generator (, line 8) This one caused a crash (see SF bug 567538): @@ -1540,7 +1540,7 @@ >>> def f(): (yield bar) = y Traceback (most recent call last): ... -SyntaxError: can't assign to yield expression (, line 1) +SyntaxError: assignment to yield expression not possible (, line 1) >>> def f(): (yield bar) += y Traceback (most recent call last): @@ -1633,7 +1633,7 @@ >>> g = f() >>> g.next() ->>> g.close() +>>> g.close(); import gc; _ = gc.collect() exiting >>> g.close() # should be no-op now @@ -1654,7 +1654,7 @@ >>> g = f() >>> g.next() ->>> del g +>>> del g; import gc; _ = gc.collect() exiting @@ -1680,6 +1680,7 @@ >>> g = f() >>> g.next() >>> del g +>>> import gc; _ = gc.collect() >>> sys.stderr.getvalue().startswith( ... "Exception exceptions.RuntimeError: 'generator ignored GeneratorExit' in " ... ) @@ -1796,9 +1797,10 @@ ... ... l = Leaker() ... del l +... import gc; _ = gc.collect() ... err = sys.stderr.getvalue().strip() ... err.startswith( -... "Exception exceptions.RuntimeError: RuntimeError() in <" +... 'Exception "RuntimeError" in method __del__ of <' ... ) ... err.endswith("> ignored") ... len(err.splitlines()) From fijal at codespeak.net Wed Jan 14 14:23:08 2009 From: fijal at codespeak.net (fijal at codespeak.net) Date: Wed, 14 Jan 2009 14:23:08 +0100 (CET) Subject: [pypy-svn] r60954 - pypy/trunk/pypy/interpreter/test Message-ID: <20090114132308.829A7168494@codespeak.net> Author: fijal Date: Wed Jan 14 14:23:07 2009 New Revision: 60954 Modified: pypy/trunk/pypy/interpreter/test/test_code.py Log: a failing test for code object Modified: pypy/trunk/pypy/interpreter/test/test_code.py ============================================================================== --- pypy/trunk/pypy/interpreter/test/test_code.py (original) +++ pypy/trunk/pypy/interpreter/test/test_code.py Wed Jan 14 14:23:07 2009 @@ -63,6 +63,19 @@ for key, value in expected.items(): assert getattr(code, key) == value + def test_co_names(self): + skip("Fails") + def foo(): + pass + + g = 3 + + def f(x, y): + z = x + y + foo(g) + + assert f.func_code.co_names == ('foo', 'g') + def test_code(self): import sys try: From antocuni at codespeak.net Wed Jan 14 14:28:42 2009 From: antocuni at codespeak.net (antocuni at codespeak.net) Date: Wed, 14 Jan 2009 14:28:42 +0100 (CET) Subject: [pypy-svn] r60955 - pypy/trunk/lib-python Message-ID: <20090114132842.296F01684B5@codespeak.net> Author: antocuni Date: Wed Jan 14 14:28:41 2009 New Revision: 60955 Modified: pypy/trunk/lib-python/failure_list.txt Log: update list of failing tests Modified: pypy/trunk/lib-python/failure_list.txt ============================================================================== --- pypy/trunk/lib-python/failure_list.txt (original) +++ pypy/trunk/lib-python/failure_list.txt Wed Jan 14 14:28:41 2009 @@ -8,7 +8,6 @@ test_codecs ! unknown test_coding ! hah. fix buildbot :-/ test_commands ! unknown -test_compile ! test_leading_newlines: impl detail; the rest: not good SHOULD BE FIXED NOW, check the nightly tests test_compiler ! unknown test_ctypes ! implementation details but also some real crashes test_decimal missing decimal.ROUND_05UP @@ -26,11 +25,10 @@ test_fork1 ! why did this fail just once? test_format test checking for exact exception messages test_gc internal stuff, we may want to provide placeholders +test_generators ! I really hate our bytecode compiler :-( # SHOULD BE FIXED NOW test_generators ! I really hate our bytecode compiler :-( -test_genexps ! failing doctests test_gettext ! check this use of unicode() test_grammar implementation detail -test_hmac ! looks bad! SHOULD BE FIXED NOW, check the nightly tests test_import importing from pyc-files-without-py-file disabled by default test_importhooks ! unknown test_inspect ! test_wrapped_decorator: try to fix; isbuiltin([].append): cry and maaaybe try to fix From fijal at codespeak.net Wed Jan 14 14:47:39 2009 From: fijal at codespeak.net (fijal at codespeak.net) Date: Wed, 14 Jan 2009 14:47:39 +0100 (CET) Subject: [pypy-svn] r60957 - in pypy/trunk/pypy/interpreter: astcompiler test Message-ID: <20090114134739.241B71684B5@codespeak.net> Author: fijal Date: Wed Jan 14 14:47:38 2009 New Revision: 60957 Modified: pypy/trunk/pypy/interpreter/astcompiler/pyassem.py pypy/trunk/pypy/interpreter/test/test_code.py Log: A test and a fix (2.5 changes behavior of co_names) Modified: pypy/trunk/pypy/interpreter/astcompiler/pyassem.py ============================================================================== --- pypy/trunk/pypy/interpreter/astcompiler/pyassem.py (original) +++ pypy/trunk/pypy/interpreter/astcompiler/pyassem.py Wed Jan 14 14:47:38 2009 @@ -174,7 +174,6 @@ % name) def _convert_LOAD_FAST(self, arg): - self._lookupName(arg, self.names) return self._lookupName(arg, self.varnames) _convert_STORE_FAST = _convert_LOAD_FAST _convert_DELETE_FAST = _convert_LOAD_FAST Modified: pypy/trunk/pypy/interpreter/test/test_code.py ============================================================================== --- pypy/trunk/pypy/interpreter/test/test_code.py (original) +++ pypy/trunk/pypy/interpreter/test/test_code.py Wed Jan 14 14:47:38 2009 @@ -64,7 +64,7 @@ assert getattr(code, key) == value def test_co_names(self): - skip("Fails") + src = '''if 1: def foo(): pass @@ -73,8 +73,11 @@ def f(x, y): z = x + y foo(g) +''' + d = {} + exec src in d - assert f.func_code.co_names == ('foo', 'g') + assert list(sorted(d['f'].func_code.co_names)) == ['foo', 'g'] def test_code(self): import sys From fijal at codespeak.net Wed Jan 14 15:08:40 2009 From: fijal at codespeak.net (fijal at codespeak.net) Date: Wed, 14 Jan 2009 15:08:40 +0100 (CET) Subject: [pypy-svn] r60958 - pypy/trunk/lib-python/2.5.2/email/test/data Message-ID: <20090114140840.0A0A91684DA@codespeak.net> Author: fijal Date: Wed Jan 14 15:08:38 2009 New Revision: 60958 Modified: pypy/trunk/lib-python/2.5.2/email/test/data/msg_26.txt (props changed) Log: delete eol-style from this From fijal at codespeak.net Wed Jan 14 15:09:06 2009 From: fijal at codespeak.net (fijal at codespeak.net) Date: Wed, 14 Jan 2009 15:09:06 +0100 (CET) Subject: [pypy-svn] r60959 - pypy/trunk/lib-python/2.5.2/email/test/data Message-ID: <20090114140906.EF5201684DA@codespeak.net> Author: fijal Date: Wed Jan 14 15:09:06 2009 New Revision: 60959 Modified: pypy/trunk/lib-python/2.5.2/email/test/data/msg_26.txt Log: change eol to win Modified: pypy/trunk/lib-python/2.5.2/email/test/data/msg_26.txt ============================================================================== --- pypy/trunk/lib-python/2.5.2/email/test/data/msg_26.txt (original) +++ pypy/trunk/lib-python/2.5.2/email/test/data/msg_26.txt Wed Jan 14 15:09:06 2009 @@ -1,45 +1,45 @@ -Received: from xcar [192.168.0.2] by jeeves.wooster.local - (SMTPD32-7.07 EVAL) id AFF92F0214; Sun, 12 May 2002 08:55:37 +0100 -Date: Sun, 12 May 2002 08:56:15 +0100 -From: Father Time -To: timbo at jeeves.wooster.local -Subject: IMAP file test -Message-ID: <6df65d354b.father.time at rpc.wooster.local> -X-Organization: Home -User-Agent: Messenger-Pro/2.50a (MsgServe/1.50) (RISC-OS/4.02) POPstar/2.03 -MIME-Version: 1.0 -Content-Type: multipart/mixed; boundary="1618492860--2051301190--113853680" -Status: R -X-UIDL: 319998302 - -This message is in MIME format which your mailer apparently does not support. -You either require a newer version of your software which supports MIME, or -a separate MIME decoding utility. Alternatively, ask the sender of this -message to resend it in a different format. - ---1618492860--2051301190--113853680 -Content-Type: text/plain; charset=us-ascii - -Simple email with attachment. - - ---1618492860--2051301190--113853680 -Content-Type: application/riscos; name="clock.bmp,69c"; type=BMP; load=&fff69c4b; exec=&355dd4d1; access=&03 -Content-Disposition: attachment; filename="clock.bmp" -Content-Transfer-Encoding: base64 - -Qk12AgAAAAAAAHYAAAAoAAAAIAAAACAAAAABAAQAAAAAAAAAAADXDQAA1w0AAAAAAAAA -AAAAAAAAAAAAiAAAiAAAAIiIAIgAAACIAIgAiIgAALu7uwCIiIgAERHdACLuIgAz//8A -zAAAAN0R3QDu7iIA////AAAAAAAAAAAAAAAAAAAAAAAAAAi3AAAAAAAAADeAAAAAAAAA -C3ADMzMzMANwAAAAAAAAAAAHMAAAAANwAAAAAAAAAACAMAd3zPfwAwgAAAAAAAAIAwd/ -f8x/f3AwgAAAAAAAgDB0x/f3//zPAwgAAAAAAAcHfM9////8z/AwAAAAAAiwd/f3//// -////A4AAAAAAcEx/f///////zAMAAAAAiwfM9////3///8zwOAAAAAcHf3////B///// -8DAAAAALB/f3///wd3d3//AwAAAABwTPf//wCQAAD/zAMAAAAAsEx/f///B////8wDAA -AAAHB39////wf/////AwAAAACwf39///8H/////wMAAAAIcHfM9///B////M8DgAAAAA -sHTH///wf///xAMAAAAACHB3f3//8H////cDgAAAAAALB3zH//D//M9wMAAAAAAAgLB0 -z39///xHAwgAAAAAAAgLB3d3RHd3cDCAAAAAAAAAgLAHd0R3cAMIAAAAAAAAgAgLcAAA -AAMwgAgAAAAACDAAAAu7t7cwAAgDgAAAAABzcIAAAAAAAAgDMwAAAAAAN7uwgAAAAAgH -MzMAAAAACH97tzAAAAALu3c3gAAAAAAL+7tzDABAu7f7cAAAAAAACA+3MA7EQAv/sIAA -AAAAAAAIAAAAAAAAAIAAAAAA - ---1618492860--2051301190--113853680-- +Received: from xcar [192.168.0.2] by jeeves.wooster.local + (SMTPD32-7.07 EVAL) id AFF92F0214; Sun, 12 May 2002 08:55:37 +0100 +Date: Sun, 12 May 2002 08:56:15 +0100 +From: Father Time +To: timbo at jeeves.wooster.local +Subject: IMAP file test +Message-ID: <6df65d354b.father.time at rpc.wooster.local> +X-Organization: Home +User-Agent: Messenger-Pro/2.50a (MsgServe/1.50) (RISC-OS/4.02) POPstar/2.03 +MIME-Version: 1.0 +Content-Type: multipart/mixed; boundary="1618492860--2051301190--113853680" +Status: R +X-UIDL: 319998302 + +This message is in MIME format which your mailer apparently does not support. +You either require a newer version of your software which supports MIME, or +a separate MIME decoding utility. Alternatively, ask the sender of this +message to resend it in a different format. + +--1618492860--2051301190--113853680 +Content-Type: text/plain; charset=us-ascii + +Simple email with attachment. + + +--1618492860--2051301190--113853680 +Content-Type: application/riscos; name="clock.bmp,69c"; type=BMP; load=&fff69c4b; exec=&355dd4d1; access=&03 +Content-Disposition: attachment; filename="clock.bmp" +Content-Transfer-Encoding: base64 + +Qk12AgAAAAAAAHYAAAAoAAAAIAAAACAAAAABAAQAAAAAAAAAAADXDQAA1w0AAAAAAAAA +AAAAAAAAAAAAiAAAiAAAAIiIAIgAAACIAIgAiIgAALu7uwCIiIgAERHdACLuIgAz//8A +zAAAAN0R3QDu7iIA////AAAAAAAAAAAAAAAAAAAAAAAAAAi3AAAAAAAAADeAAAAAAAAA +C3ADMzMzMANwAAAAAAAAAAAHMAAAAANwAAAAAAAAAACAMAd3zPfwAwgAAAAAAAAIAwd/ +f8x/f3AwgAAAAAAAgDB0x/f3//zPAwgAAAAAAAcHfM9////8z/AwAAAAAAiwd/f3//// +////A4AAAAAAcEx/f///////zAMAAAAAiwfM9////3///8zwOAAAAAcHf3////B///// +8DAAAAALB/f3///wd3d3//AwAAAABwTPf//wCQAAD/zAMAAAAAsEx/f///B////8wDAA +AAAHB39////wf/////AwAAAACwf39///8H/////wMAAAAIcHfM9///B////M8DgAAAAA +sHTH///wf///xAMAAAAACHB3f3//8H////cDgAAAAAALB3zH//D//M9wMAAAAAAAgLB0 +z39///xHAwgAAAAAAAgLB3d3RHd3cDCAAAAAAAAAgLAHd0R3cAMIAAAAAAAAgAgLcAAA +AAMwgAgAAAAACDAAAAu7t7cwAAgDgAAAAABzcIAAAAAAAAgDMwAAAAAAN7uwgAAAAAgH +MzMAAAAACH97tzAAAAALu3c3gAAAAAAL+7tzDABAu7f7cAAAAAAACA+3MA7EQAv/sIAA +AAAAAAAIAAAAAAAAAIAAAAAA + +--1618492860--2051301190--113853680-- From fijal at codespeak.net Wed Jan 14 15:09:56 2009 From: fijal at codespeak.net (fijal at codespeak.net) Date: Wed, 14 Jan 2009 15:09:56 +0100 (CET) Subject: [pypy-svn] r60960 - pypy/trunk/lib-python Message-ID: <20090114140956.5DCD41684DA@codespeak.net> Author: fijal Date: Wed Jan 14 15:09:55 2009 New Revision: 60960 Modified: pypy/trunk/lib-python/failure_list.txt Log: update Modified: pypy/trunk/lib-python/failure_list.txt ============================================================================== --- pypy/trunk/lib-python/failure_list.txt (original) +++ pypy/trunk/lib-python/failure_list.txt Wed Jan 14 15:09:55 2009 @@ -16,7 +16,6 @@ test_distutils this is our issue367 test_doctest ! unknown test_dumbdbm ! oups? looks unexpected -test_email ! annoying failures, look at me test_email_codecs test skipped test_email_renamed ! same as test_email test_enumerate same as test_iterlen From fijal at codespeak.net Wed Jan 14 15:58:40 2009 From: fijal at codespeak.net (fijal at codespeak.net) Date: Wed, 14 Jan 2009 15:58:40 +0100 (CET) Subject: [pypy-svn] r60961 - pypy/trunk/pypy/module/_file/test Message-ID: <20090114145840.A38ED168480@codespeak.net> Author: fijal Date: Wed Jan 14 15:58:37 2009 New Revision: 60961 Modified: pypy/trunk/pypy/module/_file/test/test_file.py Log: A failing test for mixed readline and normal read Modified: pypy/trunk/pypy/module/_file/test/test_file.py ============================================================================== --- pypy/trunk/pypy/module/_file/test/test_file.py (original) +++ pypy/trunk/pypy/module/_file/test/test_file.py Wed Jan 14 15:58:37 2009 @@ -125,6 +125,31 @@ assert type(res) is str f.close() + + def test_readline_mixed_with_read(self): + skip("fails") + s = '''From MAILER-DAEMON Wed Jan 14 14:42:30 2009 +From: foo + +0 +From MAILER-DAEMON Wed Jan 14 14:42:44 2009 +Return-Path: +X-Original-To: gkj+person at localhost +Delivered-To: gkj+person at localhost +Received: from localhost (localhost [127.0.0.1]) + by andy.gregorykjohnson.com (Postfix) with ESMTP id 356ED9DD17 + for ; Wed, 13 Jul 2005 17:23:16 -0400 (EDT) +Delivered-To: gkj at sundance.gregorykjohnson.com''' + f = self.file(self.temppath, "w") + f.write(s) + f.close() + f = self.file(self.temppath, "r") + f.seek(0L) + f.readline() + assert f.tell() == 44L + assert f.read(12L) == 'From: foo\n\n0' + f.close() + class AppTestConcurrency(object): # these tests only really make sense on top of a translated pypy-c, # because on top of py.py the inner calls to os.write() don't @@ -255,7 +280,6 @@ assert s == "foo" assert f.closed - def test_flush_at_exit(): from pypy import conftest from pypy.tool.option import make_config, make_objspace From fijal at codespeak.net Wed Jan 14 16:04:50 2009 From: fijal at codespeak.net (fijal at codespeak.net) Date: Wed, 14 Jan 2009 16:04:50 +0100 (CET) Subject: [pypy-svn] r60962 - in pypy/trunk/pypy: module/_file/test rlib Message-ID: <20090114150450.62E411683FE@codespeak.net> Author: fijal Date: Wed Jan 14 16:04:49 2009 New Revision: 60962 Modified: pypy/trunk/pypy/module/_file/test/test_file.py pypy/trunk/pypy/rlib/streamio.py Log: missing lines.reverse() Took a couple of hours :( Modified: pypy/trunk/pypy/module/_file/test/test_file.py ============================================================================== --- pypy/trunk/pypy/module/_file/test/test_file.py (original) +++ pypy/trunk/pypy/module/_file/test/test_file.py Wed Jan 14 16:04:49 2009 @@ -127,7 +127,6 @@ def test_readline_mixed_with_read(self): - skip("fails") s = '''From MAILER-DAEMON Wed Jan 14 14:42:30 2009 From: foo Modified: pypy/trunk/pypy/rlib/streamio.py ============================================================================== --- pypy/trunk/pypy/rlib/streamio.py (original) +++ pypy/trunk/pypy/rlib/streamio.py Wed Jan 14 16:04:49 2009 @@ -564,6 +564,7 @@ data = self.lines[linenum] cutoff = len(data) - (k-n) assert cutoff >= 0 + lines.reverse() lines.append(data[:cutoff]) del self.lines[linenum:] self.lines.append(data[cutoff:]) From antocuni at codespeak.net Wed Jan 14 16:27:49 2009 From: antocuni at codespeak.net (antocuni at codespeak.net) Date: Wed, 14 Jan 2009 16:27:49 +0100 (CET) Subject: [pypy-svn] r60963 - in pypy/trunk/pypy/module/recparser: . test Message-ID: <20090114152749.8D7871684DA@codespeak.net> Author: antocuni Date: Wed Jan 14 16:27:48 2009 New Revision: 60963 Modified: pypy/trunk/pypy/module/recparser/pyparser.py pypy/trunk/pypy/module/recparser/test/test_parser.py Log: make the "parser" module taking care of futures Modified: pypy/trunk/pypy/module/recparser/pyparser.py ============================================================================== --- pypy/trunk/pypy/module/recparser/pyparser.py (original) +++ pypy/trunk/pypy/module/recparser/pyparser.py Wed Jan 14 16:27:48 2009 @@ -10,6 +10,7 @@ from pypy.interpreter.pyparser.syntaxtree import TokenNode, SyntaxNode, AbstractSyntaxVisitor from pypy.interpreter.pyparser.error import SyntaxError from pypy.interpreter.pyparser import grammar, symbol, pytoken +from pypy.interpreter.pyparser.future import getFutures from pypy.interpreter.argument import Arguments # backward compat (temp) @@ -163,11 +164,13 @@ return compiler def parse_python_source(space, source, mode): - parser = get_ast_compiler(space).get_parser() + pycompiler = get_ast_compiler(space) + parser = pycompiler.get_parser() + flags = getFutures(pycompiler.futureFlags, source) builder = grammar.BaseGrammarBuilder(debug=False, parser=parser) builder.space = space try: - parser.parse_source(source, mode, builder) + parser.parse_source(source, mode, builder, flags) return builder.stack[-1] except SyntaxError, e: raise OperationError(space.w_SyntaxError, Modified: pypy/trunk/pypy/module/recparser/test/test_parser.py ============================================================================== --- pypy/trunk/pypy/module/recparser/test/test_parser.py (original) +++ pypy/trunk/pypy/module/recparser/test/test_parser.py Wed Jan 14 16:27:48 2009 @@ -20,6 +20,16 @@ import parser parser.suite("a = 3").totuple() + def test_futures(self): + import parser + src = """ +from __future__ import with_statement +def f(): + with foo: + return 1 + """.strip() + parser.suite(src) + class AppTestRecparserErrors: def setup_class(cls): cls.space = space From antocuni at codespeak.net Wed Jan 14 17:14:01 2009 From: antocuni at codespeak.net (antocuni at codespeak.net) Date: Wed, 14 Jan 2009 17:14:01 +0100 (CET) Subject: [pypy-svn] r60965 - in pypy/trunk/pypy/interpreter: . test Message-ID: <20090114161401.E4C9B1684DE@codespeak.net> Author: antocuni Date: Wed Jan 14 17:14:01 2009 New Revision: 60965 Modified: pypy/trunk/pypy/interpreter/generator.py pypy/trunk/pypy/interpreter/test/test_generator.py Log: comment out this finalizer as it produces a segfault, and I don't feel like investigating now Modified: pypy/trunk/pypy/interpreter/generator.py ============================================================================== --- pypy/trunk/pypy/interpreter/generator.py (original) +++ pypy/trunk/pypy/interpreter/generator.py Wed Jan 14 17:14:01 2009 @@ -111,5 +111,5 @@ msg = "generator ignored GeneratorExit" raise OperationError(space.w_RuntimeError, space.wrap(msg)) - def __del__(self): - self.descr_close() +## def __del__(self): +## self.descr_close() Modified: pypy/trunk/pypy/interpreter/test/test_generator.py ============================================================================== --- pypy/trunk/pypy/interpreter/test/test_generator.py (original) +++ pypy/trunk/pypy/interpreter/test/test_generator.py Wed Jan 14 17:14:01 2009 @@ -157,6 +157,7 @@ raises(RuntimeError, g.close) def test_close_on_collect(self): + skip("uncomment the __del__ in generator.py, but it causes a segfault") ## we need to exec it, else it won't run on python2.4 exec """ def f(): From fijal at codespeak.net Wed Jan 14 23:22:10 2009 From: fijal at codespeak.net (fijal at codespeak.net) Date: Wed, 14 Jan 2009 23:22:10 +0100 (CET) Subject: [pypy-svn] r60978 - pypy/trunk/lib-python Message-ID: <20090114222210.453581684F0@codespeak.net> Author: fijal Date: Wed Jan 14 23:22:07 2009 New Revision: 60978 Modified: pypy/trunk/lib-python/failure_list.txt Log: update Modified: pypy/trunk/lib-python/failure_list.txt ============================================================================== --- pypy/trunk/lib-python/failure_list.txt (original) +++ pypy/trunk/lib-python/failure_list.txt Wed Jan 14 23:22:07 2009 @@ -17,7 +17,6 @@ test_doctest ! unknown test_dumbdbm ! oups? looks unexpected test_email_codecs test skipped -test_email_renamed ! same as test_email test_enumerate same as test_iterlen test_file some more exceptions should be raised test_float float.__getformat__() exists mainly only for tests @@ -25,7 +24,6 @@ test_format test checking for exact exception messages test_gc internal stuff, we may want to provide placeholders test_generators ! I really hate our bytecode compiler :-( # SHOULD BE FIXED NOW -test_generators ! I really hate our bytecode compiler :-( test_gettext ! check this use of unicode() test_grammar implementation detail test_import importing from pyc-files-without-py-file disabled by default From fijal at codespeak.net Wed Jan 14 23:37:46 2009 From: fijal at codespeak.net (fijal at codespeak.net) Date: Wed, 14 Jan 2009 23:37:46 +0100 (CET) Subject: [pypy-svn] r60980 - in pypy/trunk/pypy/module/fcntl: . test Message-ID: <20090114223746.28FA41684A6@codespeak.net> Author: fijal Date: Wed Jan 14 23:37:45 2009 New Revision: 60980 Modified: pypy/trunk/pypy/module/fcntl/interp_fcntl.py pypy/trunk/pypy/module/fcntl/test/test_fcntl.py Log: how-this-could-have-ever-worked kind of checkin (and a test) Modified: pypy/trunk/pypy/module/fcntl/interp_fcntl.py ============================================================================== --- pypy/trunk/pypy/module/fcntl/interp_fcntl.py (original) +++ pypy/trunk/pypy/module/fcntl/interp_fcntl.py Wed Jan 14 23:37:45 2009 @@ -167,7 +167,7 @@ rffi.setintfield(l, 'c_l_whence', 0) rffi.setintfield(l, 'c_l_start', 0) rffi.setintfield(l, 'c_l_len', 0) - op = [F_SETLKW, F_SETLK][op & LOCK_NB] + op = [F_SETLKW, F_SETLK][int(bool(op & LOCK_NB))] op = rffi.cast(rffi.INT, op) # C long => C int fcntl_flock(fd, op, l) lltype.free(l, flavor='raw') @@ -213,11 +213,7 @@ l.c_l_whence = rffi.cast(rffi.SHORT, whence) try: - try: - op = [F_SETLKW, F_SETLK][op & LOCK_NB] - except IndexError: - raise OperationError(space.w_ValueError, - space.wrap("invalid value for operation")) + op = [F_SETLKW, F_SETLK][int(bool(op & LOCK_NB))] op = rffi.cast(rffi.INT, op) # C long => C int fcntl_flock(fd, op, l) finally: Modified: pypy/trunk/pypy/module/fcntl/test/test_fcntl.py ============================================================================== --- pypy/trunk/pypy/module/fcntl/test/test_fcntl.py (original) +++ pypy/trunk/pypy/module/fcntl/test/test_fcntl.py Wed Jan 14 23:37:45 2009 @@ -191,3 +191,8 @@ res = fcntl.ioctl(0, TIOCGPGRP, "\x00\x00") assert res == expected + + def test_lockf_with_ex(self): + import fcntl + f = open(self.tmp, "w") + fcntl.lockf(f, fcntl.LOCK_EX | fcntl.LOCK_NB) From fijal at codespeak.net Thu Jan 15 00:03:21 2009 From: fijal at codespeak.net (fijal at codespeak.net) Date: Thu, 15 Jan 2009 00:03:21 +0100 (CET) Subject: [pypy-svn] r60983 - pypy/trunk/pypy/objspace/std/test Message-ID: <20090114230321.839971684E6@codespeak.net> Author: fijal Date: Thu Jan 15 00:03:20 2009 New Revision: 60983 Modified: pypy/trunk/pypy/objspace/std/test/test_userobject.py Log: a failing test for oldstyle classes Modified: pypy/trunk/pypy/objspace/std/test/test_userobject.py ============================================================================== --- pypy/trunk/pypy/objspace/std/test/test_userobject.py (original) +++ pypy/trunk/pypy/objspace/std/test/test_userobject.py Thu Jan 15 00:03:20 2009 @@ -207,6 +207,36 @@ s = repr(Foo()) assert s.startswith(' Author: fijal Date: Thu Jan 15 00:17:35 2009 New Revision: 60984 Modified: pypy/trunk/pypy/module/__builtin__/interp_classobj.py pypy/trunk/pypy/objspace/std/test/test_userobject.py Log: a fix for deleting attribute of instances of oldstyle classes Modified: pypy/trunk/pypy/module/__builtin__/interp_classobj.py ============================================================================== --- pypy/trunk/pypy/module/__builtin__/interp_classobj.py (original) +++ pypy/trunk/pypy/module/__builtin__/interp_classobj.py Thu Jan 15 00:17:35 2009 @@ -400,7 +400,11 @@ if w_meth is not None: space.call_function(w_meth, w_name) else: - self.deldictvalue(space, w_name) + if not self.deldictvalue(space, w_name): + raise OperationError( + space.w_AttributeError, + space.wrap("%s instance has no attribute %s" % ( + self.w_class.name, space.str_w(space.str(w_name))))) def descr_repr(self, space): w_meth = self.getattr(space, space.wrap('__repr__'), False) Modified: pypy/trunk/pypy/objspace/std/test/test_userobject.py ============================================================================== --- pypy/trunk/pypy/objspace/std/test/test_userobject.py (original) +++ pypy/trunk/pypy/objspace/std/test/test_userobject.py Thu Jan 15 00:17:35 2009 @@ -208,7 +208,6 @@ assert s.startswith(' Author: fijal Date: Thu Jan 15 00:20:53 2009 New Revision: 60985 Modified: pypy/trunk/lib-python/failure_list.txt Log: hopefully fixed test_mailbox, took the whole day though :-( Modified: pypy/trunk/lib-python/failure_list.txt ============================================================================== --- pypy/trunk/lib-python/failure_list.txt (original) +++ pypy/trunk/lib-python/failure_list.txt Thu Jan 15 00:20:53 2009 @@ -35,7 +35,6 @@ test_itertools same as test_iterlen test_logging ! shallow. let's just fix the __repr__ of types test_long ! easy fixes -test_mailbox ! look at me test_multibytecodec ! unknown test_mutants the test is probably too precise in the failure it expects test_new new.instancemethod(x, None) should fail, but no hurry From hpk at codespeak.net Thu Jan 15 12:01:54 2009 From: hpk at codespeak.net (hpk at codespeak.net) Date: Thu, 15 Jan 2009 12:01:54 +0100 (CET) Subject: [pypy-svn] r60989 - pypy/trunk/pypy/tool/pytest Message-ID: <20090115110154.9877A168499@codespeak.net> Author: hpk Date: Thu Jan 15 12:01:53 2009 New Revision: 60989 Modified: pypy/trunk/pypy/tool/pytest/appsupport.py pypy/trunk/pypy/tool/pytest/pypy_test_failure_demo.py Log: report the source code of a failing app-level raises statement Modified: pypy/trunk/pypy/tool/pytest/appsupport.py ============================================================================== --- pypy/trunk/pypy/tool/pytest/appsupport.py (original) +++ pypy/trunk/pypy/tool/pytest/appsupport.py Thu Jan 15 12:01:53 2009 @@ -196,7 +196,7 @@ for key, w_value in kwds_w.items(): space.setitem(w_locals, space.wrap(key), w_value) try: - space.exec_(str(source), frame.w_globals, w_locals) + space.exec_(source.compile(), frame.w_globals, w_locals) except OperationError, e: if e.match(space, w_ExpectedException): return space.sys.call('exc_info') Modified: pypy/trunk/pypy/tool/pytest/pypy_test_failure_demo.py ============================================================================== --- pypy/trunk/pypy/tool/pytest/pypy_test_failure_demo.py (original) +++ pypy/trunk/pypy/tool/pytest/pypy_test_failure_demo.py Thu Jan 15 12:01:53 2009 @@ -12,6 +12,11 @@ def test_interp_method(self): assert self.space.is_true(self.space.w_False) +def app_test_raises_in_statement(): + raises(ValueError, """ + y = x # name error + """) + def app_test_raises_something(): int("hallo") From hpk at codespeak.net Thu Jan 15 12:02:44 2009 From: hpk at codespeak.net (hpk at codespeak.net) Date: Thu, 15 Jan 2009 12:02:44 +0100 (CET) Subject: [pypy-svn] r60990 - pypy/trunk/pypy/objspace/std/test Message-ID: <20090115110244.6401E1684A9@codespeak.net> Author: hpk Date: Thu Jan 15 12:02:42 2009 New Revision: 60990 Modified: pypy/trunk/pypy/objspace/std/test/test_userobject.py Log: you can actually use "raises" at app-level also for statements Modified: pypy/trunk/pypy/objspace/std/test/test_userobject.py ============================================================================== --- pypy/trunk/pypy/objspace/std/test/test_userobject.py (original) +++ pypy/trunk/pypy/objspace/std/test/test_userobject.py Thu Jan 15 12:02:42 2009 @@ -215,12 +215,7 @@ foo = Foo() del foo.x - try: - del foo.x - except AttributeError: - pass - else: - raise Exception("DID NOT RAISE") + raises(AttributeError, "del foo.x") class Foo: def __init__(self): @@ -228,24 +223,13 @@ foo = Foo() del foo.x - - try: - del foo.x - except AttributeError: - pass - else: - raise Exception("DID NOT RAISE") + raises(AttributeError, "del foo.x") def test_del_attr_class(self): class Foo: pass - try: - del Foo.x - except AttributeError: - pass - else: - raise Exception("DID NOT RAISE") + raises(AttributeError, "del Foo.x") class AppTestWithMultiMethodVersion2(AppTestUserObject): OPTIONS = {} # for test_builtinshortcut.py From fijal at codespeak.net Thu Jan 15 14:10:15 2009 From: fijal at codespeak.net (fijal at codespeak.net) Date: Thu, 15 Jan 2009 14:10:15 +0100 (CET) Subject: [pypy-svn] r60992 - in pypy/trunk/pypy/objspace/std: . test Message-ID: <20090115131015.4E03516853D@codespeak.net> Author: fijal Date: Thu Jan 15 14:10:13 2009 New Revision: 60992 Modified: pypy/trunk/pypy/objspace/std/test/test_unicodeobject.py pypy/trunk/pypy/objspace/std/unicodeobject.py Log: a test and a fix. the thing is that now the algorithm is *exactly* like string one, but code duplication stays Modified: pypy/trunk/pypy/objspace/std/test/test_unicodeobject.py ============================================================================== --- pypy/trunk/pypy/objspace/std/test/test_unicodeobject.py (original) +++ pypy/trunk/pypy/objspace/std/test/test_unicodeobject.py Thu Jan 15 14:10:13 2009 @@ -120,6 +120,7 @@ raises(ValueError, u'abc'.split, '') raises(ValueError, u'abc'.split, u'') raises(ValueError, 'abc'.split, u'') + assert u' a b c d'.split(None, 0) == [u'a b c d'] def test_rsplit(self): assert u"".rsplit() == [] Modified: pypy/trunk/pypy/objspace/std/unicodeobject.py ============================================================================== --- pypy/trunk/pypy/objspace/std/unicodeobject.py (original) +++ pypy/trunk/pypy/objspace/std/unicodeobject.py Thu Jan 15 14:10:13 2009 @@ -659,36 +659,36 @@ return space.wrap(self.count(substr, start, end)) def unicode_split__Unicode_None_ANY(space, w_self, w_none, w_maxsplit): - self = w_self._value maxsplit = space.int_w(w_maxsplit) - parts = [] - if len(self) == 0: - return space.newlist([]) - start = 0 - end = len(self) - inword = 0 - - while maxsplit != 0 and start < end: - index = start - for index in range(start, end): - if _isspace(self[index]): - break - else: - inword = 1 + res_w = [] + value = w_self._value + length = len(value) + i = 0 + while True: + # find the beginning of the next word + while i < length: + if not value[i].isspace(): + break # found + i += 1 else: - break - if inword == 1: - parts.append(W_UnicodeObject(self[start:index])) - maxsplit -= 1 - # Eat whitespace - for start in range(index + 1, end): - if not _isspace(self[start]): - break + break # end of string, finished + + # find the end of the word + if maxsplit == 0: + j = length # take all the rest of the string else: - return space.newlist(parts) + j = i + 1 + while j < length and not value[j].isspace(): + j += 1 + maxsplit -= 1 # NB. if it's already < 0, it stays < 0 - parts.append(W_UnicodeObject(self[start:])) - return space.newlist(parts) + # the word is value[i:j] + res_w.append(W_UnicodeObject(value[i:j])) + + # continue to look from the character following the space after the word + i = j + 1 + + return space.newlist(res_w) def unicode_split__Unicode_Unicode_ANY(space, w_self, w_delim, w_maxsplit): self = w_self._value From fijal at codespeak.net Thu Jan 15 15:41:18 2009 From: fijal at codespeak.net (fijal at codespeak.net) Date: Thu, 15 Jan 2009 15:41:18 +0100 (CET) Subject: [pypy-svn] r60995 - in pypy/trunk/pypy/module/rctime: . test Message-ID: <20090115144118.4AA7316853F@codespeak.net> Author: fijal Date: Thu Jan 15 15:41:16 2009 New Revision: 60995 Modified: pypy/trunk/pypy/module/rctime/interp_time.py pypy/trunk/pypy/module/rctime/test/test_rctime.py Log: A test and a fix. Seems python has changed a bit regarding how to treat 0 Modified: pypy/trunk/pypy/module/rctime/interp_time.py ============================================================================== --- pypy/trunk/pypy/module/rctime/interp_time.py (original) +++ pypy/trunk/pypy/module/rctime/interp_time.py Thu Jan 15 15:41:16 2009 @@ -201,13 +201,22 @@ "length 9, not %d" % len(tup_w))) y = space.int_w(tup_w[0]) - rffi.setintfield(glob_buf, 'c_tm_mon', space.int_w(tup_w[1])) - rffi.setintfield(glob_buf, 'c_tm_mday', space.int_w(tup_w[2])) + tm_mon = space.int_w(tup_w[1]) + if tm_mon == 0: + tm_mon = 1 + tm_mday = space.int_w(tup_w[2]) + if tm_mday == 0: + tm_mday = 1 + tm_yday = space.int_w(tup_w[7]) + if tm_yday == 0: + tm_yday = 1 + rffi.setintfield(glob_buf, 'c_tm_mon', tm_mon) + rffi.setintfield(glob_buf, 'c_tm_mday', tm_mday) rffi.setintfield(glob_buf, 'c_tm_hour', space.int_w(tup_w[3])) rffi.setintfield(glob_buf, 'c_tm_min', space.int_w(tup_w[4])) rffi.setintfield(glob_buf, 'c_tm_sec', space.int_w(tup_w[5])) rffi.setintfield(glob_buf, 'c_tm_wday', space.int_w(tup_w[6])) - rffi.setintfield(glob_buf, 'c_tm_yday', space.int_w(tup_w[7])) + rffi.setintfield(glob_buf, 'c_tm_yday', tm_yday) rffi.setintfield(glob_buf, 'c_tm_isdst', space.int_w(tup_w[8])) if _POSIX: # actually never happens, but makes annotator happy Modified: pypy/trunk/pypy/module/rctime/test/test_rctime.py ============================================================================== --- pypy/trunk/pypy/module/rctime/test/test_rctime.py (original) +++ pypy/trunk/pypy/module/rctime/test/test_rctime.py Thu Jan 15 15:41:16 2009 @@ -216,6 +216,8 @@ raises(TypeError, rctime.strftime, ()) raises(TypeError, rctime.strftime, (1,)) raises(TypeError, rctime.strftime, range(8)) + exp = '2000 01 01 00 00 00 1 001' + assert rctime.strftime("%Y %m %d %H %M %S %w %j", (0,)*9) == exp def test_strftime_bounds_checking(self): import time as rctime @@ -229,10 +231,8 @@ raises(ValueError, rctime.strftime, '', (-1, 1, 1, 0, 0, 0, 0, 1, -1)) raises(ValueError, rctime.strftime, '', (100, 1, 1, 0, 0, 0, 0, 1, -1)) # check month - raises(ValueError, rctime.strftime, '', (1900, 0, 1, 0, 0, 0, 0, 1, -1)) raises(ValueError, rctime.strftime, '', (1900, 13, 1, 0, 0, 0, 0, 1, -1)) # check day of month - raises(ValueError, rctime.strftime, '', (1900, 1, 0, 0, 0, 0, 0, 1, -1)) raises(ValueError, rctime.strftime, '', (1900, 1, 32, 0, 0, 0, 0, 1, -1)) # check hour raises(ValueError, rctime.strftime, '', (1900, 1, 1, -1, 0, 0, 0, 1, -1)) @@ -251,7 +251,6 @@ # modulo. raises(ValueError, rctime.strftime, '', (1900, 1, 1, 0, 0, 0, -2, 1, -1)) # check day of the year - raises(ValueError, rctime.strftime, '', (1900, 1, 1, 0, 0, 0, 0, 0, -1)) raises(ValueError, rctime.strftime, '', (1900, 1, 1, 0, 0, 0, 0, 367, -1)) # check daylight savings flag raises(ValueError, rctime.strftime, '', (1900, 1, 1, 0, 0, 0, 0, 1, -2)) From fijal at codespeak.net Thu Jan 15 15:44:17 2009 From: fijal at codespeak.net (fijal at codespeak.net) Date: Thu, 15 Jan 2009 15:44:17 +0100 (CET) Subject: [pypy-svn] r60996 - pypy/trunk/lib-python/modified-2.5.2/test Message-ID: <20090115144417.EC0E2168546@codespeak.net> Author: fijal Date: Thu Jan 15 15:44:17 2009 New Revision: 60996 Added: pypy/trunk/lib-python/modified-2.5.2/test/test_threading.py - copied, changed from r60977, pypy/trunk/lib-python/2.5.2/test/test_threading.py Log: Mark this as impl_detail Copied: pypy/trunk/lib-python/modified-2.5.2/test/test_threading.py (from r60977, pypy/trunk/lib-python/2.5.2/test/test_threading.py) ============================================================================== --- pypy/trunk/lib-python/2.5.2/test/test_threading.py (original) +++ pypy/trunk/lib-python/modified-2.5.2/test/test_threading.py Thu Jan 15 15:44:17 2009 @@ -134,6 +134,7 @@ # PyThreadState_SetAsyncExc() is a CPython-only gimmick, not (currently) # exposed at the Python level. This test relies on ctypes to get at it. + @test.test_support.impl_detail(msg="relies on ctypes access to CPython C API") def test_PyThreadState_SetAsyncExc(self): try: import ctypes From fijal at codespeak.net Thu Jan 15 15:51:20 2009 From: fijal at codespeak.net (fijal at codespeak.net) Date: Thu, 15 Jan 2009 15:51:20 +0100 (CET) Subject: [pypy-svn] r60997 - pypy/trunk/lib-python Message-ID: <20090115145120.7DCB9168551@codespeak.net> Author: fijal Date: Thu Jan 15 15:51:20 2009 New Revision: 60997 Modified: pypy/trunk/lib-python/failure_list.txt Log: these two should pass now Modified: pypy/trunk/lib-python/failure_list.txt ============================================================================== --- pypy/trunk/lib-python/failure_list.txt (original) +++ pypy/trunk/lib-python/failure_list.txt Thu Jan 15 15:51:20 2009 @@ -69,8 +69,6 @@ test_sys missing sys._current_frames() test_tarfile ! timeout? test_thread the docs say it's ok to raise thread.error here, but maybe we need to have thread.stack_size() implemented anyway (no hurry I'd say) -test_threading the failure should be marked as CPython-only -test_time ! easy fix (either bogus test or bogus time.strftime()) test_timeout skipped test test_trace probably all acceptable differences test_traceback ! don't care about '__members__', but check the other tests From fijal at codespeak.net Thu Jan 15 15:51:36 2009 From: fijal at codespeak.net (fijal at codespeak.net) Date: Thu, 15 Jan 2009 15:51:36 +0100 (CET) Subject: [pypy-svn] r60998 - pypy/trunk/lib-python Message-ID: <20090115145136.C7BC7168552@codespeak.net> Author: fijal Date: Thu Jan 15 15:51:36 2009 New Revision: 60998 Modified: pypy/trunk/lib-python/conftest.py Log: we have resource module these days Modified: pypy/trunk/lib-python/conftest.py ============================================================================== --- pypy/trunk/lib-python/conftest.py (original) +++ pypy/trunk/lib-python/conftest.py Thu Jan 15 15:51:36 2009 @@ -342,7 +342,7 @@ RegrTest('test_re.py', core=True), RegrTest('test_repr.py', core=True), - RegrTest('test_resource.py', skip="unsupported extension module"), + RegrTest('test_resource.py'), RegrTest('test_rfc822.py'), RegrTest('test_rgbimg.py', skip="unsupported extension module"), RegrTest('test_richcmp.py', core=True), From fijal at codespeak.net Thu Jan 15 15:53:20 2009 From: fijal at codespeak.net (fijal at codespeak.net) Date: Thu, 15 Jan 2009 15:53:20 +0100 (CET) Subject: [pypy-svn] r60999 - pypy/trunk/pypy/lib Message-ID: <20090115145320.3173F168551@codespeak.net> Author: fijal Date: Thu Jan 15 15:53:19 2009 New Revision: 60999 Modified: pypy/trunk/pypy/lib/resource.py Log: a bit more cpythonlike Modified: pypy/trunk/pypy/lib/resource.py ============================================================================== --- pypy/trunk/pypy/lib/resource.py (original) +++ pypy/trunk/pypy/lib/resource.py Thu Jan 15 15:53:19 2009 @@ -7,6 +7,9 @@ SimpleType) import _structseq +class error(Exception): + pass + _CONSTANTS = ( 'RLIM_INFINITY', 'RLIM_NLIMITS', @@ -66,10 +69,6 @@ optional_constants.append(key) del config -class ResourceError(OSError): - def __init__(self, errno): - OSError.__init__(self, errno) - class timeval(Structure): _fields_ = ( ("tv_sec", c_int), @@ -134,7 +133,7 @@ errno = get_errno() if errno == EINVAL: raise ValueError("invalid who parameter") - raise ResourceError(errno) + raise error(errno) return struct_rusage(( float(ru.ru_utime), float(ru.ru_stime), @@ -162,7 +161,7 @@ ret = _getrlimit(resource, byref(rlim)) if ret == -1: errno = get_errno() - raise ResourceError(errno) + raise error(errno) return (rlim.rlim_cur, rlim.rlim_max) def setrlimit(resource, rlim): @@ -178,7 +177,7 @@ elif errno == EPERM: return ValueError("not allowed to raise maximum limit") else: - raise ResourceError(errno) + raise error(errno) def getpagesize(): pagesize = 0 @@ -192,7 +191,7 @@ return sysconf("SC_PAGESIZE") __all__ = _CONSTANTS + tuple(optional_constants) + ( - 'ResourceError', 'timeval', 'struct_rusage', 'rlimit', + 'error', 'timeval', 'struct_rusage', 'rlimit', 'getrusage', 'getrlimit', 'setrlimit', 'getpagesize', ) From fijal at codespeak.net Thu Jan 15 16:06:15 2009 From: fijal at codespeak.net (fijal at codespeak.net) Date: Thu, 15 Jan 2009 16:06:15 +0100 (CET) Subject: [pypy-svn] r61000 - in pypy/trunk/pypy/module/_sre: . test Message-ID: <20090115150615.86728168552@codespeak.net> Author: fijal Date: Thu Jan 15 16:06:14 2009 New Revision: 61000 Modified: pypy/trunk/pypy/module/_sre/app_sre.py pypy/trunk/pypy/module/_sre/test/test_app_sre.py Log: a test and a fix Modified: pypy/trunk/pypy/module/_sre/app_sre.py ============================================================================== --- pypy/trunk/pypy/module/_sre/app_sre.py (original) +++ pypy/trunk/pypy/module/_sre/app_sre.py Thu Jan 15 16:06:14 2009 @@ -106,7 +106,8 @@ else: state.start = state.string_position - if n == 0: # not just an optimization -- see test_sub_unicode + if n == 0 or len(sublist) == 1: + # not just an optimization -- see test_sub_unicode return string, n if last_pos < state.end: Modified: pypy/trunk/pypy/module/_sre/test/test_app_sre.py ============================================================================== --- pypy/trunk/pypy/module/_sre/test/test_app_sre.py (original) +++ pypy/trunk/pypy/module/_sre/test/test_app_sre.py Thu Jan 15 16:06:14 2009 @@ -187,6 +187,7 @@ # following strangeish rules: assert isinstance(re.sub(u"a", u"b", "diwoiioamoi"), unicode) assert isinstance(re.sub(u"a", u"b", "diwoiiobmoi"), str) + assert isinstance(re.sub(u'x', 'y', 'x'), str) def test_sub_callable(self): import re From antocuni at codespeak.net Thu Jan 15 16:32:42 2009 From: antocuni at codespeak.net (antocuni at codespeak.net) Date: Thu, 15 Jan 2009 16:32:42 +0100 (CET) Subject: [pypy-svn] r61001 - pypy/trunk/lib-python/modified-2.5.2/test Message-ID: <20090115153242.F14ED168547@codespeak.net> Author: antocuni Date: Thu Jan 15 16:32:40 2009 New Revision: 61001 Added: pypy/trunk/lib-python/modified-2.5.2/test/test_compiler.py - copied, changed from r60954, pypy/trunk/lib-python/2.5.2/test/test_compiler.py Log: skip these two tests for now Copied: pypy/trunk/lib-python/modified-2.5.2/test/test_compiler.py (from r60954, pypy/trunk/lib-python/2.5.2/test/test_compiler.py) ============================================================================== --- pypy/trunk/lib-python/2.5.2/test/test_compiler.py (original) +++ pypy/trunk/lib-python/modified-2.5.2/test/test_compiler.py Thu Jan 15 16:32:40 2009 @@ -60,6 +60,9 @@ compiler.compile("class foo():pass\n\n","","exec") def testYieldExpr(self): + raise test.test_support.TestSkipped("our parser sucks") + # this problem is directly related to r56318, but if we revert it + # yield stops working at all compiler.compile("def g(): yield\n\n", "", "exec") def testTryExceptFinally(self): @@ -171,6 +174,8 @@ # ascii source without encdef self._testErrEnc(ascii, ascii, 19) + raise test.test_support.TestSkipped("Japanese codecs not supported yet") + # ascii source with encdef self._testErrEnc(encdef+ascii, ascii, 19) From antocuni at codespeak.net Thu Jan 15 16:48:54 2009 From: antocuni at codespeak.net (antocuni at codespeak.net) Date: Thu, 15 Jan 2009 16:48:54 +0100 (CET) Subject: [pypy-svn] r61004 - pypy/trunk/lib-python Message-ID: <20090115154854.A4AB516855E@codespeak.net> Author: antocuni Date: Thu Jan 15 16:48:54 2009 New Revision: 61004 Modified: pypy/trunk/lib-python/failure_list.txt Log: update list of failing tests Modified: pypy/trunk/lib-python/failure_list.txt ============================================================================== --- pypy/trunk/lib-python/failure_list.txt (original) +++ pypy/trunk/lib-python/failure_list.txt Thu Jan 15 16:48:54 2009 @@ -23,7 +23,7 @@ test_fork1 ! why did this fail just once? test_format test checking for exact exception messages test_gc internal stuff, we may want to provide placeholders -test_generators ! I really hate our bytecode compiler :-( # SHOULD BE FIXED NOW +test_generators ! the fix is in r60950 but doesn't work. See r60965 test_gettext ! check this use of unicode() test_grammar implementation detail test_import importing from pyc-files-without-py-file disabled by default From fijal at codespeak.net Thu Jan 15 16:50:45 2009 From: fijal at codespeak.net (fijal at codespeak.net) Date: Thu, 15 Jan 2009 16:50:45 +0100 (CET) Subject: [pypy-svn] r61005 - in pypy/trunk/pypy/objspace/std: . test Message-ID: <20090115155045.330C2168560@codespeak.net> Author: fijal Date: Thu Jan 15 16:50:44 2009 New Revision: 61005 Modified: pypy/trunk/pypy/objspace/std/stringobject.py pypy/trunk/pypy/objspace/std/stringtype.py pypy/trunk/pypy/objspace/std/test/test_unicodeobject.py pypy/trunk/pypy/objspace/std/unicodeobject.py Log: Some tests and fixes. Also fixes translation. Modified: pypy/trunk/pypy/objspace/std/stringobject.py ============================================================================== --- pypy/trunk/pypy/objspace/std/stringobject.py (original) +++ pypy/trunk/pypy/objspace/std/stringobject.py Thu Jan 15 16:50:44 2009 @@ -404,7 +404,7 @@ start = slicetype.adapt_lower_bound(space, len(self), w_start) end = slicetype.adapt_lower_bound(space, len(self), w_end) return (self, sub, start, end) -_convert_idx_params.annspecialcase = 'specialize:arg(5)' +_convert_idx_params._annspecialcase_ = 'specialize:arg(5)' def contains__String_String(space, w_self, w_sub): self = w_self._value Modified: pypy/trunk/pypy/objspace/std/stringtype.py ============================================================================== --- pypy/trunk/pypy/objspace/std/stringtype.py (original) +++ pypy/trunk/pypy/objspace/std/stringtype.py Thu Jan 15 16:50:44 2009 @@ -2,6 +2,7 @@ from pypy.objspace.std.basestringtype import basestring_typedef from sys import maxint +from pypy.rlib.objectmodel import specialize def wrapstr(space, s): from pypy.objspace.std.stringobject import W_StringObject @@ -307,6 +308,7 @@ # Helpers for several string implementations + at specialize.argtype(0) def stringendswith(u_self, suffix, start, end): begin = end - len(suffix) if begin < start: @@ -316,6 +318,7 @@ return False return True + at specialize.argtype(0) def stringstartswith(u_self, prefix, start, end): stop = start + len(prefix) if stop > end: Modified: pypy/trunk/pypy/objspace/std/test/test_unicodeobject.py ============================================================================== --- pypy/trunk/pypy/objspace/std/test/test_unicodeobject.py (original) +++ pypy/trunk/pypy/objspace/std/test/test_unicodeobject.py Thu Jan 15 16:50:44 2009 @@ -566,7 +566,7 @@ assert u'abcdefghiabc'.rfind(u'') == 12 assert u'abcdefghiabc'.rfind(u'abcd') == 0 assert u'abcdefghiabc'.rfind(u'abcz') == -1 - + assert u'abc'.rfind('', 4) == -1 def test_count(self): assert u"".count(u"x") ==0 Modified: pypy/trunk/pypy/objspace/std/unicodeobject.py ============================================================================== --- pypy/trunk/pypy/objspace/std/unicodeobject.py (original) +++ pypy/trunk/pypy/objspace/std/unicodeobject.py Thu Jan 15 16:50:44 2009 @@ -11,6 +11,7 @@ from pypy.tool.sourcetools import func_with_new_name from pypy.objspace.std.formatting import mod_format +from pypy.objspace.std.stringtype import stringstartswith, stringendswith class W_UnicodeObject(W_Object): from pypy.objspace.std.unicodetype import unicode_typedef as typedef @@ -464,67 +465,49 @@ index = length return index -def _convert_idx_params(space, w_self, w_start, w_end): +def _convert_idx_params(space, w_self, w_sub, w_start, w_end, upper_bound=False): + assert isinstance(w_sub, W_UnicodeObject) self = w_self._value - start = slicetype.adapt_bound(space, len(self), w_start) - end = slicetype.adapt_bound(space, len(self), w_end) - - assert start >= 0 - assert end >= 0 - - return (self, start, end) - -def _check_startswith_substring(str, substr, start, end): - substr_len = len(substr) - - if end - start < substr_len: - return False # substring is too long - - for i in range(substr_len): - if str[start + i] != substr[i]: - return False - return True - -def _check_endswith_substring(str, substr, start, end): - substr_len = len(substr) - - if end - start < substr_len: - return False # substring is too long - start = end - substr_len - for i in range(substr_len): - if str[start + i] != substr[i]: - return False - return True + sub = w_sub._value + if upper_bound: + start = slicetype.adapt_bound(space, len(self), w_start) + end = slicetype.adapt_bound(space, len(self), w_end) + else: + start = slicetype.adapt_lower_bound(space, len(self), w_start) + end = slicetype.adapt_lower_bound(space, len(self), w_end) + return (self, sub, start, end) +_convert_idx_params._annspecialcase_ = 'specialize:arg(5)' def unicode_endswith__Unicode_Unicode_ANY_ANY(space, w_self, w_substr, w_start, w_end): - self, start, end = _convert_idx_params(space, w_self, w_start, w_end) - substr = w_substr._value - return space.wrap(_check_endswith_substring(self, substr, start, end)) + self, substr, start, end = _convert_idx_params(space, w_self, w_substr, + w_start, w_end, True) + return space.newbool(stringendswith(self, substr, start, end)) def unicode_startswith__Unicode_Unicode_ANY_ANY(space, w_self, w_substr, w_start, w_end): - self, start, end = _convert_idx_params(space, w_self, w_start, w_end) + self, substr, start, end = _convert_idx_params(space, w_self, w_substr, + w_start, w_end, True) # XXX this stuff can be waaay better for ootypebased backends if # we re-use more of our rpython machinery (ie implement startswith # with additional parameters as rpython) - - substr = w_substr._value - return space.wrap(_check_startswith_substring(self, substr, start, end)) + return space.newbool(stringstartswith(self, substr, start, end)) def unicode_startswith__Unicode_Tuple_ANY_ANY(space, w_unistr, w_prefixes, w_start, w_end): - unistr, start, end = _convert_idx_params(space, w_unistr, w_start, w_end) + unistr, _, start, end = _convert_idx_params(space, w_unistr, space.wrap(u''), + w_start, w_end, True) for w_prefix in space.viewiterable(w_prefixes): prefix = space.unicode_w(w_prefix) - if _check_startswith_substring(unistr, prefix, start, end): + if stringstartswith(unistr, prefix, start, end): return space.w_True return space.w_False def unicode_endswith__Unicode_Tuple_ANY_ANY(space, w_unistr, w_suffixes, w_start, w_end): - unistr, start, end = _convert_idx_params(space, w_unistr, w_start, w_end) + unistr, _, start, end = _convert_idx_params(space, w_unistr, space.wrap(u''), + w_start, w_end, True) for w_suffix in space.viewiterable(w_suffixes): suffix = space.unicode_w(w_suffix) - if _check_endswith_substring(unistr, suffix, start, end): + if stringendswith(unistr, suffix, start, end): return space.w_True return space.w_False @@ -626,18 +609,18 @@ return space.newlist(lines) def unicode_find__Unicode_Unicode_ANY_ANY(space, w_self, w_substr, w_start, w_end): - self, start, end = _convert_idx_params(space, w_self, w_start, w_end) - substr = w_substr._value + self, substr, start, end = _convert_idx_params(space, w_self, w_substr, + w_start, w_end) return space.wrap(self.find(substr, start, end)) def unicode_rfind__Unicode_Unicode_ANY_ANY(space, w_self, w_substr, w_start, w_end): - self, start, end = _convert_idx_params(space, w_self, w_start, w_end) - substr = w_substr._value + self, substr, start, end = _convert_idx_params(space, w_self, w_substr, + w_start, w_end) return space.wrap(self.rfind(substr, start, end)) def unicode_index__Unicode_Unicode_ANY_ANY(space, w_self, w_substr, w_start, w_end): - self, start, end = _convert_idx_params(space, w_self, w_start, w_end) - substr = w_substr._value + self, substr, start, end = _convert_idx_params(space, w_self, w_substr, + w_start, w_end) index = self.find(substr, start, end) if index < 0: raise OperationError(space.w_ValueError, @@ -645,8 +628,8 @@ return space.wrap(index) def unicode_rindex__Unicode_Unicode_ANY_ANY(space, w_self, w_substr, w_start, w_end): - self, start, end = _convert_idx_params(space, w_self, w_start, w_end) - substr = w_substr._value + self, substr, start, end = _convert_idx_params(space, w_self, w_substr, + w_start, w_end) index = self.rfind(substr, start, end) if index < 0: raise OperationError(space.w_ValueError, @@ -654,8 +637,8 @@ return space.wrap(index) def unicode_count__Unicode_Unicode_ANY_ANY(space, w_self, w_substr, w_start, w_end): - self, start, end = _convert_idx_params(space, w_self, w_start, w_end) - substr = w_substr._value + self, substr, start, end = _convert_idx_params(space, w_self, w_substr, + w_start, w_end) return space.wrap(self.count(substr, start, end)) def unicode_split__Unicode_None_ANY(space, w_self, w_none, w_maxsplit): @@ -667,7 +650,7 @@ while True: # find the beginning of the next word while i < length: - if not value[i].isspace(): + if not _isspace(value[i]): break # found i += 1 else: @@ -678,7 +661,7 @@ j = length # take all the rest of the string else: j = i + 1 - while j < length and not value[j].isspace(): + while j < length and not _isspace(value[j]): j += 1 maxsplit -= 1 # NB. if it's already < 0, it stays < 0 From antocuni at codespeak.net Thu Jan 15 16:57:57 2009 From: antocuni at codespeak.net (antocuni at codespeak.net) Date: Thu, 15 Jan 2009 16:57:57 +0100 (CET) Subject: [pypy-svn] r61006 - pypy/trunk/lib-python/modified-2.5.2/test Message-ID: <20090115155757.B8526168568@codespeak.net> Author: antocuni Date: Thu Jan 15 16:57:55 2009 New Revision: 61006 Added: pypy/trunk/lib-python/modified-2.5.2/test/test_dumbdbm.py - copied, changed from r61003, pypy/trunk/lib-python/2.5.2/test/test_dumbdbm.py Log: don't rely on reference counting to close your files! Copied: pypy/trunk/lib-python/modified-2.5.2/test/test_dumbdbm.py (from r61003, pypy/trunk/lib-python/2.5.2/test/test_dumbdbm.py) ============================================================================== --- pypy/trunk/lib-python/2.5.2/test/test_dumbdbm.py (original) +++ pypy/trunk/lib-python/modified-2.5.2/test/test_dumbdbm.py Thu Jan 15 16:57:55 2009 @@ -85,7 +85,9 @@ # Mangle the file by adding \r before each newline data = open(_fname + '.dir').read() data = data.replace('\n', '\r\n') - open(_fname + '.dir', 'wb').write(data) + f = open(_fname + '.dir', 'wb') + f.write(data) + f.close() f = dumbdbm.open(_fname) self.assertEqual(f['1'], 'hello') From fijal at codespeak.net Thu Jan 15 16:58:25 2009 From: fijal at codespeak.net (fijal at codespeak.net) Date: Thu, 15 Jan 2009 16:58:25 +0100 (CET) Subject: [pypy-svn] r61007 - pypy/trunk/lib-python Message-ID: <20090115155825.640C516856D@codespeak.net> Author: fijal Date: Thu Jan 15 16:58:24 2009 New Revision: 61007 Modified: pypy/trunk/lib-python/conftest.py pypy/trunk/lib-python/failure_list.txt Log: this is bogus test (on my machine there is no os.startfile) Modified: pypy/trunk/lib-python/conftest.py ============================================================================== --- pypy/trunk/lib-python/conftest.py (original) +++ pypy/trunk/lib-python/conftest.py Thu Jan 15 16:58:24 2009 @@ -469,7 +469,7 @@ RegrTest('test_platform.py'), RegrTest('test_runpy.py'), RegrTest('test_sqlite.py'), - RegrTest('test_startfile.py'), + RegrTest('test_startfile.py', skip="bogus test"), RegrTest('test_structmembers.py', skip="depends on _testcapi"), RegrTest('test_urllib2_localnet.py'), RegrTest('test_uuid.py'), Modified: pypy/trunk/lib-python/failure_list.txt ============================================================================== --- pypy/trunk/lib-python/failure_list.txt (original) +++ pypy/trunk/lib-python/failure_list.txt Thu Jan 15 16:58:24 2009 @@ -51,7 +51,6 @@ test_pyexpat is that an implementation detail? test_quopri ! check if test_script{en,de}code() shows a real bug test_random should probably be fixed, but no hurry i guess -test_re obscure, looks like yet another case not covered by test_sub_unicode in pypy/module/_sre/ test_repr implementation detail test_sax ! unknown test_sets ! is this another CPython implementation detail test? @@ -62,7 +61,6 @@ test_socketserver test skipped test_sort implementation detail test_sqlite ! why no sqlite available? -test_startfile what is os.startfile? test_structmembers CPython-only test_subprocess ! missing resource.error. no clue about os.fpathconf(). test_syntax more small hacking here and there in the ast compiler From fijal at codespeak.net Thu Jan 15 17:03:51 2009 From: fijal at codespeak.net (fijal at codespeak.net) Date: Thu, 15 Jan 2009 17:03:51 +0100 (CET) Subject: [pypy-svn] r61009 - pypy/trunk/lib-python/modified-2.5.2/test Message-ID: <20090115160351.AAB7B168559@codespeak.net> Author: fijal Date: Thu Jan 15 17:03:51 2009 New Revision: 61009 Modified: pypy/trunk/lib-python/modified-2.5.2/test/test_socket.py Log: a bit hairy checkin, to have the same interface as our socket, probably needs a review Modified: pypy/trunk/lib-python/modified-2.5.2/test/test_socket.py ============================================================================== --- pypy/trunk/lib-python/modified-2.5.2/test/test_socket.py (original) +++ pypy/trunk/lib-python/modified-2.5.2/test/test_socket.py Thu Jan 15 17:03:51 2009 @@ -815,6 +815,8 @@ closed = False def flush(self): pass def close(self): self.closed = True + def _drop(self): pass + def _reuse(self): pass # must not close unless we request it: the original use of _fileobject # by module socket requires that the underlying socket not be closed until From fijal at codespeak.net Thu Jan 15 17:28:06 2009 From: fijal at codespeak.net (fijal at codespeak.net) Date: Thu, 15 Jan 2009 17:28:06 +0100 (CET) Subject: [pypy-svn] r61010 - pypy/trunk/lib-python/modified-2.5.2 Message-ID: <20090115162806.D1335168560@codespeak.net> Author: fijal Date: Thu Jan 15 17:28:04 2009 New Revision: 61010 Modified: pypy/trunk/lib-python/modified-2.5.2/socket.py Log: I *think* this is what the test was pointing out. Completely unsure though, since _drop attr is a bit mystic to me Modified: pypy/trunk/lib-python/modified-2.5.2/socket.py ============================================================================== --- pypy/trunk/lib-python/modified-2.5.2/socket.py (original) +++ pypy/trunk/lib-python/modified-2.5.2/socket.py Thu Jan 15 17:28:04 2009 @@ -247,6 +247,8 @@ if self._sock: s = self._sock self._sock = None + if self._close: + s.close() s._drop() def __del__(self): From fijal at codespeak.net Thu Jan 15 17:28:37 2009 From: fijal at codespeak.net (fijal at codespeak.net) Date: Thu, 15 Jan 2009 17:28:37 +0100 (CET) Subject: [pypy-svn] r61011 - pypy/trunk/pypy/module/_socket Message-ID: <20090115162837.2FF92168560@codespeak.net> Author: fijal Date: Thu Jan 15 17:28:36 2009 New Revision: 61011 Modified: pypy/trunk/pypy/module/_socket/interp_socket.py Log: export type as attribute Modified: pypy/trunk/pypy/module/_socket/interp_socket.py ============================================================================== --- pypy/trunk/pypy/module/_socket/interp_socket.py (original) +++ pypy/trunk/pypy/module/_socket/interp_socket.py Thu Jan 15 17:28:36 2009 @@ -473,6 +473,7 @@ [*] not available on all platforms!""", __new__ = descr_socket_new, __weakref__ = make_weakref_descr(W_RSocket), + type = interp_attrproperty('type', W_RSocket), family = interp_attrproperty('family', W_RSocket), ** socketmethods ) From fijal at codespeak.net Thu Jan 15 17:30:05 2009 From: fijal at codespeak.net (fijal at codespeak.net) Date: Thu, 15 Jan 2009 17:30:05 +0100 (CET) Subject: [pypy-svn] r61012 - pypy/trunk/lib-python Message-ID: <20090115163005.C35A9168562@codespeak.net> Author: fijal Date: Thu Jan 15 17:30:05 2009 New Revision: 61012 Modified: pypy/trunk/lib-python/failure_list.txt Log: this should work by now Modified: pypy/trunk/lib-python/failure_list.txt ============================================================================== --- pypy/trunk/lib-python/failure_list.txt (original) +++ pypy/trunk/lib-python/failure_list.txt Thu Jan 15 17:30:05 2009 @@ -57,7 +57,6 @@ test_shelve ! unknown test_signal ! missing signal.alarm(), probably easy to add test_site ! fix me -test_socket ! some failures, look test_socketserver test skipped test_sort implementation detail test_sqlite ! why no sqlite available? From antocuni at codespeak.net Thu Jan 15 18:19:07 2009 From: antocuni at codespeak.net (antocuni at codespeak.net) Date: Thu, 15 Jan 2009 18:19:07 +0100 (CET) Subject: [pypy-svn] r61014 - pypy/trunk/pypy/module/__builtin__/test Message-ID: <20090115171907.461F316856E@codespeak.net> Author: antocuni Date: Thu Jan 15 18:19:06 2009 New Revision: 61014 Modified: pypy/trunk/pypy/module/__builtin__/test/test_import.py Log: a failing test, that shows why lib-python/test_importing fails Modified: pypy/trunk/pypy/module/__builtin__/test/test_import.py ============================================================================== --- pypy/trunk/pypy/module/__builtin__/test/test_import.py (original) +++ pypy/trunk/pypy/module/__builtin__/test/test_import.py Thu Jan 15 18:19:06 2009 @@ -312,6 +312,17 @@ """ raises(ValueError, imp) + def test_relative_import_with___name__(self): + skip("fixme") + import sys + import imp + mod = imp.new_module("foo") + mod.xxx = 42 + sys.modules['foo'] = mod + mydict = {'__name__': 'foo.bar'} + exec "from . import xxx" in mydict + assert mydict['xxx'] == 42 + def test_universal_newlines(self): import pkg_univnewlines assert pkg_univnewlines.a == 5 From fijal at codespeak.net Thu Jan 15 18:46:38 2009 From: fijal at codespeak.net (fijal at codespeak.net) Date: Thu, 15 Jan 2009 18:46:38 +0100 (CET) Subject: [pypy-svn] r61015 - in pypy/trunk/pypy: module/posix rpython/module Message-ID: <20090115174638.2386716855E@codespeak.net> Author: fijal Date: Thu Jan 15 18:46:37 2009 New Revision: 61015 Modified: pypy/trunk/pypy/module/posix/__init__.py pypy/trunk/pypy/module/posix/interp_posix.py pypy/trunk/pypy/rpython/module/ll_os.py Log: A couple of missing os.* Modified: pypy/trunk/pypy/module/posix/__init__.py ============================================================================== --- pypy/trunk/pypy/module/posix/__init__.py (original) +++ pypy/trunk/pypy/module/posix/__init__.py Thu Jan 15 18:46:37 2009 @@ -86,23 +86,12 @@ interpleveldefs['sysconf_names'] = 'space.wrap(os.sysconf_names)' if hasattr(os, 'ttyname'): interpleveldefs['ttyname'] = 'interp_posix.ttyname' - if hasattr(os, 'setsid'): - interpleveldefs['setsid'] = 'interp_posix.setsid' - if hasattr(os, 'getuid'): - interpleveldefs['getuid'] = 'interp_posix.getuid' - interpleveldefs['geteuid'] = 'interp_posix.geteuid' - if hasattr(os, 'getgid'): - interpleveldefs['getgid'] = 'interp_posix.getgid' - if hasattr(os, 'getegid'): - interpleveldefs['getegid'] = 'interp_posix.getegid' - if hasattr(os, 'setuid'): - interpleveldefs['setuid'] = 'interp_posix.setuid' - if hasattr(os, 'seteuid'): - interpleveldefs['seteuid'] = 'interp_posix.seteuid' - if hasattr(os, 'setgid'): - interpleveldefs['setgid'] = 'interp_posix.setgid' - if hasattr(os, 'setegid'): - interpleveldefs['setegid'] = 'interp_posix.setegid' + + for name in ['setsid', 'getuid', 'geteuid', 'getgid', 'getegid', 'setuid', + 'seteuid', 'setgid', 'setegid', 'getpgrp', 'setpgrp', + 'getppid', 'getpgid', 'setpgid', 'setreuid', 'setregid']: + if hasattr(os, name): + interpleveldefs[name] = 'interp_posix.%s' % (name,) # not visible via os, inconsistency in nt: if hasattr(posix, '_getfullpathname'): interpleveldefs['_getfullpathname'] = 'interp_posix._getfullpathname' Modified: pypy/trunk/pypy/module/posix/interp_posix.py ============================================================================== --- pypy/trunk/pypy/module/posix/interp_posix.py (original) +++ pypy/trunk/pypy/module/posix/interp_posix.py Thu Jan 15 18:46:37 2009 @@ -651,6 +651,78 @@ return space.wrap(os.geteuid()) geteuid.unwrap_spec = [ObjSpace] +def getpgrp(space): + """ getpgrp() -> pgrp + + Return the current process group id. + """ + return space.wrap(os.getpgrp()) +getpgrp.unwrap_spec = [ObjSpace] + +def setpgrp(space): + """ setpgrp() + + Make this process a session leader. + """ + try: + os.setpgrp() + except OSError, e: + raise wrap_oserror(space, e) + return space.w_None +setpgrp.unwrap_spec = [ObjSpace] + +def getppid(space): + """ getppid() -> ppid + + Return the parent's process id. + """ + return space.wrap(os.getppid()) +getppid.unwrap_spec = [ObjSpace] + +def getpgid(space, pid): + """ getpgid(pid) -> pgid + + Call the system call getpgid(). + """ + return space.wrap(os.getpgid(pid)) +getpgid.unwrap_spec = [ObjSpace, int] + +def setpgid(space, pid, pgrp): + """ setpgid(pid, pgrp) + + Call the system call setpgid(). + """ + try: + os.setpgid(pid, pgrp) + except OSError, e: + raise wrap_oserror(space, e) + return space.w_None +setpgid.unwrap_spec = [ObjSpace, int, int] + +def setreuid(space, ruid, euid): + """ setreuid(ruid, euid) + + Set the current process's real and effective user ids. + """ + try: + os.setreuid(ruid, euid) + except OSError, e: + raise wrap_oserror(space, e) + return space.w_None +setreuid.unwrap_spec = [ObjSpace, int, int] + +def setregid(space, rgid, egid): + """ setregid(rgid, egid) + + Set the current process's real and effective group ids. + """ + try: + os.setregid(rgid, egid) + except OSError, e: + raise wrap_oserror(space, e) + return space.w_None +setregid.unwrap_spec = [ObjSpace, int, int] + def declare_new_w_star(name): if name in RegisterOs.w_star_returning_int: def WSTAR(space, status): Modified: pypy/trunk/pypy/rpython/module/ll_os.py ============================================================================== --- pypy/trunk/pypy/rpython/module/ll_os.py (original) +++ pypy/trunk/pypy/rpython/module/ll_os.py Thu Jan 15 18:46:37 2009 @@ -119,7 +119,7 @@ return extdef([], int, llimpl=c_func_llimpl, export_name='ll_os.ll_os_' + name) - def extdef_for_function_int_to_int(self, name, **kwds): + def extdef_for_function_accepting_int(self, name, **kwds): c_func = self.llexternal(name, [rffi.INT], rffi.INT, **kwds) def c_func_llimpl(arg): res = rffi.cast(rffi.LONG, c_func(arg)) @@ -131,6 +131,31 @@ return extdef([int], None, llimpl=c_func_llimpl, export_name='ll_os.ll_os_' + name) + def extdef_for_function_accepting_2int(self, name, **kwds): + c_func = self.llexternal(name, [rffi.INT, rffi.INT], rffi.INT, **kwds) + def c_func_llimpl(arg, arg2): + res = rffi.cast(rffi.LONG, c_func(arg, arg2)) + if res == -1: + raise OSError(rposix.get_errno(), "%s failed" % name) + + c_func_llimpl.func_name = name + '_llimpl' + + return extdef([int, int], None, llimpl=c_func_llimpl, + export_name='ll_os.ll_os_' + name) + + def extdef_for_function_int_to_int(self, name, **kwds): + c_func = self.llexternal(name, [rffi.INT], rffi.INT, **kwds) + def c_func_llimpl(arg): + res = rffi.cast(rffi.LONG, c_func(arg)) + if res == -1: + raise OSError(rposix.get_errno(), "%s failed" % name) + return res + + c_func_llimpl.func_name = name + '_llimpl' + + return extdef([int], int, llimpl=c_func_llimpl, + export_name='ll_os.ll_os_' + name) + @registering_if(os, 'execv') def register_os_execv(self): eci = self.gcc_profiling_bug_workaround( @@ -465,19 +490,19 @@ @registering_if(os, 'setuid') def register_os_setuid(self): - return self.extdef_for_function_int_to_int('setuid') + return self.extdef_for_function_accepting_int('setuid') @registering_if(os, 'seteuid') def register_os_seteuid(self): - return self.extdef_for_function_int_to_int('seteuid') + return self.extdef_for_function_accepting_int('seteuid') @registering_if(os, 'setgid') def register_os_setgid(self): - return self.extdef_for_function_int_to_int('setgid') + return self.extdef_for_function_accepting_int('setgid') @registering_if(os, 'setegid') def register_os_setegid(self): - return self.extdef_for_function_int_to_int('setegid') + return self.extdef_for_function_accepting_int('setegid') @registering_if(os, 'getpid') def register_os_getpid(self): @@ -490,7 +515,34 @@ @registering_if(os, 'getegid') def register_os_getegid(self): return self.extdef_for_os_function_returning_int('getegid') - + + @registering_if(os, 'getpgrp') + def register_os_getpgrp(self): + return self.extdef_for_os_function_returning_int('getpgrp') + + @registering_if(os, 'setpgrp') + def register_os_setpgrp(self): + return self.extdef_for_os_function_returning_int('setpgrp') + + @registering_if(os, 'getppid') + def register_os_getppid(self): + return self.extdef_for_os_function_returning_int('getppid') + + @registering_if(os, 'getpgid') + def register_os_getpgid(self): + return self.extdef_for_function_int_to_int('getpgid') + + @registering_if(os, 'setpgid') + def register_os_setpgid(self): + return self.extdef_for_function_accepting_2int('setpgid') + + @registering_if(os, 'setreuid') + def register_os_setreuid(self): + return self.extdef_for_function_accepting_2int('setreuid') + + @registering_if(os, 'setregid') + def register_os_setregid(self): + return self.extdef_for_function_accepting_2int('setregid') @registering(os.open) def register_os_open(self): From getxsick at codespeak.net Thu Jan 15 19:09:56 2009 From: getxsick at codespeak.net (getxsick at codespeak.net) Date: Thu, 15 Jan 2009 19:09:56 +0100 (CET) Subject: [pypy-svn] r61016 - pypy/extradoc/sprintinfo/wroclaw2009 Message-ID: <20090115180956.45119168573@codespeak.net> Author: getxsick Date: Thu Jan 15 19:09:55 2009 New Revision: 61016 Modified: pypy/extradoc/sprintinfo/wroclaw2009/announcement.txt Log: add accomodation info Modified: pypy/extradoc/sprintinfo/wroclaw2009/announcement.txt ============================================================================== --- pypy/extradoc/sprintinfo/wroclaw2009/announcement.txt (original) +++ pypy/extradoc/sprintinfo/wroclaw2009/announcement.txt Thu Jan 15 19:09:55 2009 @@ -62,6 +62,20 @@ Warsaw (5h by train), Berlin (6h by train), Poznan (2h by train), Katowice (3h by train) or Krak?w (4h by train). +------------ +Accomodation +------------ + +Unfortunately, there aren't any hotels in really close area to sprint venue. +There are a lot of hotels in city centre area and it's like 10-20 mins far away. +List of possible accomodations: + +* http://www.wroclaw.pl/m6874/p7318.aspx (hotels) +* http://www.wroclaw.pl/m6875/p7137.aspx (hostels) + +You can simple check the location at http://maps.google.com +If you have any additional questions or advice, drop a line to Bartosz Skowron. + -------------------------------------- Preparation (if you feel it is needed) -------------------------------------- From getxsick at codespeak.net Thu Jan 15 19:26:04 2009 From: getxsick at codespeak.net (getxsick at codespeak.net) Date: Thu, 15 Jan 2009 19:26:04 +0100 (CET) Subject: [pypy-svn] r61018 - pypy/extradoc/sprintinfo/wroclaw2009 Message-ID: <20090115182604.1B7A7168577@codespeak.net> Author: getxsick Date: Thu Jan 15 19:26:02 2009 New Revision: 61018 Modified: pypy/extradoc/sprintinfo/wroclaw2009/announcement.txt Log: typo Modified: pypy/extradoc/sprintinfo/wroclaw2009/announcement.txt ============================================================================== --- pypy/extradoc/sprintinfo/wroclaw2009/announcement.txt (original) +++ pypy/extradoc/sprintinfo/wroclaw2009/announcement.txt Thu Jan 15 19:26:02 2009 @@ -67,7 +67,7 @@ ------------ Unfortunately, there aren't any hotels in really close area to sprint venue. -There are a lot of hotels in city centre area and it's like 10-20 mins far away. +There is a lot of hotels in city centre area and it's like 10-20 mins far away. List of possible accomodations: * http://www.wroclaw.pl/m6874/p7318.aspx (hotels) From fijal at codespeak.net Thu Jan 15 19:34:51 2009 From: fijal at codespeak.net (fijal at codespeak.net) Date: Thu, 15 Jan 2009 19:34:51 +0100 (CET) Subject: [pypy-svn] r61019 - pypy/trunk/lib-python Message-ID: <20090115183451.5F90016854E@codespeak.net> Author: fijal Date: Thu Jan 15 19:34:50 2009 New Revision: 61019 Modified: pypy/trunk/lib-python/failure_list.txt Log: update Modified: pypy/trunk/lib-python/failure_list.txt ============================================================================== --- pypy/trunk/lib-python/failure_list.txt (original) +++ pypy/trunk/lib-python/failure_list.txt Thu Jan 15 19:34:50 2009 @@ -29,8 +29,6 @@ test_import importing from pyc-files-without-py-file disabled by default test_importhooks ! unknown test_inspect ! test_wrapped_decorator: try to fix; isbuiltin([].append): cry and maaaybe try to fix -test_ioctl missing os.getpgrp() -test_isinstance ! mark the recursion limit tests as CPython-specific test_iterlen somehow implementation detail (missing __length_hint__()) test_itertools same as test_iterlen test_logging ! shallow. let's just fix the __repr__ of types From antocuni at codespeak.net Thu Jan 15 19:43:30 2009 From: antocuni at codespeak.net (antocuni at codespeak.net) Date: Thu, 15 Jan 2009 19:43:30 +0100 (CET) Subject: [pypy-svn] r61020 - pypy/trunk/lib-python Message-ID: <20090115184330.3953416856E@codespeak.net> Author: antocuni Date: Thu Jan 15 19:43:29 2009 New Revision: 61020 Modified: pypy/trunk/lib-python/failure_list.txt Log: update Modified: pypy/trunk/lib-python/failure_list.txt ============================================================================== --- pypy/trunk/lib-python/failure_list.txt (original) +++ pypy/trunk/lib-python/failure_list.txt Thu Jan 15 19:43:29 2009 @@ -15,7 +15,6 @@ test_dis probably not worth the pain of whacking at the compiler test_distutils this is our issue367 test_doctest ! unknown -test_dumbdbm ! oups? looks unexpected test_email_codecs test skipped test_enumerate same as test_iterlen test_file some more exceptions should be raised @@ -32,7 +31,6 @@ test_iterlen somehow implementation detail (missing __length_hint__()) test_itertools same as test_iterlen test_logging ! shallow. let's just fix the __repr__ of types -test_long ! easy fixes test_multibytecodec ! unknown test_mutants the test is probably too precise in the failure it expects test_new new.instancemethod(x, None) should fail, but no hurry From fijal at codespeak.net Fri Jan 16 09:54:31 2009 From: fijal at codespeak.net (fijal at codespeak.net) Date: Fri, 16 Jan 2009 09:54:31 +0100 (CET) Subject: [pypy-svn] r61025 - in pypy/branch/oo-jit/pypy/rpython/lltypesystem: . test Message-ID: <20090116085431.EF844169E04@codespeak.net> Author: fijal Date: Fri Jan 16 09:54:30 2009 New Revision: 61025 Modified: pypy/branch/oo-jit/pypy/rpython/lltypesystem/ll2ctypes.py pypy/branch/oo-jit/pypy/rpython/lltypesystem/test/test_ll2ctypes.py Log: Since we're keeping all the callbacks alive forever, let's cache them. This makes lltype2ctypes return the same number for the same pointer Modified: pypy/branch/oo-jit/pypy/rpython/lltypesystem/ll2ctypes.py ============================================================================== --- pypy/branch/oo-jit/pypy/rpython/lltypesystem/ll2ctypes.py (original) +++ pypy/branch/oo-jit/pypy/rpython/lltypesystem/ll2ctypes.py Fri Jan 16 09:54:30 2009 @@ -433,7 +433,8 @@ # ctypes does not keep callback arguments alive. So we do. Forever # we need to think deeper how to approach this problem # additionally, this adds mess to __del__ "semantics" -_all_callbacks = [] +_all_callbacks = {} +_all_callback_results = [] _callback2obj = {} # this is just another hack that passes around references to applevel types @@ -479,6 +480,8 @@ return new_opaque_object(llobj) container = llobj._obj if isinstance(T.TO, lltype.FuncType): + if llobj._obj in _all_callbacks: + return _all_callbacks[llobj._obj] v1voidlist = [(i, getattr(container, '_void' + str(i), None)) for i in range(len(T.TO.ARGS)) if T.TO.ARGS[i] is lltype.Void] @@ -505,7 +508,7 @@ return None res = lltype2ctypes(llres) if isinstance(T.TO.RESULT, lltype.Ptr): - _all_callbacks.append(res) + _all_callbacks_results.append(res) res = ctypes.cast(res, ctypes.c_void_p).value if res is None: return 0 @@ -530,8 +533,8 @@ else: ctypes_func_type = get_ctypes_type(T) res = ctypes_func_type(callback) - _all_callbacks.append(res) _callback2obj[ctypes.cast(res, ctypes.c_void_p).value] = container + _all_callbacks[llobj._obj] = res return res if container._storage is None: Modified: pypy/branch/oo-jit/pypy/rpython/lltypesystem/test/test_ll2ctypes.py ============================================================================== --- pypy/branch/oo-jit/pypy/rpython/lltypesystem/test/test_ll2ctypes.py (original) +++ pypy/branch/oo-jit/pypy/rpython/lltypesystem/test/test_ll2ctypes.py Fri Jan 16 09:54:30 2009 @@ -364,7 +364,9 @@ return n+1 FUNCTYPE = lltype.FuncType([lltype.Signed], lltype.Signed) - cdummy = lltype2ctypes(llhelper(lltype.Ptr(FUNCTYPE), dummy)) + helper = llhelper(lltype.Ptr(FUNCTYPE), dummy) + cdummy = lltype2ctypes(helper) + cdummy2 = lltype2ctypes(helper) assert isinstance(cdummy, ctypes.CFUNCTYPE(ctypes.c_long, ctypes.c_long)) res = cdummy(41) From fijal at codespeak.net Fri Jan 16 10:15:53 2009 From: fijal at codespeak.net (fijal at codespeak.net) Date: Fri, 16 Jan 2009 10:15:53 +0100 (CET) Subject: [pypy-svn] r61026 - pypy/trunk/pypy/module/_sre Message-ID: <20090116091553.2C37116855C@codespeak.net> Author: fijal Date: Fri Jan 16 10:15:51 2009 New Revision: 61026 Modified: pypy/trunk/pypy/module/_sre/app_sre.py Log: oops. Modified: pypy/trunk/pypy/module/_sre/app_sre.py ============================================================================== --- pypy/trunk/pypy/module/_sre/app_sre.py (original) +++ pypy/trunk/pypy/module/_sre/app_sre.py Fri Jan 16 10:15:51 2009 @@ -106,12 +106,13 @@ else: state.start = state.string_position + if last_pos < state.end: + sublist.append(string[last_pos:state.end]) + if n == 0 or len(sublist) == 1: # not just an optimization -- see test_sub_unicode return string, n - if last_pos < state.end: - sublist.append(string[last_pos:state.end]) if need_unicode: item = u"".join(sublist) else: From fijal at codespeak.net Fri Jan 16 10:16:59 2009 From: fijal at codespeak.net (fijal at codespeak.net) Date: Fri, 16 Jan 2009 10:16:59 +0100 (CET) Subject: [pypy-svn] r61027 - pypy/trunk/pypy/module/_socket Message-ID: <20090116091659.5977B16855C@codespeak.net> Author: fijal Date: Fri Jan 16 10:16:58 2009 New Revision: 61027 Modified: pypy/trunk/pypy/module/_socket/interp_socket.py Log: export proto attribute as well Modified: pypy/trunk/pypy/module/_socket/interp_socket.py ============================================================================== --- pypy/trunk/pypy/module/_socket/interp_socket.py (original) +++ pypy/trunk/pypy/module/_socket/interp_socket.py Fri Jan 16 10:16:58 2009 @@ -474,6 +474,7 @@ __new__ = descr_socket_new, __weakref__ = make_weakref_descr(W_RSocket), type = interp_attrproperty('type', W_RSocket), + proto = interp_attrproperty('proto', W_RSocket), family = interp_attrproperty('family', W_RSocket), ** socketmethods ) From fijal at codespeak.net Fri Jan 16 10:22:15 2009 From: fijal at codespeak.net (fijal at codespeak.net) Date: Fri, 16 Jan 2009 10:22:15 +0100 (CET) Subject: [pypy-svn] r61028 - in pypy/trunk/pypy: module/posix rpython/module Message-ID: <20090116092215.EDC02169E23@codespeak.net> Author: fijal Date: Fri Jan 16 10:22:14 2009 New Revision: 61028 Modified: pypy/trunk/pypy/module/posix/__init__.py pypy/trunk/pypy/module/posix/interp_posix.py pypy/trunk/pypy/rpython/module/ll_os.py Log: os.{get,set}sid Modified: pypy/trunk/pypy/module/posix/__init__.py ============================================================================== --- pypy/trunk/pypy/module/posix/__init__.py (original) +++ pypy/trunk/pypy/module/posix/__init__.py Fri Jan 16 10:22:14 2009 @@ -89,7 +89,8 @@ for name in ['setsid', 'getuid', 'geteuid', 'getgid', 'getegid', 'setuid', 'seteuid', 'setgid', 'setegid', 'getpgrp', 'setpgrp', - 'getppid', 'getpgid', 'setpgid', 'setreuid', 'setregid']: + 'getppid', 'getpgid', 'setpgid', 'setreuid', 'setregid', + 'getsid', 'setsid']: if hasattr(os, name): interpleveldefs[name] = 'interp_posix.%s' % (name,) # not visible via os, inconsistency in nt: Modified: pypy/trunk/pypy/module/posix/interp_posix.py ============================================================================== --- pypy/trunk/pypy/module/posix/interp_posix.py (original) +++ pypy/trunk/pypy/module/posix/interp_posix.py Fri Jan 16 10:22:14 2009 @@ -723,6 +723,26 @@ return space.w_None setregid.unwrap_spec = [ObjSpace, int, int] +def getsid(space, pid): + """ getsid(pid) -> sid + + Call the system call getsid(). + """ + return space.wrap(os.getsid(pid)) +getsid.unwrap_spec = [ObjSpace, int] + +def setsid(space): + """ setsid() + + Call the system call setsid(). + """ + try: + os.setsid() + except OSError, e: + raise wrap_oserror(space, e) + return space.w_None +setsid.unwrap_spec = [ObjSpace] + def declare_new_w_star(name): if name in RegisterOs.w_star_returning_int: def WSTAR(space, status): Modified: pypy/trunk/pypy/rpython/module/ll_os.py ============================================================================== --- pypy/trunk/pypy/rpython/module/ll_os.py (original) +++ pypy/trunk/pypy/rpython/module/ll_os.py Fri Jan 16 10:22:14 2009 @@ -544,6 +544,14 @@ def register_os_setregid(self): return self.extdef_for_function_accepting_2int('setregid') + @registering_if(os, 'getsid') + def register_os_getsid(self): + return self.extdef_for_function_int_to_int('getsid') + + @registering_if(os, 'setsid') + def register_os_setsid(self): + return self.extdef_for_os_function_returning_int('setsid') + @registering(os.open) def register_os_open(self): os_open = self.llexternal(underscore_on_windows+'open', From fijal at codespeak.net Fri Jan 16 11:59:52 2009 From: fijal at codespeak.net (fijal at codespeak.net) Date: Fri, 16 Jan 2009 11:59:52 +0100 (CET) Subject: [pypy-svn] r61031 - pypy/branch/oo-jit/pypy/rpython/lltypesystem Message-ID: <20090116105952.AE50B169E19@codespeak.net> Author: fijal Date: Fri Jan 16 11:59:49 2009 New Revision: 61031 Modified: pypy/branch/oo-jit/pypy/rpython/lltypesystem/ll2ctypes.py Log: A temporary hack for inability to properly compare lltype.FuncType without going into recursive hash (wrongly) Modified: pypy/branch/oo-jit/pypy/rpython/lltypesystem/ll2ctypes.py ============================================================================== --- pypy/branch/oo-jit/pypy/rpython/lltypesystem/ll2ctypes.py (original) +++ pypy/branch/oo-jit/pypy/rpython/lltypesystem/ll2ctypes.py Fri Jan 16 11:59:49 2009 @@ -480,8 +480,14 @@ return new_opaque_object(llobj) container = llobj._obj if isinstance(T.TO, lltype.FuncType): - if llobj._obj in _all_callbacks: - return _all_callbacks[llobj._obj] + # XXX a temporary workaround for comparison of lltype.FuncType + key = llobj._obj.__dict__.copy() + key['_TYPE'] = repr(key['_TYPE']) + items = key.items() + items.sort() + key = tuple(items) + if key in _all_callbacks: + return _all_callbacks[key] v1voidlist = [(i, getattr(container, '_void' + str(i), None)) for i in range(len(T.TO.ARGS)) if T.TO.ARGS[i] is lltype.Void] @@ -534,7 +540,7 @@ ctypes_func_type = get_ctypes_type(T) res = ctypes_func_type(callback) _callback2obj[ctypes.cast(res, ctypes.c_void_p).value] = container - _all_callbacks[llobj._obj] = res + _all_callbacks[key] = res return res if container._storage is None: From antocuni at codespeak.net Fri Jan 16 14:50:27 2009 From: antocuni at codespeak.net (antocuni at codespeak.net) Date: Fri, 16 Jan 2009 14:50:27 +0100 (CET) Subject: [pypy-svn] r61034 - in pypy/trunk/pypy/module/__builtin__: . test Message-ID: <20090116135027.6BC30169E33@codespeak.net> Author: antocuni Date: Fri Jan 16 14:50:25 2009 New Revision: 61034 Modified: pypy/trunk/pypy/module/__builtin__/importing.py pypy/trunk/pypy/module/__builtin__/test/test_import.py Log: fix relative __import__s when the global dict contains __name__ and __path__ Modified: pypy/trunk/pypy/module/__builtin__/importing.py ============================================================================== --- pypy/trunk/pypy/module/__builtin__/importing.py (original) +++ pypy/trunk/pypy/module/__builtin__/importing.py Fri Jan 16 14:50:25 2009 @@ -172,9 +172,13 @@ ctxt_name_prefix_parts = [ ctxt_name_prefix_parts[i] for i in range(len(cnpp)-level) ] if ctxt_name_prefix_parts: - rel_modulename = '.'.join(ctxt_name_prefix_parts+[modulename]) + rel_modulename = '.'.join(ctxt_name_prefix_parts) + if modulename: + rel_modulename += '.' + modulename else: # context is a package module - rel_modulename = ctxt_name+'.'+modulename + rel_modulename = ctxt_name + if modulename: + rel_modulename += '.' + modulename baselevel = len(ctxt_name_prefix_parts) if rel_modulename is not None: w_mod = check_sys_modules(space, w(rel_modulename)) Modified: pypy/trunk/pypy/module/__builtin__/test/test_import.py ============================================================================== --- pypy/trunk/pypy/module/__builtin__/test/test_import.py (original) +++ pypy/trunk/pypy/module/__builtin__/test/test_import.py Fri Jan 16 14:50:25 2009 @@ -313,15 +313,19 @@ raises(ValueError, imp) def test_relative_import_with___name__(self): - skip("fixme") + import sys + mydict = {'__name__': 'sys.foo'} + res = __import__('', mydict, mydict, ('bar',), 1) + assert res is sys + + def test_relative_import_with___name__and___path__(self): import sys import imp - mod = imp.new_module("foo") - mod.xxx = 42 - sys.modules['foo'] = mod - mydict = {'__name__': 'foo.bar'} - exec "from . import xxx" in mydict - assert mydict['xxx'] == 42 + foo = imp.new_module('foo') + sys.modules['sys.foo'] = foo + mydict = {'__name__': 'sys.foo', '__path__': '/some/path'} + res = __import__('', mydict, mydict, ('bar',), 1) + assert res is foo def test_universal_newlines(self): import pkg_univnewlines From arigo at codespeak.net Fri Jan 16 14:52:35 2009 From: arigo at codespeak.net (arigo at codespeak.net) Date: Fri, 16 Jan 2009 14:52:35 +0100 (CET) Subject: [pypy-svn] r61035 - in pypy/trunk/pypy/lib: . app_test Message-ID: <20090116135235.80FCE169E35@codespeak.net> Author: arigo Date: Fri Jan 16 14:52:34 2009 New Revision: 61035 Modified: pypy/trunk/pypy/lib/app_test/test_binascii.py pypy/trunk/pypy/lib/binascii.py Log: Kill the old b2a_qp() and copy it from C. Allows a new test to pass. Modified: pypy/trunk/pypy/lib/app_test/test_binascii.py ============================================================================== --- pypy/trunk/pypy/lib/app_test/test_binascii.py (original) +++ pypy/trunk/pypy/lib/app_test/test_binascii.py Fri Jan 16 14:52:34 2009 @@ -147,6 +147,12 @@ f('') binascii.crc_hqx('', 0) +def test_qp_bug_case(): + assert binascii.b2a_qp('y'*77, False, False) == 'y'*75 + '=\nyy' + assert binascii.b2a_qp(' '*77, False, False) == ' '*75 + '=\n =20' + assert binascii.b2a_qp('y'*76, False, False) == 'y'*76 + assert binascii.b2a_qp(' '*76, False, False) == ' '*75 + '=\n=20' + def test_wrong_padding(): s = 'CSixpLDtKSC/7Liuvsax4iC6uLmwMcijIKHaILzSwd/H0SC8+LCjwLsgv7W/+Mj3IQ' raises(binascii.Error, binascii.a2b_base64, s) Modified: pypy/trunk/pypy/lib/binascii.py ============================================================================== --- pypy/trunk/pypy/lib/binascii.py (original) +++ pypy/trunk/pypy/lib/binascii.py Fri Jan 16 14:52:34 2009 @@ -254,70 +254,75 @@ inp += 1 return ''.join(odata) -def b2a_qp(s, quotetabs=False, istext=True, header=False): +def b2a_qp(data, quotetabs=False, istext=True, header=False): """quotetabs=True means that tab and space characters are always quoted. istext=False means that \r and \n are treated as regular characters header=True encodes space characters with '_' and requires real '_' characters to be quoted. """ - crlf = s.find('\r\n') - lf = s.find('\n') - linebreak = None - if crlf >= 0 and crlf <= lf: - linebreak = '\r\n' - elif lf > 0: - linebreak = '\n' - - # if linebreak and linebreak == '\r\n': - # The above is more efficient for files with \n linebreaks, - # but fails badly on files with mixed linebreak encoding - if linebreak: - s = s.replace('\r\n', '\n') - else: - linebreak = '\n' - - lines = s.split('\n') + MAXLINESIZE = 76 - soft_lbr = '=' + linebreak - result = [] - for line in lines: - charlist = [] - count = 0 - for c in line: - # Don't quote - if '!' <= c <= '<' or '>' <= c <= '^' or '`' <= c <= '~' or ( - c == '_' and not header) or (c in '\n\r' and istext): - if count >= 75: - charlist.append(soft_lbr) - count = 0 - charlist.append(c) - count += 1 - elif not quotetabs and c in '\t ': - if count >= 72: - charlist.append(soft_lbr) - count = 0 - - if count >= 71: # Quote - count += 3 - charlist.append('=' + two_hex_digits(ord(c))) - else: # Don't quote - if c == ' ' and header: - charlist.append('_') - else: - charlist.append(c) - count += 1 - else: # Quote - if count >= 72: - charlist.append(soft_lbr) - count = 0 - count += 3 - charlist.append('=' + two_hex_digits(ord(c))) - if charlist and charlist[-1] in '\t ': - # Whitespace at end of line has to be quoted - charlist[-1] = '=' + two_hex_digits(ord(charlist[-1])) - result.append(''.join(charlist)) - return linebreak.join(result) + # See if this string is using CRLF line ends + lf = data.find('\n') + crlf = lf > 0 and data[lf-1] == '\r' + + inp = 0 + linelen = 0 + odata = [] + while inp < len(data): + c = data[inp] + if (c > '~' or + c == '=' or + (header and c == '_') or + (c == '.' and linelen == 0 and (inp == len(data) or + data[inp+1] == '\n' or + data[inp+1] == '\r')) or + (not istext and (c == '\r' or c == '\n')) or + ((c == '\t' or c == ' ') and (inp + 1 == len(data))) or + (c <= ' ' and c != '\r' and c != '\n' and + (quotetabs or (not quotetabs and (c != '\t' and c != ' '))))): + linelen += 3 + if linelen >= MAXLINESIZE: + odata.append('=') + if crlf: odata.append('\r') + odata.append('\n') + linelen = 3 + odata.append('=' + two_hex_digits(ord(c))) + inp += 1 + else: + if (istext and + (c == '\n' or (inp+1 < len(data) and c == '\r' and + data[inp+1] == '\n'))): + linelen = 0 + # Protect against whitespace on end of line + if (len(odata) > 0 and + (odata[-1] == ' ' or odata[-1] == '\t')): + ch = ord(odata[-1]) + odata[-1] = '=' + odata.append(two_hex_digits(ch)) + + if crlf: odata.append('\r') + odata.append('\n') + if c == '\r': + inp += 2 + else: + inp += 1 + else: + if (inp + 1 < len(data) and + data[inp+1] != '\n' and + (linelen + 1) >= MAXLINESIZE): + odata.append('=') + if crlf: odata.append('\r') + odata.append('\n') + linelen = 0 + + linelen += 1 + if header and c == ' ': + c = '_' + odata.append(c) + inp += 1 + return ''.join(odata) hex_numbers = '0123456789ABCDEF' def hex(n): From fijal at codespeak.net Fri Jan 16 15:41:27 2009 From: fijal at codespeak.net (fijal at codespeak.net) Date: Fri, 16 Jan 2009 15:41:27 +0100 (CET) Subject: [pypy-svn] r61036 - in pypy/branch/oo-jit/pypy/rpython/lltypesystem: . test Message-ID: <20090116144127.4A6EF168577@codespeak.net> Author: fijal Date: Fri Jan 16 15:41:25 2009 New Revision: 61036 Modified: pypy/branch/oo-jit/pypy/rpython/lltypesystem/ll2ctypes.py pypy/branch/oo-jit/pypy/rpython/lltypesystem/test/test_ll2ctypes.py Log: The ability to pass around llmemory.GCREF. Note that it's only about passing it around, address cast to int won't work after translation (I need to investigate to see whether it'll really be a problem) Modified: pypy/branch/oo-jit/pypy/rpython/lltypesystem/ll2ctypes.py ============================================================================== --- pypy/branch/oo-jit/pypy/rpython/lltypesystem/ll2ctypes.py (original) +++ pypy/branch/oo-jit/pypy/rpython/lltypesystem/ll2ctypes.py Fri Jan 16 15:41:25 2009 @@ -193,6 +193,8 @@ elif isinstance(T, lltype.OpaqueType): if T is lltype.RuntimeTypeInfo: return ctypes.c_char * 2 + if T == llmemory.GCREF.TO: + return ctypes.c_void_p if T.hints.get('external', None) != 'C': raise TypeError("%s is not external" % T) return ctypes.c_char * T.hints['getsize']() @@ -472,12 +474,15 @@ return uninitialized2ctypes(llobj.TYPE) T = lltype.typeOf(llobj) + if isinstance(T, lltype.Ptr): if not llobj: # NULL pointer return get_ctypes_type(T)() if T is base_ptr_lltype(): return new_opaque_object(llobj) + if T == llmemory.GCREF: + return new_opaque_object(llobj._obj) container = llobj._obj if isinstance(T.TO, lltype.FuncType): # XXX a temporary workaround for comparison of lltype.FuncType @@ -589,7 +594,7 @@ if isinstance(T, lltype.Ptr): if not cobj: # NULL pointer return lltype.nullptr(T.TO) - if T is base_ptr_lltype(): + if T is base_ptr_lltype() or T == llmemory.GCREF: return _opaque_list[ctypes.cast(cobj, ctypes.c_void_p).value] if isinstance(T.TO, lltype.Struct): if T.TO._arrayfld is not None: Modified: pypy/branch/oo-jit/pypy/rpython/lltypesystem/test/test_ll2ctypes.py ============================================================================== --- pypy/branch/oo-jit/pypy/rpython/lltypesystem/test/test_ll2ctypes.py (original) +++ pypy/branch/oo-jit/pypy/rpython/lltypesystem/test/test_ll2ctypes.py Fri Jan 16 15:41:25 2009 @@ -925,3 +925,10 @@ res = cast_adr_to_int(someaddr()) assert isinstance(res, int) assert res == -sys.maxint/2 - 1 + + def test_cast_gcref_back_and_forth(self): + NODE = lltype.GcStruct('NODE') + node = lltype.malloc(NODE) + ref = lltype.cast_opaque_ptr(llmemory.GCREF, node) + back = rffi.cast(llmemory.GCREF, rffi.cast(lltype.Signed, ref)) + assert lltype.cast_opaque_ptr(lltype.Ptr(NODE), ref) == node From fijal at codespeak.net Fri Jan 16 17:06:06 2009 From: fijal at codespeak.net (fijal at codespeak.net) Date: Fri, 16 Jan 2009 17:06:06 +0100 (CET) Subject: [pypy-svn] r61037 - pypy/branch/oo-jit/pypy/rpython/lltypesystem Message-ID: <20090116160606.44C17168581@codespeak.net> Author: fijal Date: Fri Jan 16 17:06:04 2009 New Revision: 61037 Modified: pypy/branch/oo-jit/pypy/rpython/lltypesystem/ll2ctypes.py Log: TYPO! Modified: pypy/branch/oo-jit/pypy/rpython/lltypesystem/ll2ctypes.py ============================================================================== --- pypy/branch/oo-jit/pypy/rpython/lltypesystem/ll2ctypes.py (original) +++ pypy/branch/oo-jit/pypy/rpython/lltypesystem/ll2ctypes.py Fri Jan 16 17:06:04 2009 @@ -436,7 +436,7 @@ # we need to think deeper how to approach this problem # additionally, this adds mess to __del__ "semantics" _all_callbacks = {} -_all_callback_results = [] +_all_callbacks_results = [] _callback2obj = {} # this is just another hack that passes around references to applevel types From arigo at codespeak.net Fri Jan 16 17:10:46 2009 From: arigo at codespeak.net (arigo at codespeak.net) Date: Fri, 16 Jan 2009 17:10:46 +0100 (CET) Subject: [pypy-svn] r61038 - pypy/branch/oo-jit/pypy/rpython/lltypesystem/test Message-ID: <20090116161046.14FE61683DD@codespeak.net> Author: arigo Date: Fri Jan 16 17:10:45 2009 New Revision: 61038 Modified: pypy/branch/oo-jit/pypy/rpython/lltypesystem/test/test_ll2ctypes.py Log: A test that shows a problem with a changing hash. Modified: pypy/branch/oo-jit/pypy/rpython/lltypesystem/test/test_ll2ctypes.py ============================================================================== --- pypy/branch/oo-jit/pypy/rpython/lltypesystem/test/test_ll2ctypes.py (original) +++ pypy/branch/oo-jit/pypy/rpython/lltypesystem/test/test_ll2ctypes.py Fri Jan 16 17:10:45 2009 @@ -932,3 +932,12 @@ ref = lltype.cast_opaque_ptr(llmemory.GCREF, node) back = rffi.cast(llmemory.GCREF, rffi.cast(lltype.Signed, ref)) assert lltype.cast_opaque_ptr(lltype.Ptr(NODE), ref) == node + + def test_runtimetypeinfo_change(self): + p = lltype.opaqueptr(lltype.RuntimeTypeInfo, 'foo') + hash1 = hash(p._obj) + print repr(p) + lltype2ctypes(p) + print repr(p) + hash2 = hash(p._obj) + assert hash1 == hash2 From arigo at codespeak.net Fri Jan 16 17:23:33 2009 From: arigo at codespeak.net (arigo at codespeak.net) Date: Fri, 16 Jan 2009 17:23:33 +0100 (CET) Subject: [pypy-svn] r61040 - pypy/branch/oo-jit/pypy/rpython/lltypesystem Message-ID: <20090116162333.D233D16855C@codespeak.net> Author: arigo Date: Fri Jan 16 17:23:31 2009 New Revision: 61040 Modified: pypy/branch/oo-jit/pypy/rpython/lltypesystem/ll2ctypes.py Log: Fix the previous problem by reverting a __hash__ method introduced recently. Modified: pypy/branch/oo-jit/pypy/rpython/lltypesystem/ll2ctypes.py ============================================================================== --- pypy/branch/oo-jit/pypy/rpython/lltypesystem/ll2ctypes.py (original) +++ pypy/branch/oo-jit/pypy/rpython/lltypesystem/ll2ctypes.py Fri Jan 16 17:23:31 2009 @@ -364,11 +364,12 @@ def __ne__(self, other): return not (self == other) - def __hash__(self): - if self._storage is not None: - return ctypes.addressof(self._storage) - else: - return object.__hash__(self) +## XXX the following hash method breaks stuff! Look at r60058 more carefully +## def __hash__(self): +## if self._storage is not None: +## return ctypes.addressof(self._storage) +## else: +## return object.__hash__(self) def __repr__(self): if self._storage is None: From arigo at codespeak.net Fri Jan 16 17:32:21 2009 From: arigo at codespeak.net (arigo at codespeak.net) Date: Fri, 16 Jan 2009 17:32:21 +0100 (CET) Subject: [pypy-svn] r61041 - pypy/branch/oo-jit/pypy/rpython/lltypesystem Message-ID: <20090116163221.8C36B16856C@codespeak.net> Author: arigo Date: Fri Jan 16 17:32:20 2009 New Revision: 61041 Modified: pypy/branch/oo-jit/pypy/rpython/lltypesystem/ll2ctypes.py Log: Revert r61031. Modified: pypy/branch/oo-jit/pypy/rpython/lltypesystem/ll2ctypes.py ============================================================================== --- pypy/branch/oo-jit/pypy/rpython/lltypesystem/ll2ctypes.py (original) +++ pypy/branch/oo-jit/pypy/rpython/lltypesystem/ll2ctypes.py Fri Jan 16 17:32:20 2009 @@ -486,14 +486,8 @@ return new_opaque_object(llobj._obj) container = llobj._obj if isinstance(T.TO, lltype.FuncType): - # XXX a temporary workaround for comparison of lltype.FuncType - key = llobj._obj.__dict__.copy() - key['_TYPE'] = repr(key['_TYPE']) - items = key.items() - items.sort() - key = tuple(items) - if key in _all_callbacks: - return _all_callbacks[key] + if llobj._obj in _all_callbacks: + return _all_callbacks[llobj._obj] v1voidlist = [(i, getattr(container, '_void' + str(i), None)) for i in range(len(T.TO.ARGS)) if T.TO.ARGS[i] is lltype.Void] @@ -546,7 +540,7 @@ ctypes_func_type = get_ctypes_type(T) res = ctypes_func_type(callback) _callback2obj[ctypes.cast(res, ctypes.c_void_p).value] = container - _all_callbacks[key] = res + _all_callbacks[llobj._obj] = res return res if container._storage is None: From antocuni at codespeak.net Fri Jan 16 17:42:07 2009 From: antocuni at codespeak.net (antocuni at codespeak.net) Date: Fri, 16 Jan 2009 17:42:07 +0100 (CET) Subject: [pypy-svn] r61042 - in pypy/trunk/pypy: interpreter/pyparser/test module/_codecs module/_codecs/test Message-ID: <20090116164207.8B3D9168577@codespeak.net> Author: antocuni Date: Fri Jan 16 17:42:05 2009 New Revision: 61042 Modified: pypy/trunk/pypy/interpreter/pyparser/test/test_parsestring.py pypy/trunk/pypy/module/_codecs/app_codecs.py pypy/trunk/pypy/module/_codecs/test/test_codecs.py Log: correctly detect an escaped newline when parsing unicode literals Modified: pypy/trunk/pypy/interpreter/pyparser/test/test_parsestring.py ============================================================================== --- pypy/trunk/pypy/interpreter/pyparser/test/test_parsestring.py (original) +++ pypy/trunk/pypy/interpreter/pyparser/test/test_parsestring.py Fri Jan 16 17:42:05 2009 @@ -78,3 +78,8 @@ ret = space.unwrap(w_ret) assert ret == eval("# -*- coding: koi8-u -*-\n'\x81'") + def test_multiline_unicode_strings_with_backslash(self): + space = self.space + s = '"""' + '\\' + '\n"""' + w_ret = parsestring.parsestr(space, None, s) + assert space.str_w(w_ret) == '' Modified: pypy/trunk/pypy/module/_codecs/app_codecs.py ============================================================================== --- pypy/trunk/pypy/module/_codecs/app_codecs.py (original) +++ pypy/trunk/pypy/module/_codecs/app_codecs.py Fri Jan 16 17:42:05 2009 @@ -684,7 +684,8 @@ ch = s[pos] pos += 1 ## /* \x escapes */ - if ch == '\\' : p += u'\\' + if ch == '\n': pass + elif ch == '\\' : p += u'\\' elif ch == '\'': p += u'\'' elif ch == '\"': p += u'\"' elif ch == 'b' : p += u'\b' Modified: pypy/trunk/pypy/module/_codecs/test/test_codecs.py ============================================================================== --- pypy/trunk/pypy/module/_codecs/test/test_codecs.py (original) +++ pypy/trunk/pypy/module/_codecs/test/test_codecs.py Fri Jan 16 17:42:05 2009 @@ -337,3 +337,9 @@ for (i, line) in enumerate(reader): assert line == s[i] + def test_escape_decode_escaped_newline(self): + import _codecs + s = '\\\n' + decoded = _codecs.unicode_escape_decode(s)[0] + assert decoded == '' + From antocuni at codespeak.net Fri Jan 16 17:52:22 2009 From: antocuni at codespeak.net (antocuni at codespeak.net) Date: Fri, 16 Jan 2009 17:52:22 +0100 (CET) Subject: [pypy-svn] r61044 - in pypy/trunk/lib-python: . modified-2.5.2/test Message-ID: <20090116165222.ED9F4168509@codespeak.net> Author: antocuni Date: Fri Jan 16 17:52:22 2009 New Revision: 61044 Modified: pypy/trunk/lib-python/failure_list.txt pypy/trunk/lib-python/modified-2.5.2/test/test_optparse.py Log: fix test_optparse, update failure_list Modified: pypy/trunk/lib-python/failure_list.txt ============================================================================== --- pypy/trunk/lib-python/failure_list.txt (original) +++ pypy/trunk/lib-python/failure_list.txt Fri Jan 16 17:52:22 2009 @@ -26,7 +26,7 @@ test_gettext ! check this use of unicode() test_grammar implementation detail test_import importing from pyc-files-without-py-file disabled by default -test_importhooks ! unknown +test_importhooks ! unknown # SHOULD BE FIXED NOW, check nightly tests test_inspect ! test_wrapped_decorator: try to fix; isbuiltin([].append): cry and maaaybe try to fix test_iterlen somehow implementation detail (missing __length_hint__()) test_itertools same as test_iterlen @@ -35,7 +35,7 @@ test_mutants the test is probably too precise in the failure it expects test_new new.instancemethod(x, None) should fail, but no hurry test_normalization test skipped -test_optparse ! test needs some fixes, but still, some failures are strange +test_optparse ! test needs some fixes, but still, some failures are strange # SHOULD BE FIXED N?OW test_parser missing parser.compilest(). I don't think we care for now test_peepholer implementation detail (might be useful to look, though) test_pep277 NT only Modified: pypy/trunk/lib-python/modified-2.5.2/test/test_optparse.py ============================================================================== --- pypy/trunk/lib-python/modified-2.5.2/test/test_optparse.py (original) +++ pypy/trunk/lib-python/modified-2.5.2/test/test_optparse.py Fri Jan 16 17:52:22 2009 @@ -238,7 +238,7 @@ def test_attr_invalid(self): d = {'foo': None, 'bar': None} - msg = ', '.join(d.keys()) + msg = ', '.join(sorted(d.keys())) # avoid order-dependant issues self.assertOptionError( "option -b: invalid keyword arguments: %s" % msg, ["-b"], d) @@ -1596,10 +1596,11 @@ self.parser.add_option("-l", type=long) def test_parse_num_fail(self): + # "empty string for int()" is pypy's error message self.assertRaises( _parse_num, ("", int), {}, ValueError, - re.compile(r"invalid literal for int().*: '?'?")) + re.compile(r"(invalid literal for int().*: '?'?|empty string for int())")) self.assertRaises( _parse_num, ("0xOoops", long), {}, ValueError, From fijal at codespeak.net Fri Jan 16 18:07:44 2009 From: fijal at codespeak.net (fijal at codespeak.net) Date: Fri, 16 Jan 2009 18:07:44 +0100 (CET) Subject: [pypy-svn] r61045 - pypy/branch/oo-jit/pypy/rpython/lltypesystem Message-ID: <20090116170744.E8C4E16856C@codespeak.net> Author: fijal Date: Fri Jan 16 18:07:43 2009 New Revision: 61045 Modified: pypy/branch/oo-jit/pypy/rpython/lltypesystem/ll2ctypes.py Log: hack differently. Now we really cast underlaying object to C thingie, instead of cheating. Saves us a segfault Modified: pypy/branch/oo-jit/pypy/rpython/lltypesystem/ll2ctypes.py ============================================================================== --- pypy/branch/oo-jit/pypy/rpython/lltypesystem/ll2ctypes.py (original) +++ pypy/branch/oo-jit/pypy/rpython/lltypesystem/ll2ctypes.py Fri Jan 16 18:07:43 2009 @@ -49,6 +49,7 @@ lltype.UniChar: ctypes.c_uint, lltype.Bool: ctypes.c_long, # XXX llmemory.Address: ctypes.c_void_p, + llmemory.GCREF: ctypes.c_void_p, }) @@ -193,8 +194,6 @@ elif isinstance(T, lltype.OpaqueType): if T is lltype.RuntimeTypeInfo: return ctypes.c_char * 2 - if T == llmemory.GCREF.TO: - return ctypes.c_void_p if T.hints.get('external', None) != 'C': raise TypeError("%s is not external" % T) return ctypes.c_char * T.hints['getsize']() @@ -483,8 +482,10 @@ if T is base_ptr_lltype(): return new_opaque_object(llobj) if T == llmemory.GCREF: - return new_opaque_object(llobj._obj) - container = llobj._obj + container = llobj._obj.container + T = lltype.Ptr(lltype.typeOf(container)) + else: + container = llobj._obj if isinstance(T.TO, lltype.FuncType): if llobj._obj in _all_callbacks: return _all_callbacks[llobj._obj] @@ -589,7 +590,7 @@ if isinstance(T, lltype.Ptr): if not cobj: # NULL pointer return lltype.nullptr(T.TO) - if T is base_ptr_lltype() or T == llmemory.GCREF: + if T is base_ptr_lltype(): return _opaque_list[ctypes.cast(cobj, ctypes.c_void_p).value] if isinstance(T.TO, lltype.Struct): if T.TO._arrayfld is not None: From arigo at codespeak.net Fri Jan 16 18:08:14 2009 From: arigo at codespeak.net (arigo at codespeak.net) Date: Fri, 16 Jan 2009 18:08:14 +0100 (CET) Subject: [pypy-svn] r61046 - pypy/branch/oo-jit/pypy/rpython/lltypesystem Message-ID: <20090116170814.36CDC16856C@codespeak.net> Author: arigo Date: Fri Jan 16 18:08:13 2009 New Revision: 61046 Modified: pypy/branch/oo-jit/pypy/rpython/lltypesystem/ll2ctypes.py Log: Revert r61040 and r61041 and reintroduce the __hash__. It's too bad, but the hash cannot remain constant when the object is passed through ll2ctypes, given the set of constrains. Modified: pypy/branch/oo-jit/pypy/rpython/lltypesystem/ll2ctypes.py ============================================================================== --- pypy/branch/oo-jit/pypy/rpython/lltypesystem/ll2ctypes.py (original) +++ pypy/branch/oo-jit/pypy/rpython/lltypesystem/ll2ctypes.py Fri Jan 16 18:08:13 2009 @@ -363,12 +363,11 @@ def __ne__(self, other): return not (self == other) -## XXX the following hash method breaks stuff! Look at r60058 more carefully -## def __hash__(self): -## if self._storage is not None: -## return ctypes.addressof(self._storage) -## else: -## return object.__hash__(self) + def __hash__(self): + if self._storage is not None: + return ctypes.addressof(self._storage) + else: + return object.__hash__(self) def __repr__(self): if self._storage is None: @@ -487,8 +486,14 @@ else: container = llobj._obj if isinstance(T.TO, lltype.FuncType): - if llobj._obj in _all_callbacks: - return _all_callbacks[llobj._obj] + # XXX a temporary workaround for comparison of lltype.FuncType + key = llobj._obj.__dict__.copy() + key['_TYPE'] = repr(key['_TYPE']) + items = key.items() + items.sort() + key = tuple(items) + if key in _all_callbacks: + return _all_callbacks[key] v1voidlist = [(i, getattr(container, '_void' + str(i), None)) for i in range(len(T.TO.ARGS)) if T.TO.ARGS[i] is lltype.Void] @@ -541,7 +546,7 @@ ctypes_func_type = get_ctypes_type(T) res = ctypes_func_type(callback) _callback2obj[ctypes.cast(res, ctypes.c_void_p).value] = container - _all_callbacks[llobj._obj] = res + _all_callbacks[key] = res return res if container._storage is None: From fijal at codespeak.net Sat Jan 17 13:03:19 2009 From: fijal at codespeak.net (fijal at codespeak.net) Date: Sat, 17 Jan 2009 13:03:19 +0100 (CET) Subject: [pypy-svn] r61054 - in pypy/trunk/pypy/module/_sre: . test Message-ID: <20090117120319.D5F55168523@codespeak.net> Author: fijal Date: Sat Jan 17 13:03:17 2009 New Revision: 61054 Modified: pypy/trunk/pypy/module/_sre/app_sre.py pypy/trunk/pypy/module/_sre/test/test_app_sre.py Log: I think *this* is the real fix for the problem. And a test. Modified: pypy/trunk/pypy/module/_sre/app_sre.py ============================================================================== --- pypy/trunk/pypy/module/_sre/app_sre.py (original) +++ pypy/trunk/pypy/module/_sre/app_sre.py Sat Jan 17 13:03:17 2009 @@ -81,7 +81,7 @@ sublist = [] need_unicode = (isinstance(string, unicode) or - isinstance(self.pattern, unicode)) + isinstance(repl, unicode)) n = last_pos = 0 while not count or n < count: state.reset() @@ -109,7 +109,7 @@ if last_pos < state.end: sublist.append(string[last_pos:state.end]) - if n == 0 or len(sublist) == 1: + if n == 0: # not just an optimization -- see test_sub_unicode return string, n Modified: pypy/trunk/pypy/module/_sre/test/test_app_sre.py ============================================================================== --- pypy/trunk/pypy/module/_sre/test/test_app_sre.py (original) +++ pypy/trunk/pypy/module/_sre/test/test_app_sre.py Sat Jan 17 13:03:17 2009 @@ -913,6 +913,9 @@ s.assert_match(opcodes, ["a"]) s.assert_no_match(opcodes, ["ab"]) + def test_bug(self): + import re + assert re.sub('=\w{2}', 'x', '=CA') == 'x' class AppTestOptimizations: """These tests try to trigger optmized edge cases.""" From fijal at codespeak.net Sat Jan 17 17:44:14 2009 From: fijal at codespeak.net (fijal at codespeak.net) Date: Sat, 17 Jan 2009 17:44:14 +0100 (CET) Subject: [pypy-svn] r61064 - in pypy/branch/oo-jit/pypy/rpython/lltypesystem: . test Message-ID: <20090117164414.9AF0A169E2B@codespeak.net> Author: fijal Date: Sat Jan 17 17:44:14 2009 New Revision: 61064 Modified: pypy/branch/oo-jit/pypy/rpython/lltypesystem/ll2ctypes.py pypy/branch/oo-jit/pypy/rpython/lltypesystem/test/test_ll2ctypes.py Log: Move hack from codegen386 here Besides I suppose that this test is not suppose to pass anyway Modified: pypy/branch/oo-jit/pypy/rpython/lltypesystem/ll2ctypes.py ============================================================================== --- pypy/branch/oo-jit/pypy/rpython/lltypesystem/ll2ctypes.py (original) +++ pypy/branch/oo-jit/pypy/rpython/lltypesystem/ll2ctypes.py Sat Jan 17 17:44:14 2009 @@ -481,8 +481,12 @@ if T is base_ptr_lltype(): return new_opaque_object(llobj) if T == llmemory.GCREF: + if isinstance(llobj, _llgcref): + return ctypes.c_void_p(llobj.intval) container = llobj._obj.container T = lltype.Ptr(lltype.typeOf(container)) + # otherwise it came from integer and we want a c_void_p with + # the same valu else: container = llobj._obj if isinstance(T.TO, lltype.FuncType): @@ -631,7 +635,11 @@ return lltype.functionptr(T.TO, getattr(cobj, '__name__', '?'), _callable=_callable) elif isinstance(T.TO, lltype.OpaqueType): - container = lltype._opaque(T.TO) + if T == llmemory.GCREF: + # XXX obscure hack + return _llgcref(cobj) + else: + container = lltype._opaque(T.TO) else: raise NotImplementedError(T) llobj = lltype._ptr(T, container, solid=True) @@ -899,6 +907,23 @@ def _cast_to_int(self): return ctypes.cast(self.void_p, ctypes.c_long) +class _llgcref(object): + _TYPE = llmemory.GCREF + + def __init__(self, void_p): + self.intval = void_p.value + + def __eq__(self, other): + if isinstance(other, _llgcref): + return self.intval == other.intval + return force_cast(lltype.Signed, other) == self.intval + + def __ne__(self, other): + return not self == other + + def __nonzero__(self): + return bool(self.intval) + def cast_adr_to_int(addr): if isinstance(addr, llmemory.fakeaddress): # use ll2ctypes to obtain a real ctypes-based representation of Modified: pypy/branch/oo-jit/pypy/rpython/lltypesystem/test/test_ll2ctypes.py ============================================================================== --- pypy/branch/oo-jit/pypy/rpython/lltypesystem/test/test_ll2ctypes.py (original) +++ pypy/branch/oo-jit/pypy/rpython/lltypesystem/test/test_ll2ctypes.py Sat Jan 17 17:44:14 2009 @@ -933,11 +933,6 @@ back = rffi.cast(llmemory.GCREF, rffi.cast(lltype.Signed, ref)) assert lltype.cast_opaque_ptr(lltype.Ptr(NODE), ref) == node - def test_runtimetypeinfo_change(self): - p = lltype.opaqueptr(lltype.RuntimeTypeInfo, 'foo') - hash1 = hash(p._obj) - print repr(p) - lltype2ctypes(p) - print repr(p) - hash2 = hash(p._obj) - assert hash1 == hash2 + def test_gcref_forth_and_back(self): + cp = ctypes.c_void_p(1234) + assert lltype2ctypes(ctypes2lltype(llmemory.GCREF, cp)).value == cp.value From fijal at codespeak.net Sat Jan 17 17:45:36 2009 From: fijal at codespeak.net (fijal at codespeak.net) Date: Sat, 17 Jan 2009 17:45:36 +0100 (CET) Subject: [pypy-svn] r61065 - pypy/branch/oo-jit/pypy/rpython/lltypesystem/test Message-ID: <20090117164536.D9B5E169E2B@codespeak.net> Author: fijal Date: Sat Jan 17 17:45:36 2009 New Revision: 61065 Modified: pypy/branch/oo-jit/pypy/rpython/lltypesystem/test/test_ll2ctypes.py Log: more testing Modified: pypy/branch/oo-jit/pypy/rpython/lltypesystem/test/test_ll2ctypes.py ============================================================================== --- pypy/branch/oo-jit/pypy/rpython/lltypesystem/test/test_ll2ctypes.py (original) +++ pypy/branch/oo-jit/pypy/rpython/lltypesystem/test/test_ll2ctypes.py Sat Jan 17 17:45:36 2009 @@ -935,4 +935,10 @@ def test_gcref_forth_and_back(self): cp = ctypes.c_void_p(1234) - assert lltype2ctypes(ctypes2lltype(llmemory.GCREF, cp)).value == cp.value + v = ctypes2lltype(llmemory.GCREF, cp) + assert lltype2ctypes(v).value == cp.value + v1 = ctypes2lltype(llmemory.GCREF, cp) + assert v == v1 + assert v + v2 = ctypes2lltype(llmemory.GCREF, ctypes.c_void_p(1235)) + assert v2 != v From fijal at codespeak.net Sat Jan 17 17:52:48 2009 From: fijal at codespeak.net (fijal at codespeak.net) Date: Sat, 17 Jan 2009 17:52:48 +0100 (CET) Subject: [pypy-svn] r61066 - pypy/branch/oo-jit/pypy/rpython/lltypesystem Message-ID: <20090117165248.6CFDA169E2B@codespeak.net> Author: fijal Date: Sat Jan 17 17:52:48 2009 New Revision: 61066 Modified: pypy/branch/oo-jit/pypy/rpython/lltypesystem/ll2ctypes.py pypy/branch/oo-jit/pypy/rpython/lltypesystem/lltype.py Log: install a hook to cast to ptr, let's see how it'll work Modified: pypy/branch/oo-jit/pypy/rpython/lltypesystem/ll2ctypes.py ============================================================================== --- pypy/branch/oo-jit/pypy/rpython/lltypesystem/ll2ctypes.py (original) +++ pypy/branch/oo-jit/pypy/rpython/lltypesystem/ll2ctypes.py Sat Jan 17 17:52:48 2009 @@ -924,6 +924,9 @@ def __nonzero__(self): return bool(self.intval) + def _cast_to_ptr(self, PTRTYPE): + return force_cast(PTRTYPE, self.intval) + def cast_adr_to_int(addr): if isinstance(addr, llmemory.fakeaddress): # use ll2ctypes to obtain a real ctypes-based representation of Modified: pypy/branch/oo-jit/pypy/rpython/lltypesystem/lltype.py ============================================================================== --- pypy/branch/oo-jit/pypy/rpython/lltypesystem/lltype.py (original) +++ pypy/branch/oo-jit/pypy/rpython/lltypesystem/lltype.py Sat Jan 17 17:52:48 2009 @@ -798,6 +798,8 @@ "%s to %s" % (CURTYPE, PTRTYPE)) if (isinstance(CURTYPE.TO, OpaqueType) and not isinstance(PTRTYPE.TO, OpaqueType)): + if hasattr(ptr, '_cast_to_ptr'): + return ptr._cast_to_ptr(PTRTYPE) if not ptr: return nullptr(PTRTYPE.TO) try: From fijal at codespeak.net Sat Jan 17 17:56:54 2009 From: fijal at codespeak.net (fijal at codespeak.net) Date: Sat, 17 Jan 2009 17:56:54 +0100 (CET) Subject: [pypy-svn] r61068 - pypy/branch/oo-jit/pypy/rpython/lltypesystem Message-ID: <20090117165654.CF6C516854B@codespeak.net> Author: fijal Date: Sat Jan 17 17:56:54 2009 New Revision: 61068 Modified: pypy/branch/oo-jit/pypy/rpython/lltypesystem/ll2ctypes.py Log: missing cast Modified: pypy/branch/oo-jit/pypy/rpython/lltypesystem/ll2ctypes.py ============================================================================== --- pypy/branch/oo-jit/pypy/rpython/lltypesystem/ll2ctypes.py (original) +++ pypy/branch/oo-jit/pypy/rpython/lltypesystem/ll2ctypes.py Sat Jan 17 17:56:54 2009 @@ -927,6 +927,9 @@ def _cast_to_ptr(self, PTRTYPE): return force_cast(PTRTYPE, self.intval) + def _cast_to_int(self): + return self.intval + def cast_adr_to_int(addr): if isinstance(addr, llmemory.fakeaddress): # use ll2ctypes to obtain a real ctypes-based representation of From pedronis at codespeak.net Sat Jan 17 20:51:27 2009 From: pedronis at codespeak.net (pedronis at codespeak.net) Date: Sat, 17 Jan 2009 20:51:27 +0100 (CET) Subject: [pypy-svn] r61069 - pypy/build/bot2 Message-ID: <20090117195127.43355169E41@codespeak.net> Author: pedronis Date: Sat Jan 17 20:51:24 2009 New Revision: 61069 Modified: pypy/build/bot2/TODO Log: input from fijal Modified: pypy/build/bot2/TODO ============================================================================== --- pypy/build/bot2/TODO (original) +++ pypy/build/bot2/TODO Sat Jan 17 20:51:24 2009 @@ -2,6 +2,10 @@ ---------------------------------------- - it seems there is no timeout detection anymore for the lib-python tests (?) ! +- (fijal) There is a bunch of exceptions that should be reported as skipped on view. + + TestSkipped, ResourceDenied comes to mind. Not sure what else + - slave for own test need pexect (seems not to be there on wyvern's python?) - move most buildbots to be over python 2.5 or 2.6 (LIKELY) @@ -11,6 +15,7 @@ - convention for naming and coalescing alternative builders for the same build + Nice to have --------------- From pedronis at codespeak.net Sun Jan 18 00:08:33 2009 From: pedronis at codespeak.net (pedronis at codespeak.net) Date: Sun, 18 Jan 2009 00:08:33 +0100 (CET) Subject: [pypy-svn] r61071 - in pypy/build/bot2/pypybuildbot: . test Message-ID: <20090117230833.5AD8E169E43@codespeak.net> Author: pedronis Date: Sun Jan 18 00:08:32 2009 New Revision: 61071 Modified: pypy/build/bot2/pypybuildbot/summary.py pypy/build/bot2/pypybuildbot/test/test_summary.py Log: trying support for categories Modified: pypy/build/bot2/pypybuildbot/summary.py ============================================================================== --- pypy/build/bot2/pypybuildbot/summary.py (original) +++ pypy/build/bot2/pypybuildbot/summary.py Sun Jan 18 00:08:32 2009 @@ -254,7 +254,7 @@ def __init__(self, status): self.sections = [] - self.cur_branch=None + self.cur_cat_branch=None self.fixed_builder = False self.status = status @@ -286,11 +286,26 @@ anchors.append(html.a(text, href=host_agnostic(info['URL']))) return anchors - def start_branch(self, branch): - self.cur_branch = branch - branch_anchor = html.a(branch, href="/summary?branch=%s" % branch, + def start_cat_branch(self, cat_branch): + category, branch = cat_branch + branch = trunk_name(branch) + + if category is None: + cat_branch = ('-', branch) + self.cur_cat_branch = cat_branch + + category, branch = cat_branch + + cat_anchor = html.a("{%s}" % category, + href="/summary?category=%s" % category, + class_="failSummary branch") + + branch_anchor = html.a(branch, + href="/summary?category=%s&branch=%s" % + cat_branch, class_="failSummary branch") - self.sections.append(html.h2(branch_anchor)) + + self.sections.append(html.h2(cat_anchor," ",branch_anchor)) def _builder_anchor(self, builder): if self.fixed_builder: @@ -320,8 +335,9 @@ pick = "builder=%s&builds=%d" % self._builder_num(outcome_set) else: pick = "recentrev=%d" % rev - rev_anchor = html.a(str(rev), href="/summary?branch=%s&%s" % - (self.cur_branch, pick)) + category, branch = self.cur_cat_branch + rev_anchor = html.a(str(rev), href="/summary?category=%s&branch=%s&%s" % + (category, branch, pick)) return rev_anchor def add_section(self, outcome_sets): @@ -485,6 +501,7 @@ trunk_name = make_subst(None, "") trunk_value = make_subst("", None) +nocat_value = make_subst("-", None) def safe_int(v): try: @@ -494,10 +511,11 @@ class Summary(HtmlResource): - def __init__(self): + def __init__(self, categories=[]): HtmlResource.__init__(self) self.putChild('longrepr', LongRepr()) self._defaultBranchCache = {} + self.categories = categories def getTitle(self, request): status = self.getStatus(request) @@ -535,15 +553,16 @@ return branch def recentRuns(self, status, only_recentrevs=None, only_branches=None, - only_builder=None, only_builds=None): + only_builder=None, only_builds=None, + only_categories=None): test_rev = make_test(only_recentrevs) test_branch = make_test(only_branches) test_builder = make_test(only_builder) fixed_builder = bool(only_builder) - branches = {} + cat_branches = {} - for builderName in status.getBuilderNames(): + for builderName in status.getBuilderNames(only_categories): if not test_builder(builderName): continue builderStatus = status.getBuilder(builderName) @@ -565,7 +584,10 @@ if not test_rev(got_rev): continue - runs, no_revision_builds = branches.setdefault(branch, + + cat_branch = (builderStatus.category, branch) + + runs, no_revision_builds = cat_branches.setdefault(cat_branch, ({}, [])) if got_rev is None: @@ -582,7 +604,7 @@ if builderName not in builds: builds[builderName] = build.getNumber() - for branch, (runs, no_revision_builds) in branches.items(): + for cat_branch, (runs, no_revision_builds) in cat_branches.items(): self._prune_runs(runs, N) for label, runBuilds in runs.iteritems(): for builderName, buildNumber in runBuilds.items(): @@ -590,7 +612,7 @@ outcome_set = outcome_set_cache.get(status, key) runBuilds[builderName] = outcome_set - return branches + return cat_branches @staticmethod def _parse_builds(build_select): @@ -608,6 +630,13 @@ if (build_start is not None and build_end is not None): builds.update(range(build_start, build_end+1)) return builds + + def _cat_branch_key(self, (category, branch)): + try: + i = self.categories.index(category) + return (0, i, branch) + except ValueError: + return (1, category, branch) def body(self, request): t0 = time.time() @@ -630,19 +659,26 @@ build_select = request.args.get('builds', None) if build_select is not None: only_builds = self._parse_builds(build_select) - - branches = self.recentRuns(status, - only_recentrevs=only_recentrevs, - only_branches=only_branches, - only_builder=only_builder, - only_builds=only_builds) - - for branch, (runs, no_revision_builds) in sorted(branches.iteritems()): + only_categories = request.args.get('category', None) + if only_categories is not None: + only_categories = map(nocat_value, only_categories) + + cat_branches = self.recentRuns(status, + only_recentrevs = only_recentrevs, + only_branches = only_branches, + only_builder = only_builder, + only_builds = only_builds, + only_categories = only_categories + ) + + + sorting = sorted(cat_branches.iterkeys(), key=self._cat_branch_key) + for cat_branch in sorting: + runs, no_revision_builds = cat_branches[cat_branch] outcome_sets = [] for label, by_build in runs.items(): outcome_sets.append(GatherOutcomeSet(by_build)) - branch = trunk_name(branch) - page.start_branch(branch) + page.start_cat_branch(cat_branch) page.add_section(outcome_sets) page.add_no_revision_builds(status, no_revision_builds) Modified: pypy/build/bot2/pypybuildbot/test/test_summary.py ============================================================================== --- pypy/build/bot2/pypybuildbot/test/test_summary.py (original) +++ pypy/build/bot2/pypybuildbot/test/test_summary.py Sun Jan 18 00:08:32 2009 @@ -298,13 +298,13 @@ def getStatus(self): return self.status -def witness_branches(summary): +def witness_cat_branch(summary): ref = [None] recentRuns = summary.recentRuns def witness(*args, **kwds): - branches = recentRuns(*args, **kwds) - ref[0] = branches - return branches + cat_branch = recentRuns(*args, **kwds) + ref[0] = cat_branch + return cat_branch summary.recentRuns = witness return lambda: ref[0] @@ -354,12 +354,12 @@ def test_sanity(self): s = summary.Summary() - res = witness_branches(s) + res = witness_cat_branch(s) req = FakeRequest([]) s.body(req) - branches = res() + cat_branch = res() - assert branches == {} + assert cat_branch == {} def test_one_build_no_rev(self): builder = status_builder.BuilderStatus('builder0') @@ -369,12 +369,12 @@ builder.nextBuildNumber = len(builder.buildCache) s = summary.Summary() - res = witness_branches(s) + res = witness_cat_branch(s) req = FakeRequest([builder]) out = s.body(req) - branches = res() + cat_branch = res() - assert branches == {None: ({}, [build])} + assert cat_branch == {(None, None): ({}, [build])} def test_one_build_no_logs(self): builder = status_builder.BuilderStatus('builder0') @@ -385,12 +385,12 @@ builder.nextBuildNumber = len(builder.buildCache) s = summary.Summary() - res = witness_branches(s) + res = witness_cat_branch(s) req = FakeRequest([builder]) out = s.body(req) - branches = res() + cat_branch = res() - revs = branches[None][0] + revs = cat_branch[(None, None)][0] assert revs.keys() == [50000] assert '<run>' in out @@ -410,12 +410,12 @@ builder.nextBuildNumber = len(builder.buildCache) s = summary.Summary() - res = witness_branches(s) + res = witness_cat_branch(s) req = FakeRequest([builder]) out = s.body(req) - branches = res() + cat_branch = res() - revs = branches[None][0] + revs = cat_branch[(None, None)][0] assert revs.keys() == [50000] assert 'step borken' in out @@ -426,12 +426,12 @@ add_builds(builder, [(60000, "F TEST1\n. b")]) s = summary.Summary() - res = witness_branches(s) + res = witness_cat_branch(s) req = FakeRequest([builder]) out = s.body(req) - branches = res() + cat_branch = res() - revs = branches[None][0] + revs = cat_branch[(None, None)][0] assert revs.keys() == [60000] outcome = revs[60000]['builder0'] assert outcome.revision == 60000 @@ -445,12 +445,12 @@ (60001, "F TEST1\n. b")]) s = summary.Summary() - res = witness_branches(s) + res = witness_cat_branch(s) req = FakeRequest([builder]) out = s.body(req) - branches = res() + cat_branch = res() - revs = branches[None][0] + revs = cat_branch[(None, None)][0] assert sorted(revs.keys()) == [60000, 60001] outcome = revs[60000]['builder0'] assert outcome.revision == 60000 @@ -473,12 +473,12 @@ (60000, "F TEST1\n. b")]) s = summary.Summary() - res = witness_branches(s) + res = witness_cat_branch(s) req = FakeRequest([builder]) out = s.body(req) - branches = res() + cat_branch = res() - revs = branches[None][0] + revs = cat_branch[(None, None)][0] assert sorted(revs.keys()) == [60000] outcome = revs[60000]['builder0'] assert outcome.revision == 60000 @@ -492,13 +492,13 @@ (60001, "F TEST1\n. b")]) s = summary.Summary() - res = witness_branches(s) + res = witness_cat_branch(s) req = FakeRequest([builder]) req.args = {'recentrev': ['60000']} out = s.body(req) - branches = res() + cat_branch = res() - revs = branches[None][0] + revs = cat_branch[(None, None)][0] assert sorted(revs.keys()) == [60000] outcome = revs[60000]['builder0'] assert outcome.revision == 60000 @@ -513,13 +513,13 @@ (60001, "F TEST1\n. b")]) s = summary.Summary() - res = witness_branches(s) + res = witness_cat_branch(s) req = FakeRequest([builder]) req.args={'builder': ['builder0']} out = s.body(req) - branches = res() + cat_branch = res() - runs = branches[None][0] + runs = cat_branch[(None, None)][0] assert sorted(runs.keys()) == [(60000,0), (60000,1), (60001,2)] outcome = runs[(60000,0)]['builder0'] assert outcome.revision == 60000 @@ -549,14 +549,14 @@ (60001, "F TEST1\n. b")]) s = summary.Summary() - res = witness_branches(s) + res = witness_cat_branch(s) req = FakeRequest([builder]) req.args={'builder': ['builder0'], 'builds': ['0','2-2', '7']} out = s.body(req) - branches = res() + cat_branch = res() - runs = branches[None][0] + runs = cat_branch[(None, None)][0] assert sorted(runs.keys()) == [(60000,0), (60001,2)] outcome = runs[(60000,0)]['builder0'] assert outcome.revision == 60000 @@ -595,3 +595,45 @@ assert 'TEST2' in out assert 'pytest aborted' not in out assert 'pytest2 aborted' in out + + def test_category_sorting_key(self): + s = summary.Summary(['foo', 'bar']) + + res = s._cat_branch_key(('foo', 'trunk')) + assert res == (0, 0, 'trunk') + + res = s._cat_branch_key(('bar', 'trunk')) + assert res == (0, 1, 'trunk') + + res = s._cat_branch_key((None, 'trunk')) + assert res == (1, None, 'trunk') + + res = s._cat_branch_key(('dontknow', 'trunk')) + assert res == (1, 'dontknow', 'trunk') + + def test_builders_with_categories(self): + builder1 = status_builder.BuilderStatus('builder_foo') + builder1.category = 'foo' + builder2 = status_builder.BuilderStatus('builder_bar') + builder2.category = 'bar' + builder3 = status_builder.BuilderStatus('builder_') + builder3.category = None + + add_builds(builder1, [(60000, "F TEST1\n")]) + add_builds(builder2, [(60000, "F TEST2\n")]) + add_builds(builder3, [(60000, "F TEST3\n")]) + + s = summary.Summary(['foo', 'bar']) + req = FakeRequest([builder1, builder2, builder3]) + out = s.body(req) + + rel1 = out.index('TEST1') + rel2 = out.index('TEST2') + rel3 = out.index('TEST3') + + assert rel3 > rel2 > rel1 + + assert "{foo}" in out + assert "{bar}" in out + + From pedronis at codespeak.net Sun Jan 18 00:27:54 2009 From: pedronis at codespeak.net (pedronis at codespeak.net) Date: Sun, 18 Jan 2009 00:27:54 +0100 (CET) Subject: [pypy-svn] r61072 - pypy/build/bot2/pypybuildbot Message-ID: <20090117232754.83813168514@codespeak.net> Author: pedronis Date: Sun Jan 18 00:27:52 2009 New Revision: 61072 Modified: pypy/build/bot2/pypybuildbot/master.py Log: trying out: give some categories Modified: pypy/build/bot2/pypybuildbot/master.py ============================================================================== --- pypy/build/bot2/pypybuildbot/master.py (original) +++ pypy/build/bot2/pypybuildbot/master.py Sun Jan 18 00:27:52 2009 @@ -17,7 +17,8 @@ # pypy test summary page summary = load('pypybuildbot.summary') -status.putChild('summary', summary.Summary()) +status.putChild('summary', summary.Summary(['own', 'applevel', 'stackless', + 'windows', 'maemo', 'other'])) pypybuilds = load('pypybuildbot.builds') @@ -60,42 +61,50 @@ {"name": LINUX32, "slavenames": ["wyvern"], "builddir": LINUX32, - "factory": pypyOwnTestFactory + "factory": pypyOwnTestFactory, + "category": 'own' }, {"name": CPYLINUX32, "slavenames": ["wyvern", "cobra"], "builddir": CPYLINUX32, - "factory": pypyTranslatedLibPythonTestFactory + "factory": pypyTranslatedLibPythonTestFactory, + "category": 'lib-python' }, {"name": APPLVLLINUX32, "slavenames": ["wyvern", "cobra"], "builddir": APPLVLLINUX32, - "factory": pypyTranslatedAppLevelTestFactory + "factory": pypyTranslatedAppLevelTestFactory, + 'category': 'applevel' }, {"name": STACKLESSAPPLVLLINUX32, "slavenames": ["wyvern", "cobra"], "builddir": STACKLESSAPPLVLLINUX32, - "factory": pypyStacklessTranslatedAppLevelTestFactory + "factory": pypyStacklessTranslatedAppLevelTestFactory, + "category": 'stackless' }, {"name" : CPYLINUX32_VM, "slavenames": ['bigdogvm1'], "builddir": CPYLINUX32_VM, - "factory": pypyTranslatedLibPythonTestFactory + "factory": pypyTranslatedLibPythonTestFactory, + "category": 'lib-python' }, {"name": CPYWIN32, "slavenames": ["winxp32-py2.5"], "builddir": CPYWIN32, - "factory": pypyTranslatedLibPythonTestFactoryWin + "factory": pypyTranslatedLibPythonTestFactoryWin, + "category": "windows" }, {"name" : CPYMAEMO, "slavenames": ['bigdogvm1'], "builddir" : CPYMAEMO, "factory": pypyTranslatedLibPythonMaemoTestFactory, + "category": 'maemo' }, {"name" : CPYFREEBSD64, "slavenames": ['headless'], 'builddir' : CPYFREEBSD64, - 'factory' : pypyTranslatedLibPythonTestFactory + 'factory' : pypyTranslatedLibPythonTestFactory, + "category": 'other' }, ], From pedronis at codespeak.net Sun Jan 18 00:29:54 2009 From: pedronis at codespeak.net (pedronis at codespeak.net) Date: Sun, 18 Jan 2009 00:29:54 +0100 (CET) Subject: [pypy-svn] r61073 - pypy/build/bot2/pypybuildbot Message-ID: <20090117232954.195E9168514@codespeak.net> Author: pedronis Date: Sun Jan 18 00:29:53 2009 New Revision: 61073 Modified: pypy/build/bot2/pypybuildbot/master.py Log: fix Modified: pypy/build/bot2/pypybuildbot/master.py ============================================================================== --- pypy/build/bot2/pypybuildbot/master.py (original) +++ pypy/build/bot2/pypybuildbot/master.py Sun Jan 18 00:29:53 2009 @@ -17,7 +17,8 @@ # pypy test summary page summary = load('pypybuildbot.summary') -status.putChild('summary', summary.Summary(['own', 'applevel', 'stackless', +status.putChild('summary', summary.Summary(['own', 'applevel', 'lib-python', + 'stackless', 'windows', 'maemo', 'other'])) From pedronis at codespeak.net Sun Jan 18 00:35:57 2009 From: pedronis at codespeak.net (pedronis at codespeak.net) Date: Sun, 18 Jan 2009 00:35:57 +0100 (CET) Subject: [pypy-svn] r61074 - pypy/build/bot2/pypybuildbot Message-ID: <20090117233557.C3A33168514@codespeak.net> Author: pedronis Date: Sun Jan 18 00:35:57 2009 New Revision: 61074 Modified: pypy/build/bot2/pypybuildbot/summary.py Log: fixes Modified: pypy/build/bot2/pypybuildbot/summary.py ============================================================================== --- pypy/build/bot2/pypybuildbot/summary.py (original) +++ pypy/build/bot2/pypybuildbot/summary.py Sun Jan 18 00:35:57 2009 @@ -289,12 +289,9 @@ def start_cat_branch(self, cat_branch): category, branch = cat_branch branch = trunk_name(branch) + category = category_name(category) - if category is None: - cat_branch = ('-', branch) - self.cur_cat_branch = cat_branch - - category, branch = cat_branch + cat_branch = self.cur_cat_branch = (category, branch) cat_anchor = html.a("{%s}" % category, href="/summary?category=%s" % category, @@ -501,6 +498,7 @@ trunk_name = make_subst(None, "") trunk_value = make_subst("", None) +category_name = make_subst(None, '-') nocat_value = make_subst("-", None) def safe_int(v): From fijal at codespeak.net Sun Jan 18 12:22:51 2009 From: fijal at codespeak.net (fijal at codespeak.net) Date: Sun, 18 Jan 2009 12:22:51 +0100 (CET) Subject: [pypy-svn] r61076 - in pypy/trunk/pypy/module/_file: . test Message-ID: <20090118112251.C3F52169E6E@codespeak.net> Author: fijal Date: Sun Jan 18 12:22:48 2009 New Revision: 61076 Modified: pypy/trunk/pypy/module/_file/interp_file.py pypy/trunk/pypy/module/_file/test/test_file.py Log: A test and a fix for forbidden modes (explicitely by PEP 278 according to cpython's source) Modified: pypy/trunk/pypy/module/_file/interp_file.py ============================================================================== --- pypy/trunk/pypy/module/_file/interp_file.py (original) +++ pypy/trunk/pypy/module/_file/interp_file.py Sun Jan 18 12:22:48 2009 @@ -49,7 +49,8 @@ getopenstreams(self.space)[stream] = None def check_mode_ok(self, mode): - if not mode or mode[0] not in ['r', 'w', 'a', 'U']: + if (not mode or mode[0] not in ['r', 'w', 'a', 'U'] or + ('U' in mode and ('w' in mode or 'a' in mode))): space = self.space raise OperationError(space.w_ValueError, space.wrap('invalid mode : "%s"' % mode)) Modified: pypy/trunk/pypy/module/_file/test/test_file.py ============================================================================== --- pypy/trunk/pypy/module/_file/test/test_file.py (original) +++ pypy/trunk/pypy/module/_file/test/test_file.py Sun Jan 18 12:22:48 2009 @@ -149,6 +149,11 @@ assert f.read(12L) == 'From: foo\n\n0' f.close() + def test_invalid_modes(self): + raises(ValueError, self.file, self.temppath, "aU") + raises(ValueError, self.file, self.temppath, "wU+") + raises(ValueError, self.file, self.temppath, "") + class AppTestConcurrency(object): # these tests only really make sense on top of a translated pypy-c, # because on top of py.py the inner calls to os.write() don't From fijal at codespeak.net Sun Jan 18 12:27:01 2009 From: fijal at codespeak.net (fijal at codespeak.net) Date: Sun, 18 Jan 2009 12:27:01 +0100 (CET) Subject: [pypy-svn] r61077 - pypy/trunk/lib-python/modified-2.5.2/test Message-ID: <20090118112701.7A868169E72@codespeak.net> Author: fijal Date: Sun Jan 18 12:27:01 2009 New Revision: 61077 Modified: pypy/trunk/lib-python/modified-2.5.2/test/test_descrtut.py Log: I take the liberty of declaring it as impl detail Modified: pypy/trunk/lib-python/modified-2.5.2/test/test_descrtut.py ============================================================================== --- pypy/trunk/lib-python/modified-2.5.2/test/test_descrtut.py (original) +++ pypy/trunk/lib-python/modified-2.5.2/test/test_descrtut.py Sun Jan 18 12:27:01 2009 @@ -8,7 +8,7 @@ # of much interest anymore), and a few were fiddled to make the output # deterministic. -from test.test_support import sortdict +from test.test_support import sortdict, check_impl_detail import pprint class defaultdict(dict): @@ -145,7 +145,8 @@ """ -test_3 = """ +if check_impl_detail(): + test_3 = """ Introspecting instances of built-in types @@ -468,13 +469,16 @@ __test__ = {"tut1": test_1, "tut2": test_2, - "tut3": test_3, "tut4": test_4, "tut5": test_5, "tut6": test_6, "tut7": test_7, "tut8": test_8} +if check_impl_detail(): + __test__["tut3"] = test_3 + + # Magic test name that regrtest.py invokes *after* importing this module. # This worms around a bootstrap problem. # Note that doctest and regrtest both look in sys.argv for a "-v" argument, From fijal at codespeak.net Sun Jan 18 15:50:18 2009 From: fijal at codespeak.net (fijal at codespeak.net) Date: Sun, 18 Jan 2009 15:50:18 +0100 (CET) Subject: [pypy-svn] r61078 - pypy/branch/oo-jit/pypy/rpython/lltypesystem Message-ID: <20090118145018.9B2B01684C5@codespeak.net> Author: fijal Date: Sun Jan 18 15:50:16 2009 New Revision: 61078 Modified: pypy/branch/oo-jit/pypy/rpython/lltypesystem/lltype.py Log: yet another hook for casting. this is still experimental, might go away at some point soon Modified: pypy/branch/oo-jit/pypy/rpython/lltypesystem/lltype.py ============================================================================== --- pypy/branch/oo-jit/pypy/rpython/lltypesystem/lltype.py (original) +++ pypy/branch/oo-jit/pypy/rpython/lltypesystem/lltype.py Sun Jan 18 15:50:16 2009 @@ -811,6 +811,8 @@ return cast_pointer(PTRTYPE, p) elif (not isinstance(CURTYPE.TO, OpaqueType) and isinstance(PTRTYPE.TO, OpaqueType)): + if hasattr(ptr, '_cast_to_opaque'): + return ptr._cast_to_opaque(PTRTYPE) if not ptr: return nullptr(PTRTYPE.TO) return opaqueptr(PTRTYPE.TO, 'hidden', container = ptr._obj, From fijal at codespeak.net Sun Jan 18 16:34:19 2009 From: fijal at codespeak.net (fijal at codespeak.net) Date: Sun, 18 Jan 2009 16:34:19 +0100 (CET) Subject: [pypy-svn] r61079 - pypy/trunk/lib-python/modified-2.5.2/encodings Message-ID: <20090118153419.6646A168513@codespeak.net> Author: fijal Date: Sun Jan 18 16:34:17 2009 New Revision: 61079 Added: pypy/trunk/lib-python/modified-2.5.2/encodings/utf_8_sig.py - copied unchanged from r61028, pypy/trunk/lib-python/2.5.2/encodings/utf_8_sig.py Log: replace old, broken encoding with new working one From fijal at codespeak.net Sun Jan 18 16:40:41 2009 From: fijal at codespeak.net (fijal at codespeak.net) Date: Sun, 18 Jan 2009 16:40:41 +0100 (CET) Subject: [pypy-svn] r61080 - in pypy/trunk/pypy/lib: . app_test Message-ID: <20090118154041.62C861683BA@codespeak.net> Author: fijal Date: Sun Jan 18 16:40:40 2009 New Revision: 61080 Modified: pypy/trunk/pypy/lib/app_test/test_binascii.py pypy/trunk/pypy/lib/binascii.py Log: An attempt to catch correctly wrong types, not sure how feasible it is... Modified: pypy/trunk/pypy/lib/app_test/test_binascii.py ============================================================================== --- pypy/trunk/pypy/lib/app_test/test_binascii.py (original) +++ pypy/trunk/pypy/lib/app_test/test_binascii.py Sun Jan 18 16:40:40 2009 @@ -160,3 +160,7 @@ def test_crap_after_padding(): s = 'xxx=axxxx' assert binascii.a2b_base64(s) == '\xc7\x1c' + +def test_wrong_args(): + # this should grow as a way longer list + raises(TypeError, binascii.a2b_base64, 42) Modified: pypy/trunk/pypy/lib/binascii.py ============================================================================== --- pypy/trunk/pypy/lib/binascii.py (original) +++ pypy/trunk/pypy/lib/binascii.py Sun Jan 18 16:40:40 2009 @@ -135,6 +135,8 @@ def a2b_base64(s): + if not isinstance(s, (str, unicode)): + raise TypeError("expected string or unicode, got %r" % (s,)) s = s.rstrip() # clean out all invalid characters, this also strips the final '=' padding # check for correct padding From fijal at codespeak.net Sun Jan 18 16:41:43 2009 From: fijal at codespeak.net (fijal at codespeak.net) Date: Sun, 18 Jan 2009 16:41:43 +0100 (CET) Subject: [pypy-svn] r61081 - in pypy/trunk/pypy/module/_codecs: . test Message-ID: <20090118154143.5C4C61684AA@codespeak.net> Author: fijal Date: Sun Jan 18 16:41:42 2009 New Revision: 61081 Modified: pypy/trunk/pypy/module/_codecs/__init__.py pypy/trunk/pypy/module/_codecs/app_codecs.py pypy/trunk/pypy/module/_codecs/interp_codecs.py pypy/trunk/pypy/module/_codecs/test/test_codecs.py Log: A small bit of cleanup, more to follow Modified: pypy/trunk/pypy/module/_codecs/__init__.py ============================================================================== --- pypy/trunk/pypy/module/_codecs/__init__.py (original) +++ pypy/trunk/pypy/module/_codecs/__init__.py Sun Jan 18 16:41:42 2009 @@ -4,7 +4,6 @@ appleveldefs = { '__doc__' : 'app_codecs.__doc__', '__name__' : 'app_codecs.__name__', - 'charbuffer_encode' : 'app_codecs.charbuffer_encode', 'charmap_decode' : 'app_codecs.charmap_decode', 'charmap_encode' : 'app_codecs.charmap_encode', 'escape_decode' : 'app_codecs.escape_decode', @@ -13,7 +12,6 @@ 'mbcs_encode' : 'app_codecs.mbcs_encode', 'raw_unicode_escape_decode' : 'app_codecs.raw_unicode_escape_decode', 'raw_unicode_escape_encode' : 'app_codecs.raw_unicode_escape_encode', - 'readbuffer_encode' : 'app_codecs.readbuffer_encode', 'unicode_escape_decode' : 'app_codecs.unicode_escape_decode', 'unicode_escape_encode' : 'app_codecs.unicode_escape_encode', 'unicode_internal_decode' : 'app_codecs.unicode_internal_decode', @@ -45,6 +43,8 @@ 'utf_16_le_decode' : 'interp_codecs.utf_16_le_decode', 'utf_16_le_encode' : 'interp_codecs.utf_16_le_encode', 'utf_16_ex_decode' : 'interp_codecs.utf_16_ex_decode', + 'charbuffer_encode': 'interp_codecs.buffer_encode', + 'readbuffer_encode': 'interp_codecs.buffer_encode', } def setup_after_space_initialization(self): Modified: pypy/trunk/pypy/module/_codecs/app_codecs.py ============================================================================== --- pypy/trunk/pypy/module/_codecs/app_codecs.py (original) +++ pypy/trunk/pypy/module/_codecs/app_codecs.py Sun Jan 18 16:41:42 2009 @@ -199,13 +199,6 @@ res = ''.join(res) return res, len(data) -def charbuffer_encode( obj, errors='strict'): - """None - """ - res = str(obj) - res = ''.join(res) - return res, len(res) - def charmap_decode( data, errors='strict', mapping=None): """None """ Modified: pypy/trunk/pypy/module/_codecs/interp_codecs.py ============================================================================== --- pypy/trunk/pypy/module/_codecs/interp_codecs.py (original) +++ pypy/trunk/pypy/module/_codecs/interp_codecs.py Sun Jan 18 16:41:42 2009 @@ -149,6 +149,10 @@ assert 0, "XXX, what to do here?" encode.unwrap_spec = [ObjSpace, W_Root, W_Root, str] +def buffer_encode(space, s, errors='strict'): + return space.newtuple([space.wrap(s), space.wrap(len(s))]) +buffer_encode.unwrap_spec = [ObjSpace, 'bufferstr', str] + def decode(space, w_obj, w_encoding=NoneNotWrapped, errors='strict'): """decode(obj, [encoding[,errors]]) -> object Modified: pypy/trunk/pypy/module/_codecs/test/test_codecs.py ============================================================================== --- pypy/trunk/pypy/module/_codecs/test/test_codecs.py (original) +++ pypy/trunk/pypy/module/_codecs/test/test_codecs.py Sun Jan 18 16:41:42 2009 @@ -337,9 +337,18 @@ for (i, line) in enumerate(reader): assert line == s[i] + def test_array(self): + import _codecs, array + _codecs.readbuffer_encode(array.array('c', 'spam')) == ('spam', 4) + + def test_utf8sig(self): + import codecs + d = codecs.getincrementaldecoder("utf-8-sig")() + s = u"spam" + assert d.decode(s.encode("utf-8-sig")) == s + def test_escape_decode_escaped_newline(self): import _codecs s = '\\\n' decoded = _codecs.unicode_escape_decode(s)[0] assert decoded == '' - From fijal at codespeak.net Sun Jan 18 17:57:57 2009 From: fijal at codespeak.net (fijal at codespeak.net) Date: Sun, 18 Jan 2009 17:57:57 +0100 (CET) Subject: [pypy-svn] r61082 - in pypy/trunk/pypy/module/_codecs: . test Message-ID: <20090118165757.EA98A1684D0@codespeak.net> Author: fijal Date: Sun Jan 18 17:57:56 2009 New Revision: 61082 Modified: pypy/trunk/pypy/module/_codecs/app_codecs.py pypy/trunk/pypy/module/_codecs/test/test_codecs.py Log: a bit of fixes for _codecs module. This is not over yet thouhg. Modified: pypy/trunk/pypy/module/_codecs/app_codecs.py ============================================================================== --- pypy/trunk/pypy/module/_codecs/app_codecs.py (original) +++ pypy/trunk/pypy/module/_codecs/app_codecs.py Sun Jan 18 17:57:56 2009 @@ -1,3 +1,4 @@ + # Note: # This *is* now explicitly RPython. # Please make sure not to break this. @@ -48,12 +49,6 @@ """ pass -def readbuffer_encode( obj, errors='strict'): - """None - """ - res = str(obj) - return res, len(res) - def escape_encode( obj, errors='strict'): """None """ @@ -142,10 +137,17 @@ t = 0 h = 0 for j in range(start, stop, step): - t += ord(unistr[i+j])<<(h*8) + t += ord(unistr[i+j])<<(h*8) h += 1 i += unicode_bytes - p += unichr(t) + try: + p += unichr(t) + except ValueError: + startpos = i - unicode_bytes + endpos = i + raise UnicodeDecodeError('unicode_internal', unistr, startpos, + endpos, + "unichr(%s) not in range" % (t,)) res = u''.join(p) return res, len(unistr) @@ -416,8 +418,8 @@ inShift = 1 elif SPECIAL(ch, 0, 0) : - raise UnicodeDecodeError, "unexpected special character" - + msg = "unexpected special character" + raise UnicodeDecodeError('utf-7', s, i-1, i, msg) else: p += ch else: @@ -437,7 +439,8 @@ elif (SPECIAL(ch, 0, 0)): i += 1 - raise UnicodeDecodeError, "unexpected special character" + msg = "unexpected special character" + raise UnicodeDecodeError('utf-7', s, i-1, i, msg) else: p += ch i += 1 @@ -445,7 +448,8 @@ if (inShift) : #XXX This aint right endinpos = size - raise UnicodeDecodeError, "unterminated shift sequence" + msg = "unterminated shift sequence" + raise UnicodeDecodeError('utf-7', s, i-1, i, msg) return p @@ -857,7 +861,7 @@ raise KeyError else: raise TypeError - except KeyError: + except (KeyError, IndexError): x = unicode_call_errorhandler(errors, "charmap", "character maps to ", s, inpos, inpos+1) p += x[0] Modified: pypy/trunk/pypy/module/_codecs/test/test_codecs.py ============================================================================== --- pypy/trunk/pypy/module/_codecs/test/test_codecs.py (original) +++ pypy/trunk/pypy/module/_codecs/test/test_codecs.py Sun Jan 18 17:57:56 2009 @@ -352,3 +352,21 @@ s = '\\\n' decoded = _codecs.unicode_escape_decode(s)[0] assert decoded == '' + + def test_charmap_decode(self): + import codecs + res = codecs.charmap_decode("\x00\x01\x02", "replace", u"ab") + assert res == (u"ab\ufffd", 3) + + def test_decode_errors(self): + import sys + if sys.maxunicode > 0xffff: + try: + "\x00\x00\x00\x00\x00\x11\x11\x00".decode("unicode_internal") + except UnicodeDecodeError, ex: + assert "unicode_internal" == ex.encoding + assert "\x00\x00\x00\x00\x00\x11\x11\x00" == ex.object + assert ex.start == 4 + assert ex.end == 8 + else: + raise Exception("DID NOT RAISE") From fijal at codespeak.net Sun Jan 18 18:03:46 2009 From: fijal at codespeak.net (fijal at codespeak.net) Date: Sun, 18 Jan 2009 18:03:46 +0100 (CET) Subject: [pypy-svn] r61083 - pypy/trunk/pypy/module/_codecs Message-ID: <20090118170346.05B851684D0@codespeak.net> Author: fijal Date: Sun Jan 18 18:03:45 2009 New Revision: 61083 Modified: pypy/trunk/pypy/module/_codecs/app_codecs.py Log: grrrrr Modified: pypy/trunk/pypy/module/_codecs/app_codecs.py ============================================================================== --- pypy/trunk/pypy/module/_codecs/app_codecs.py (original) +++ pypy/trunk/pypy/module/_codecs/app_codecs.py Sun Jan 18 18:03:45 2009 @@ -812,7 +812,7 @@ # /* Default to Latin-1 */ if mapping == 'latin-1': import _codecs - return _codecs.latin_1_encode(p, size, errors) + return _codecs.latin_1_encode(p, errors) if (size == 0): return '' inpos = 0 From fijal at codespeak.net Sun Jan 18 21:42:42 2009 From: fijal at codespeak.net (fijal at codespeak.net) Date: Sun, 18 Jan 2009 21:42:42 +0100 (CET) Subject: [pypy-svn] r61084 - in pypy/trunk/pypy/module/_codecs: . test Message-ID: <20090118204242.CBFCD1684C1@codespeak.net> Author: fijal Date: Sun Jan 18 21:42:40 2009 New Revision: 61084 Modified: pypy/trunk/pypy/module/_codecs/app_codecs.py pypy/trunk/pypy/module/_codecs/test/test_codecs.py Log: Some fight with codecs. More tests pass, but this is very ugly place. I'm going to make tests pass and get out Modified: pypy/trunk/pypy/module/_codecs/app_codecs.py ============================================================================== --- pypy/trunk/pypy/module/_codecs/app_codecs.py (original) +++ pypy/trunk/pypy/module/_codecs/app_codecs.py Sun Jan 18 21:42:40 2009 @@ -1,4 +1,4 @@ - +# NOT_RPYTHON # Note: # This *is* now explicitly RPython. # Please make sure not to break this. @@ -118,8 +118,7 @@ return res, len(res) def unicode_internal_decode( unistr, errors='strict'): - """None - """ + import sys if type(unistr) == unicode: return unistr, len(unistr) else: @@ -133,7 +132,13 @@ start = 0 stop = unicode_bytes step = 1 - while i < len(unistr)-unicode_bytes+1: + while i < len(unistr): + if len(unistr) - i < unicode_bytes: + msg = 'truncated input' + next, _ = unicode_call_errorhandler(errors, 'unicode_internal', msg, + unistr, i, i + unicode_bytes) + p += next + break t = 0 h = 0 for j in range(start, stop, step): @@ -145,9 +150,10 @@ except ValueError: startpos = i - unicode_bytes endpos = i - raise UnicodeDecodeError('unicode_internal', unistr, startpos, - endpos, - "unichr(%s) not in range" % (t,)) + msg = "unichr(%s) not in range" % (t,) + next, _ = unicode_call_errorhandler(errors, 'unicode_internal', msg, + unistr, startpos, endpos) + p += next res = u''.join(p) return res, len(unistr) @@ -234,6 +240,14 @@ res = ''.join(res) return res, len(res) +def check_exception(exc): + try: + delta = exc.end - exc.start + if delta < 0 or not isinstance(exc.object, (unicode, str)): + raise TypeError("wrong exception") + except AttributeError: + raise TypeError("wrong exception") + def strict_errors(exc): if isinstance(exc, Exception): raise exc @@ -241,6 +255,7 @@ raise TypeError("codec must pass exception instance") def ignore_errors(exc): + check_exception(exc) if isinstance(exc, UnicodeEncodeError): return u'', exc.end elif isinstance(exc, (UnicodeDecodeError, UnicodeTranslateError)): @@ -251,6 +266,7 @@ Py_UNICODE_REPLACEMENT_CHARACTER = u"\ufffd" def replace_errors(exc): + check_exception(exc) if isinstance(exc, UnicodeEncodeError): return u'?'*(exc.end-exc.start), exc.end elif isinstance(exc, (UnicodeTranslateError, UnicodeDecodeError)): @@ -356,7 +372,7 @@ return out, bits def PyUnicode_DecodeUTF7(s, size, errors): - + from _codecs import lookup_error starts = s errmsg = "" inShift = 0 @@ -419,7 +435,8 @@ elif SPECIAL(ch, 0, 0) : msg = "unexpected special character" - raise UnicodeDecodeError('utf-7', s, i-1, i, msg) + out, _ = unicode_call_errorhandler(errors, 'utf-7', msg, s, i-1, i) + p += out else: p += ch else: @@ -440,7 +457,8 @@ elif (SPECIAL(ch, 0, 0)): i += 1 msg = "unexpected special character" - raise UnicodeDecodeError('utf-7', s, i-1, i, msg) + out, _ = unicode_call_errorhandler(errors, 'utf-7', msg, s, i-1, i) + p += out else: p += ch i += 1 @@ -449,8 +467,8 @@ #XXX This aint right endinpos = size msg = "unterminated shift sequence" - raise UnicodeDecodeError('utf-7', s, i-1, i, msg) - + out, _ = unicode_call_errorhandler(errors, 'utf-7', msg, s, i-1, i) + p += out return p def PyUnicode_EncodeUTF7(s, size, encodeSetO, encodeWhiteSpace, errors): @@ -606,7 +624,7 @@ else: exceptionObject = UnicodeEncodeError(encoding, input, startinpos, endinpos, reason) res = errorHandler(exceptionObject) - if isinstance(res, tuple) and isinstance(res[0], unicode) and isinstance(res[1], int): + if isinstance(res, tuple) and len(res) == 2 and isinstance(res[0], unicode) and isinstance(res[1], int): newpos = res[1] if (newpos < 0): newpos = len(input) + newpos Modified: pypy/trunk/pypy/module/_codecs/test/test_codecs.py ============================================================================== --- pypy/trunk/pypy/module/_codecs/test/test_codecs.py (original) +++ pypy/trunk/pypy/module/_codecs/test/test_codecs.py Sun Jan 18 21:42:40 2009 @@ -357,6 +357,8 @@ import codecs res = codecs.charmap_decode("\x00\x01\x02", "replace", u"ab") assert res == (u"ab\ufffd", 3) + res = codecs.charmap_decode("\x00\x01\x02", "replace", u"ab\ufffe") + assert res == (u'ab\ufffd', 3) def test_decode_errors(self): import sys @@ -370,3 +372,110 @@ assert ex.end == 8 else: raise Exception("DID NOT RAISE") + + def test_errors(self): + import codecs + assert ( + codecs.replace_errors(UnicodeEncodeError("ascii", u"\u3042", 0, 1, "ouch"))) == ( + (u"?", 1) + ) + assert ( + codecs.replace_errors(UnicodeDecodeError("ascii", "\xff", 0, 1, "ouch"))) == ( + (u"\ufffd", 1) + ) + assert ( + codecs.replace_errors(UnicodeTranslateError(u"\u3042", 0, 1, "ouch"))) == ( + (u"\ufffd", 1) + ) + class BadStartUnicodeEncodeError(UnicodeEncodeError): + def __init__(self): + UnicodeEncodeError.__init__(self, "ascii", u"", 0, 1, "bad") + self.start = [] + + # A UnicodeEncodeError object with a bad object attribute + class BadObjectUnicodeEncodeError(UnicodeEncodeError): + def __init__(self): + UnicodeEncodeError.__init__(self, "ascii", u"", 0, 1, "bad") + self.object = [] + + # A UnicodeDecodeError object without an end attribute + class NoEndUnicodeDecodeError(UnicodeDecodeError): + def __init__(self): + UnicodeDecodeError.__init__(self, "ascii", "", 0, 1, "bad") + del self.end + + # A UnicodeDecodeError object with a bad object attribute + class BadObjectUnicodeDecodeError(UnicodeDecodeError): + def __init__(self): + UnicodeDecodeError.__init__(self, "ascii", "", 0, 1, "bad") + self.object = [] + + # A UnicodeTranslateError object without a start attribute + class NoStartUnicodeTranslateError(UnicodeTranslateError): + def __init__(self): + UnicodeTranslateError.__init__(self, u"", 0, 1, "bad") + del self.start + + # A UnicodeTranslateError object without an end attribute + class NoEndUnicodeTranslateError(UnicodeTranslateError): + def __init__(self): + UnicodeTranslateError.__init__(self, u"", 0, 1, "bad") + del self.end + + # A UnicodeTranslateError object without an object attribute + class NoObjectUnicodeTranslateError(UnicodeTranslateError): + def __init__(self): + UnicodeTranslateError.__init__(self, u"", 0, 1, "bad") + del self.object + + import codecs + raises(TypeError, codecs.replace_errors, BadObjectUnicodeEncodeError()) + raises(TypeError, codecs.replace_errors, 42) + # "replace" complains about the wrong exception type + raises(TypeError, codecs.replace_errors, UnicodeError("ouch")) + raises(TypeError, codecs.replace_errors, BadObjectUnicodeEncodeError()) + raises(TypeError, codecs.replace_errors, BadObjectUnicodeDecodeError() + ) + # With the correct exception, "replace" returns an "?" or u"\ufffd" replacement + + def test_decode_ignore(self): + assert '\xff'.decode('utf-7', 'ignore') == '' + assert '\x00'.decode('unicode-internal', 'ignore') == '' + + def test_badhandler(self): + import codecs + results = ( 42, u"foo", (1,2,3), (u"foo", 1, 3), (u"foo", None), (u"foo",), ("foo", 1, 3), ("foo", None), ("foo",) ) + encs = ("ascii", "latin-1", "iso-8859-1", "iso-8859-15") + + for res in results: + codecs.register_error("test.badhandler", lambda x: res) + for enc in encs: + raises( + TypeError, + u"\u3042".encode, + enc, + "test.badhandler" + ) + for (enc, bytes) in ( + ("utf-8", "\xff"), + ("ascii", "\xff"), + ("utf-7", "+x-"), + ("unicode-internal", "\x00"), + ): + raises( + TypeError, + bytes.decode, + enc, + "test.badhandler" + ) + + def test_unicode_internal(self): + try: + '\x00'.decode('unicode-internal') + except UnicodeDecodeError: + pass + else: + raise Exception("DID NOT RAISE") + + res = "\x00\x00\x00\x00\x00".decode("unicode-internal", "replace") + assert res == u"\u0000\ufffd" From fijal at codespeak.net Sun Jan 18 21:53:12 2009 From: fijal at codespeak.net (fijal at codespeak.net) Date: Sun, 18 Jan 2009 21:53:12 +0100 (CET) Subject: [pypy-svn] r61085 - in pypy/trunk/pypy/module/_codecs: . test Message-ID: <20090118205312.813C5168518@codespeak.net> Author: fijal Date: Sun Jan 18 21:53:12 2009 New Revision: 61085 Modified: pypy/trunk/pypy/module/_codecs/app_codecs.py pypy/trunk/pypy/module/_codecs/test/test_codecs.py Log: I *think* this is how it should work. completely unsure though, let's look at tests. Modified: pypy/trunk/pypy/module/_codecs/app_codecs.py ============================================================================== --- pypy/trunk/pypy/module/_codecs/app_codecs.py (original) +++ pypy/trunk/pypy/module/_codecs/app_codecs.py Sun Jan 18 21:53:12 2009 @@ -135,10 +135,10 @@ while i < len(unistr): if len(unistr) - i < unicode_bytes: msg = 'truncated input' - next, _ = unicode_call_errorhandler(errors, 'unicode_internal', msg, - unistr, i, i + unicode_bytes) + next, i = unicode_call_errorhandler(errors, 'unicode_internal', msg, + unistr, i, len(unistr)) p += next - break + continue t = 0 h = 0 for j in range(start, stop, step): @@ -151,7 +151,7 @@ startpos = i - unicode_bytes endpos = i msg = "unichr(%s) not in range" % (t,) - next, _ = unicode_call_errorhandler(errors, 'unicode_internal', msg, + next, i = unicode_call_errorhandler(errors, 'unicode_internal', msg, unistr, startpos, endpos) p += next res = u''.join(p) @@ -407,7 +407,7 @@ ## it in a 16-bit character surrogate = 1 msg = "code pairs are not supported" - out, x = unicode_call_errorhandler(errors, 'utf-7', msg, s, i-1, i) + out, i = unicode_call_errorhandler(errors, 'utf-7', msg, s, i-1, i) p += out bitsleft = 0 break @@ -419,7 +419,7 @@ ## bitsleft < 6 then we could just classify it as padding ## but that is not the case here */ msg = "partial character in shift sequence" - out, x = unicode_call_errorhandler(errors, 'utf-7', msg, s, i-1, i) + out, i = unicode_call_errorhandler(errors, 'utf-7', msg, s, i-1, i) ## /* According to RFC2152 the remaining bits should be zero. We ## choose to signal an error/insert a replacement character @@ -435,7 +435,7 @@ elif SPECIAL(ch, 0, 0) : msg = "unexpected special character" - out, _ = unicode_call_errorhandler(errors, 'utf-7', msg, s, i-1, i) + out, i = unicode_call_errorhandler(errors, 'utf-7', msg, s, i-1, i) p += out else: p += ch @@ -457,7 +457,7 @@ elif (SPECIAL(ch, 0, 0)): i += 1 msg = "unexpected special character" - out, _ = unicode_call_errorhandler(errors, 'utf-7', msg, s, i-1, i) + out, i = unicode_call_errorhandler(errors, 'utf-7', msg, s, i-1, i) p += out else: p += ch @@ -467,7 +467,7 @@ #XXX This aint right endinpos = size msg = "unterminated shift sequence" - out, _ = unicode_call_errorhandler(errors, 'utf-7', msg, s, i-1, i) + out, i = unicode_call_errorhandler(errors, 'utf-7', msg, s, i-1, i) p += out return p Modified: pypy/trunk/pypy/module/_codecs/test/test_codecs.py ============================================================================== --- pypy/trunk/pypy/module/_codecs/test/test_codecs.py (original) +++ pypy/trunk/pypy/module/_codecs/test/test_codecs.py Sun Jan 18 21:53:12 2009 @@ -470,6 +470,7 @@ ) def test_unicode_internal(self): + import codecs try: '\x00'.decode('unicode-internal') except UnicodeDecodeError: @@ -479,3 +480,16 @@ res = "\x00\x00\x00\x00\x00".decode("unicode-internal", "replace") assert res == u"\u0000\ufffd" + def handler_unicodeinternal(exc): + if not isinstance(exc, UnicodeDecodeError): + raise TypeError("don't know how to handle %r" % exc) + return (u"\x01", 1) + + res = "\x00\x00\x00\x00\x00".decode("unicode-internal", "ignore") + assert res == u"\u0000" + res = "\x00\x00\x00\x00\x00".decode("unicode-internal", "replace") + assert res == u"\u0000\ufffd" + codecs.register_error("test.hui", handler_unicodeinternal) + res = "\x00\x00\x00\x00\x00".decode("unicode-internal", "test.hui") + assert res == u"\u0000\u0001\u0000" + From fijal at codespeak.net Sun Jan 18 22:04:45 2009 From: fijal at codespeak.net (fijal at codespeak.net) Date: Sun, 18 Jan 2009 22:04:45 +0100 (CET) Subject: [pypy-svn] r61086 - pypy/trunk/pypy/module/_codecs Message-ID: <20090118210445.0F1381684BA@codespeak.net> Author: fijal Date: Sun Jan 18 22:04:44 2009 New Revision: 61086 Modified: pypy/trunk/pypy/module/_codecs/app_codecs.py Log: A bit of dance to correctly pass this test Modified: pypy/trunk/pypy/module/_codecs/app_codecs.py ============================================================================== --- pypy/trunk/pypy/module/_codecs/app_codecs.py (original) +++ pypy/trunk/pypy/module/_codecs/app_codecs.py Sun Jan 18 22:04:44 2009 @@ -210,7 +210,7 @@ def charmap_decode( data, errors='strict', mapping=None): """None """ - res = PyUnicode_DecodeCharmap(data, len(data), mapping, errors) + res = PyUnicode_DecodeCharmap(data, mapping, errors) res = u''.join(res) return res, len(data) @@ -851,8 +851,9 @@ inpos += 1 return res -def PyUnicode_DecodeCharmap(s, size, mapping, errors): +def PyUnicode_DecodeCharmap(s, mapping, errors): + size = len(s) ## /* Default to Latin-1 */ if (mapping == None): import _codecs @@ -874,16 +875,20 @@ else: raise TypeError("character mapping must be in range(65536)") elif isinstance(x, unicode): + if x == u"\ufffe": + raise KeyError p += x elif not x: raise KeyError else: raise TypeError + inpos += 1 except (KeyError, IndexError): - x = unicode_call_errorhandler(errors, "charmap", - "character maps to ", s, inpos, inpos+1) - p += x[0] - inpos += 1 + next, inpos = unicode_call_errorhandler(errors, "charmap", + "character maps to ", s, inpos, inpos+1) + p += next + inpos + print p return p def PyUnicode_DecodeRawUnicodeEscape(s, size, errors): From fijal at codespeak.net Sun Jan 18 22:17:36 2009 From: fijal at codespeak.net (fijal at codespeak.net) Date: Sun, 18 Jan 2009 22:17:36 +0100 (CET) Subject: [pypy-svn] r61091 - pypy/trunk/pypy/module/_codecs Message-ID: <20090118211736.B2F491684D2@codespeak.net> Author: fijal Date: Sun Jan 18 22:17:34 2009 New Revision: 61091 Modified: pypy/trunk/pypy/module/_codecs/app_codecs.py Log: this was not supposed to be checked in Modified: pypy/trunk/pypy/module/_codecs/app_codecs.py ============================================================================== --- pypy/trunk/pypy/module/_codecs/app_codecs.py (original) +++ pypy/trunk/pypy/module/_codecs/app_codecs.py Sun Jan 18 22:17:34 2009 @@ -888,7 +888,6 @@ "character maps to ", s, inpos, inpos+1) p += next inpos - print p return p def PyUnicode_DecodeRawUnicodeEscape(s, size, errors): From fijal at codespeak.net Mon Jan 19 00:33:12 2009 From: fijal at codespeak.net (fijal at codespeak.net) Date: Mon, 19 Jan 2009 00:33:12 +0100 (CET) Subject: [pypy-svn] r61094 - in pypy/trunk/pypy/module/_codecs: . test Message-ID: <20090118233312.AF6E71684CD@codespeak.net> Author: fijal Date: Mon Jan 19 00:33:09 2009 New Revision: 61094 Modified: pypy/trunk/pypy/module/_codecs/app_codecs.py pypy/trunk/pypy/module/_codecs/test/test_codecs.py Log: oops Modified: pypy/trunk/pypy/module/_codecs/app_codecs.py ============================================================================== --- pypy/trunk/pypy/module/_codecs/app_codecs.py (original) +++ pypy/trunk/pypy/module/_codecs/app_codecs.py Mon Jan 19 00:33:09 2009 @@ -830,7 +830,7 @@ # /* Default to Latin-1 */ if mapping == 'latin-1': import _codecs - return _codecs.latin_1_encode(p, errors) + return _codecs.latin_1_encode(p, errors)[0] if (size == 0): return '' inpos = 0 @@ -839,7 +839,7 @@ #/* try to encode it */ try: x = charmapencode_output(ord(p[inpos]), mapping) - res += [x] + res += x[0] except KeyError: x = unicode_call_errorhandler(errors, "charmap", "character maps to ", p, inpos, inpos+1, False) Modified: pypy/trunk/pypy/module/_codecs/test/test_codecs.py ============================================================================== --- pypy/trunk/pypy/module/_codecs/test/test_codecs.py (original) +++ pypy/trunk/pypy/module/_codecs/test/test_codecs.py Mon Jan 19 00:33:09 2009 @@ -493,3 +493,10 @@ res = "\x00\x00\x00\x00\x00".decode("unicode-internal", "test.hui") assert res == u"\u0000\u0001\u0000" + def test_charmap_encode(self): + assert 'xxx'.encode('charmap') == 'xxx' + +class TestDirect: + def test_charmap_encode(self): + from pypy.module._codecs.app_codecs import charmap_encode + assert charmap_encode('xxx') == ('xxx', 3) From fijal at codespeak.net Mon Jan 19 01:02:00 2009 From: fijal at codespeak.net (fijal at codespeak.net) Date: Mon, 19 Jan 2009 01:02:00 +0100 (CET) Subject: [pypy-svn] r61095 - pypy/trunk/lib-python/modified-2.5.2/test Message-ID: <20090119000200.2C7F51684C1@codespeak.net> Author: fijal Date: Mon Jan 19 01:01:59 2009 New Revision: 61095 Modified: pypy/trunk/lib-python/modified-2.5.2/test/test_codecs.py Log: disable unsupported codecs Modified: pypy/trunk/lib-python/modified-2.5.2/test/test_codecs.py ============================================================================== --- pypy/trunk/lib-python/modified-2.5.2/test/test_codecs.py (original) +++ pypy/trunk/lib-python/modified-2.5.2/test/test_codecs.py Mon Jan 19 01:01:59 2009 @@ -995,8 +995,8 @@ all_unicode_encodings = [ "ascii", "base64_codec", - "big5", - "big5hkscs", + #"big5", + #"big5hkscs", "charmap", "cp037", "cp1006", @@ -1031,27 +1031,27 @@ "cp869", "cp874", "cp875", - "cp932", - "cp949", - "cp950", - "euc_jis_2004", - "euc_jisx0213", - "euc_jp", - "euc_kr", - "gb18030", - "gb2312", - "gbk", + #"cp932", + #"cp949", + #"cp950", + #"euc_jis_2004", + #"euc_jisx0213", + #"euc_jp", + #"euc_kr", + #"gb18030", + #"gb2312", + #"gbk", "hex_codec", "hp_roman8", - "hz", + #"hz", "idna", - "iso2022_jp", - "iso2022_jp_1", - "iso2022_jp_2", - "iso2022_jp_2004", - "iso2022_jp_3", - "iso2022_jp_ext", - "iso2022_kr", + #"iso2022_jp", + #"iso2022_jp_1", + #"iso2022_jp_2", + #"iso2022_jp_2004", + #"iso2022_jp_3", + #"iso2022_jp_ext", + #"iso2022_kr", "iso8859_1", "iso8859_10", "iso8859_11", @@ -1067,7 +1067,7 @@ "iso8859_7", "iso8859_8", "iso8859_9", - "johab", + #"johab", "koi8_r", "koi8_u", "latin_1", @@ -1082,9 +1082,9 @@ "punycode", "raw_unicode_escape", "rot_13", - "shift_jis", - "shift_jis_2004", - "shift_jisx0213", + #"shift_jis", + #"shift_jis_2004", + #"shift_jisx0213", "tis_620", "unicode_escape", "unicode_internal", @@ -1166,7 +1166,8 @@ decodedresult += reader.read() self.assertEqual(decodedresult, s, "%r != %r (encoding=%r)" % (decodedresult, s, encoding)) - if encoding not in broken_incremental_coders: + if (encoding not in broken_incremental_coders and + test_support.check_impl_detail()): # check incremental decoder/encoder (fetched via the Python # and C API) and iterencode()/iterdecode() import _testcapi From fijal at codespeak.net Mon Jan 19 01:06:30 2009 From: fijal at codespeak.net (fijal at codespeak.net) Date: Mon, 19 Jan 2009 01:06:30 +0100 (CET) Subject: [pypy-svn] r61096 - pypy/trunk/lib-python/modified-2.5.2/test Message-ID: <20090119000630.3C6DF1684D2@codespeak.net> Author: fijal Date: Mon Jan 19 01:06:29 2009 New Revision: 61096 Modified: pypy/trunk/lib-python/modified-2.5.2/test/test_codecs.py Log: I suppose it's fine to raise overflow error there Modified: pypy/trunk/lib-python/modified-2.5.2/test/test_codecs.py ============================================================================== --- pypy/trunk/lib-python/modified-2.5.2/test/test_codecs.py (original) +++ pypy/trunk/lib-python/modified-2.5.2/test/test_codecs.py Mon Jan 19 01:06:29 2009 @@ -638,7 +638,7 @@ for internal in not_ok: if sys.byteorder == "little": internal = "".join(reversed(internal)) - self.assertRaises(UnicodeDecodeError, internal.decode, + self.assertRaises((UnicodeDecodeError, OverflowError), internal.decode, "unicode_internal") def test_decode_error_attributes(self): @@ -997,7 +997,7 @@ "base64_codec", #"big5", #"big5hkscs", - "charmap", + #"charmap", "cp037", "cp1006", "cp1026", From fijal at codespeak.net Mon Jan 19 01:39:09 2009 From: fijal at codespeak.net (fijal at codespeak.net) Date: Mon, 19 Jan 2009 01:39:09 +0100 (CET) Subject: [pypy-svn] r61097 - pypy/trunk/pypy/module/_codecs Message-ID: <20090119003909.4CC051684E5@codespeak.net> Author: fijal Date: Mon Jan 19 01:39:07 2009 New Revision: 61097 Modified: pypy/trunk/pypy/module/_codecs/app_codecs.py Log: how-this-could-have-ever-worked Modified: pypy/trunk/pypy/module/_codecs/app_codecs.py ============================================================================== --- pypy/trunk/pypy/module/_codecs/app_codecs.py (original) +++ pypy/trunk/pypy/module/_codecs/app_codecs.py Mon Jan 19 01:39:07 2009 @@ -857,7 +857,7 @@ ## /* Default to Latin-1 */ if (mapping == None): import _codecs - return _codecs.latin_1_decode(s, size, errors) + return _codecs.latin_1_decode(s, size, errors)[0] if (size == 0): return u'' From fijal at codespeak.net Mon Jan 19 01:58:30 2009 From: fijal at codespeak.net (fijal at codespeak.net) Date: Mon, 19 Jan 2009 01:58:30 +0100 (CET) Subject: [pypy-svn] r61098 - pypy/trunk/lib-python Message-ID: <20090119005830.4FA171684E5@codespeak.net> Author: fijal Date: Mon Jan 19 01:58:29 2009 New Revision: 61098 Modified: pypy/trunk/lib-python/conftest.py Log: whatever it is, we don't support it Modified: pypy/trunk/lib-python/conftest.py ============================================================================== --- pypy/trunk/lib-python/conftest.py (original) +++ pypy/trunk/lib-python/conftest.py Mon Jan 19 01:58:29 2009 @@ -321,7 +321,7 @@ RegrTest('test_pickletools.py', core=False), RegrTest('test_pkg.py', core=True), RegrTest('test_pkgimport.py', core=True), - RegrTest('test_plistlib.py'), + RegrTest('test_plistlib.py', skip="unsupported module"), RegrTest('test_poll.py'), RegrTest('test_popen.py'), RegrTest('test_popen2.py'), From fijal at codespeak.net Mon Jan 19 02:05:00 2009 From: fijal at codespeak.net (fijal at codespeak.net) Date: Mon, 19 Jan 2009 02:05:00 +0100 (CET) Subject: [pypy-svn] r61099 - pypy/trunk/pypy/module/select Message-ID: <20090119010500.28E281684E5@codespeak.net> Author: fijal Date: Mon Jan 19 02:04:59 2009 New Revision: 61099 Modified: pypy/trunk/pypy/module/select/interp_select.py Log: let's compute int instead of trying too hard. CPython doesn't care and it makes test blow. Modified: pypy/trunk/pypy/module/select/interp_select.py ============================================================================== --- pypy/trunk/pypy/module/select/interp_select.py (original) +++ pypy/trunk/pypy/module/select/interp_select.py Mon Jan 19 02:04:59 2009 @@ -54,11 +54,14 @@ if space.is_w(w_timeout, space.w_None): timeout = -1 else: - timeout = space.float_w(w_timeout) - # round non-integral floats upwards (in theory, with timeout=2.5 - # we should wait at least 2.5ms, so 2ms is not enough) + # rationale for computing directly integer, instead + # of float + math.cell is that + # we have for free overflow check and noone really + # cares (since CPython does not try too hard to have + # a ceiling of value) try: - timeout = int(math.ceil(timeout)) + # compute the integer + timeout = space.int_w(w_timeout) except (OverflowError, ValueError): raise OperationError(space.w_ValueError, space.wrap("math range error")) From fijal at codespeak.net Mon Jan 19 10:56:06 2009 From: fijal at codespeak.net (fijal at codespeak.net) Date: Mon, 19 Jan 2009 10:56:06 +0100 (CET) Subject: [pypy-svn] r61100 - in pypy/trunk/pypy/module/_codecs: . test Message-ID: <20090119095606.616831684C8@codespeak.net> Author: fijal Date: Mon Jan 19 10:56:04 2009 New Revision: 61100 Modified: pypy/trunk/pypy/module/_codecs/app_codecs.py pypy/trunk/pypy/module/_codecs/test/test_codecs.py Log: oops Modified: pypy/trunk/pypy/module/_codecs/app_codecs.py ============================================================================== --- pypy/trunk/pypy/module/_codecs/app_codecs.py (original) +++ pypy/trunk/pypy/module/_codecs/app_codecs.py Mon Jan 19 10:56:04 2009 @@ -88,7 +88,7 @@ def charmap_encode(obj, errors='strict', mapping='latin-1'): """None """ - res = PyUnicode_EncodeCharmap(obj, len(obj), mapping, errors) + res = PyUnicode_EncodeCharmap(obj, mapping, errors) res = ''.join(res) return res, len(res) @@ -821,7 +821,7 @@ else: raise TypeError("character mapping must return integer, None or str") -def PyUnicode_EncodeCharmap(p, size, mapping='latin-1', errors='strict'): +def PyUnicode_EncodeCharmap(p, mapping='latin-1', errors='strict'): ## /* the following variable is used for caching string comparisons ## * -1=not initialized, 0=unknown, 1=strict, 2=replace, @@ -831,6 +831,7 @@ if mapping == 'latin-1': import _codecs return _codecs.latin_1_encode(p, errors)[0] + size = len(p) if (size == 0): return '' inpos = 0 @@ -839,7 +840,7 @@ #/* try to encode it */ try: x = charmapencode_output(ord(p[inpos]), mapping) - res += x[0] + res += x except KeyError: x = unicode_call_errorhandler(errors, "charmap", "character maps to ", p, inpos, inpos+1, False) Modified: pypy/trunk/pypy/module/_codecs/test/test_codecs.py ============================================================================== --- pypy/trunk/pypy/module/_codecs/test/test_codecs.py (original) +++ pypy/trunk/pypy/module/_codecs/test/test_codecs.py Mon Jan 19 10:56:04 2009 @@ -500,3 +500,4 @@ def test_charmap_encode(self): from pypy.module._codecs.app_codecs import charmap_encode assert charmap_encode('xxx') == ('xxx', 3) + assert charmap_encode('xxx', 'strict', {ord('x'): 'XX'}) == ('XXXXXX', 6) From cfbolz at codespeak.net Mon Jan 19 12:51:13 2009 From: cfbolz at codespeak.net (cfbolz at codespeak.net) Date: Mon, 19 Jan 2009 12:51:13 +0100 (CET) Subject: [pypy-svn] r61109 - pypy/extradoc/talk/ecoop2009/tutorial Message-ID: <20090119115113.442091684D2@codespeak.net> Author: cfbolz Date: Mon Jan 19 12:51:12 2009 New Revision: 61109 Added: pypy/extradoc/talk/ecoop2009/tutorial/ pypy/extradoc/talk/ecoop2009/tutorial/llncs.cls (props changed) - copied unchanged from r60991, pypy/extradoc/talk/ecoop2009/llncs.cls pypy/extradoc/talk/ecoop2009/tutorial/proposal.tex Log: (cfbolz, arigo, antocuni): start tutorial propsal Added: pypy/extradoc/talk/ecoop2009/tutorial/proposal.tex ============================================================================== --- (empty file) +++ pypy/extradoc/talk/ecoop2009/tutorial/proposal.tex Mon Jan 19 12:51:12 2009 @@ -0,0 +1,105 @@ +\documentclass{llncs} + + + %%%% Compression Light+: LNCS margin reduced by +/-7mm along all edges (RG). +%\textwidth=130mm % LNCS: 122mm +%\textheight=203mm % LNCS: 193mm + +\renewcommand{\baselinestretch}{0.97} + +\usepackage{amssymb} +\usepackage{amsmath} +\usepackage[sans]{dsfont} +\usepackage{color} +\usepackage{ifthen} +\usepackage{xspace} +\usepackage{listings} +\usepackage{fancyvrb} +\usepackage{multirow} +\usepackage[pdftex]{graphicx} + +%\input{macros} + +\pagestyle{plain} + +%\lstset{mathescape=true,language=Java,basicstyle=\tt,keywordstyle=\bf} +\lstset{language=Python, + basicstyle=\scriptsize\ttfamily, + keywordstyle=\color{blue}, % I couldn't find a way to make chars both bold and tt + frame=none, + stringstyle=\color{blue}, + fancyvrb=true, + xleftmargin=20pt,xrightmargin=20pt, + showstringspaces=false} + +\setlength{\tabcolsep}{1ex} + + +%\renewcommand{\baselinestretch}{.98} +\newboolean{showcomments} +\setboolean{showcomments}{false} +\ifthenelse{\boolean{showcomments}} + {\newcommand{\nb}[2]{ + \fbox{\bfseries\sffamily\scriptsize#1} + {\sf\small$\blacktriangleright$\textit{#2}$\blacktriangleleft$} + } + \newcommand{\version}{\emph{\scriptsize$-$Id: main.tex 19055 2008-06-05 11:20:31Z cfbolz $-$}} + } + {\newcommand{\nb}[2]{} + \newcommand{\version}{} + } + +\newcommand\dacom[1]{\nb{DA}{#1}} +\newcommand\cfbolz[1]{\nb{CFB}{#1}} +\newcommand\anto[1]{\nb{ANTO}{#1}} +\newcommand\arigo[1]{\nb{AR}{#1}} +\newcommand{\commentout}[1]{} + +\let\oldcite=\cite + +\renewcommand\cite[1]{\ifthenelse{\equal{#1}{XXX}}{[citation~needed]}{\oldcite{#1}}} + + +\begin{document} +\title{Tutorial Proposal: Writing Interpreters for Dynamic Languages Using PyPy +(and Getting Them Fast)} + + +\author{Carl Friedrich Bolz\inst{2} \email{cfbolz at gmx.de} \and Antonio Cuni\inst{1} \email{anto.cuni at gmail.com} \and Armin Rigo\inst{2} \email{arigo at tunes.org}} + +\institute{DISI, University of Genova, Italy +\and +Softwaretechnik und Programmiersprachen + Heinrich-Heine-Universit\"at D\"usseldorf} + +\maketitle + +The easiest way to implement a dynamic language such as JavaScript or Python is +to write an interpreter for it; however, interpreters are slow. An alternative +is to write a compiler; writing a compiler that targets a high level virtual +machine like CLI or JVM is easier than targeting a real CPU, but it still +require a lot of work, as IronPython, Jython, JRuby demonstrate. Moreover, +the various platforms have to be targeted independently. + +The PyPy project \cite{RiBo07_223} aims to make the implementation of dynamic +languages easier by providing a toolchain that allows to translate an +interpreter to various target platforms, including the JVM, .NET and C/Posix. +In addition, we are working on being able to automatically transform the +interpreter into a specializing JIT-compiler to vastly increase performance. +The goal is to minimize the effort required to get a fast implementation of a +dynamic language. + + + +Outline of the tutorial: + + - introduction to PyPy + - present the small language and its interpreter + - show how to compile the interpreter to various platforms + - show how to apply JIT-generator + + +\bibliographystyle{plain} +\bibliography{main} + +\end{document} From cfbolz at codespeak.net Mon Jan 19 14:02:58 2009 From: cfbolz at codespeak.net (cfbolz at codespeak.net) Date: Mon, 19 Jan 2009 14:02:58 +0100 (CET) Subject: [pypy-svn] r61111 - pypy/extradoc/talk/ecoop2009/tutorial Message-ID: <20090119130258.4BC6A1684F2@codespeak.net> Author: cfbolz Date: Mon Jan 19 14:02:57 2009 New Revision: 61111 Modified: pypy/extradoc/talk/ecoop2009/tutorial/proposal.tex Log: (cfbolz, antocuni, arigo): expanded the proposal Modified: pypy/extradoc/talk/ecoop2009/tutorial/proposal.tex ============================================================================== --- pypy/extradoc/talk/ecoop2009/tutorial/proposal.tex (original) +++ pypy/extradoc/talk/ecoop2009/tutorial/proposal.tex Mon Jan 19 14:02:57 2009 @@ -81,7 +81,8 @@ require a lot of work, as IronPython, Jython, JRuby demonstrate. Moreover, the various platforms have to be targeted independently. -The PyPy project \cite{RiBo07_223} aims to make the implementation of dynamic +The PyPy project\footnote{\url{http://codespeak.net/pypy}} \cite{RiBo07_223} +aims to make the implementation of dynamic languages easier by providing a toolchain that allows to translate an interpreter to various target platforms, including the JVM, .NET and C/Posix. In addition, we are working on being able to automatically transform the @@ -89,17 +90,36 @@ The goal is to minimize the effort required to get a fast implementation of a dynamic language. +This tutorial will give an insight into the usage of the PyPy translation +toolchain by giving a step-by-step introduction. The topics covered are how to +write an interpreter for a dynamic language for PyPy and make it possible to +automatically generate a JIT for it. We will showcase a typical interpreter for a +small dynamic language as a running example. -Outline of the tutorial: - - introduction to PyPy - - present the small language and its interpreter - - show how to compile the interpreter to various platforms - - show how to apply JIT-generator +Outline of the tutorial: +\begin{itemize} + \item \textbf{Introduction to PyPy:} Introduce the PyPy project and give an + overview of its goals. + \item \textbf{Overview of the example language:} Present the small language and + its interpreter that will be used as a running example throughout the tutorial. + \item \textbf{Translation:} Show how to compile the interpreter to various + platforms, including .NET and C/Posix. + \item \textbf{JIT-Generation:} Show how to apply the JIT-generator to the + interpreter to automatically get a JIT for the language. +\end{itemize} + + +There is a current resurgence in research on JIT-compilers for dynamic +languages, mostly focusing on JavaScript implementations. PyPy generates such +JITs so that they don't have to be hand-written. This requires much less effort +for the language implementor. +The presenters are part of the PyPy core development team and are all involved +in the ongoing research on the JIT generator. \bibliographystyle{plain} -\bibliography{main} +\bibliography{proposal} \end{document} From cfbolz at codespeak.net Mon Jan 19 14:34:05 2009 From: cfbolz at codespeak.net (cfbolz at codespeak.net) Date: Mon, 19 Jan 2009 14:34:05 +0100 (CET) Subject: [pypy-svn] r61112 - pypy/extradoc/talk/ecoop2009/tutorial Message-ID: <20090119133405.7FA051684BA@codespeak.net> Author: cfbolz Date: Mon Jan 19 14:34:03 2009 New Revision: 61112 Modified: pypy/extradoc/talk/ecoop2009/tutorial/proposal.tex Log: (antocuni, arigo, cfbolz): write an exciting abstract. Modified: pypy/extradoc/talk/ecoop2009/tutorial/proposal.tex ============================================================================== --- pypy/extradoc/talk/ecoop2009/tutorial/proposal.tex (original) +++ pypy/extradoc/talk/ecoop2009/tutorial/proposal.tex Mon Jan 19 14:34:03 2009 @@ -71,33 +71,42 @@ \and Softwaretechnik und Programmiersprachen Heinrich-Heine-Universit\"at D\"usseldorf} - \maketitle + +\begin{abstract} +We propose to give a tutorial on how to use the PyPy project to write +interpreters for dynamic languages. PyPy supports compiling such interpreters +to various target environments (like .NET or C/Posix) and automatically +generating a Just-In-Time compiler for them. PyPy is thus an emerging tool to +help implement fast, portable multi-platform interpreters with less effort. +\end{abstract} + The easiest way to implement a dynamic language such as JavaScript or Python is to write an interpreter for it; however, interpreters are slow. An alternative is to write a compiler; writing a compiler that targets a high level virtual machine like CLI or JVM is easier than targeting a real CPU, but it still -require a lot of work, as IronPython, Jython, JRuby demonstrate. Moreover, -the various platforms have to be targeted independently. +require a lot of work, as demonstrated by the IronPython, Jython, JRuby +projects. Moreover, the various platforms (either VM or real hardware) have to +be targeted independently. -The PyPy project\footnote{\url{http://codespeak.net/pypy}} \cite{RiBo07_223} +The PyPy project\footnote{\url{http://codespeak.net/pypy}} \cite{RigoPedroni06} +\cite{RiBo07_223} aims to make the implementation of dynamic -languages easier by providing a toolchain that allows to translate an +languages easier by providing a toolchain that allows to compile an interpreter to various target platforms, including the JVM, .NET and C/Posix. -In addition, we are working on being able to automatically transform the +In addition, we are working automatically transforming the interpreter into a specializing JIT-compiler to vastly increase performance. -The goal is to minimize the effort required to get a fast implementation of a +The goal is to minimize the effort required to get a fast implementation for a dynamic language. -This tutorial will give an insight into the usage of the PyPy translation +This tutorial will provide insights into the usage of the PyPy translation toolchain by giving a step-by-step introduction. The topics covered are how to -write an interpreter for a dynamic language for PyPy and make it possible to +write an interpreter for a dynamic language with PyPy and make it possible to automatically generate a JIT for it. We will showcase a typical interpreter for a small dynamic language as a running example. - Outline of the tutorial: \begin{itemize} \item \textbf{Introduction to PyPy:} Introduce the PyPy project and give an From cfbolz at codespeak.net Mon Jan 19 14:35:20 2009 From: cfbolz at codespeak.net (cfbolz at codespeak.net) Date: Mon, 19 Jan 2009 14:35:20 +0100 (CET) Subject: [pypy-svn] r61113 - pypy/extradoc/talk/ecoop2009/tutorial Message-ID: <20090119133520.719D71684BA@codespeak.net> Author: cfbolz Date: Mon Jan 19 14:35:20 2009 New Revision: 61113 Added: pypy/extradoc/talk/ecoop2009/tutorial/proposal.bib Log: add bibtex Added: pypy/extradoc/talk/ecoop2009/tutorial/proposal.bib ============================================================================== --- (empty file) +++ pypy/extradoc/talk/ecoop2009/tutorial/proposal.bib Mon Jan 19 14:35:20 2009 @@ -0,0 +1,36 @@ + + at inproceedings{RiBo07_223, + author = {Armin Rigo and Carl Friedrich Bolz}, + title = {{How to \emph{not} write Virtual Machines for Dynamic Languages +}}, + booktitle = {Proceedings of Dyla}, + abstract = {Typical modern dynamic languages have a growing number of + implementations. We explore the reasons for this situation, + and the limitations it imposes on open source or academic + communities that lack the resources to fine-tune and + maintain them all. It is sometimes proposed that + implementing dynamic languages on top of a standardized + general-purpose object-oriented virtual machine (like Java + or .NET) would help reduce this burden. We propose a + complementary alternative to writing custom virtual machine + (VMs) by hand, validated by the PyPy project: flexibly + generating VMs from a high-level specification, inserting + features and low-level details automatically ? including + good just-in-time compilers tuned to the dynamic language at + hand. We believe this to be ultimately a better investment + of efforts than the development of more and more advanced + general-purpose object oriented VMs. In this paper we + compare these two approaches in detail.}, + year = {2007}, +} + + + at InProceedings{RigoPedroni06, +author = {A.~Rigo and + S.~Pedroni}, +title = {Py{P}y's approach to virtual machine construction}, +booktitle = {OOPSLA Companion}, +year = {2006}, +pages = {944-953}, +} + From arigo at codespeak.net Mon Jan 19 14:42:44 2009 From: arigo at codespeak.net (arigo at codespeak.net) Date: Mon, 19 Jan 2009 14:42:44 +0100 (CET) Subject: [pypy-svn] r61114 - pypy/extradoc/talk/ecoop2009/tutorial Message-ID: <20090119134244.984161684BA@codespeak.net> Author: arigo Date: Mon Jan 19 14:42:43 2009 New Revision: 61114 Added: pypy/extradoc/talk/ecoop2009/tutorial/Makefile (contents, props changed) Log: Add a Makefile. Added: pypy/extradoc/talk/ecoop2009/tutorial/Makefile ============================================================================== --- (empty file) +++ pypy/extradoc/talk/ecoop2009/tutorial/Makefile Mon Jan 19 14:42:43 2009 @@ -0,0 +1,10 @@ +%.pdf: %.tex %.bib + pdflatex $< + bibtex $* + pdflatex $< + pdflatex $< + +auto: proposal.pdf + +clean: + rm -f *.bbl *.aux *.log *.blg *.pdf From arigo at codespeak.net Mon Jan 19 14:46:34 2009 From: arigo at codespeak.net (arigo at codespeak.net) Date: Mon, 19 Jan 2009 14:46:34 +0100 (CET) Subject: [pypy-svn] r61115 - pypy/extradoc/talk/ecoop2009/tutorial Message-ID: <20090119134634.08CD91684C8@codespeak.net> Author: arigo Date: Mon Jan 19 14:46:33 2009 New Revision: 61115 Modified: pypy/extradoc/talk/ecoop2009/tutorial/proposal.tex Log: Typo. Modified: pypy/extradoc/talk/ecoop2009/tutorial/proposal.tex ============================================================================== --- pypy/extradoc/talk/ecoop2009/tutorial/proposal.tex (original) +++ pypy/extradoc/talk/ecoop2009/tutorial/proposal.tex Mon Jan 19 14:46:33 2009 @@ -95,7 +95,7 @@ aims to make the implementation of dynamic languages easier by providing a toolchain that allows to compile an interpreter to various target platforms, including the JVM, .NET and C/Posix. -In addition, we are working automatically transforming the +In addition, we are working on automatically transforming the interpreter into a specializing JIT-compiler to vastly increase performance. The goal is to minimize the effort required to get a fast implementation for a dynamic language. From antocuni at codespeak.net Mon Jan 19 15:26:43 2009 From: antocuni at codespeak.net (antocuni at codespeak.net) Date: Mon, 19 Jan 2009 15:26:43 +0100 (CET) Subject: [pypy-svn] r61117 - in pypy/extradoc/talk/ecoop2009: . tutorial Message-ID: <20090119142643.A06191684DC@codespeak.net> Author: antocuni Date: Mon Jan 19 15:26:43 2009 New Revision: 61117 Modified: pypy/extradoc/talk/ecoop2009/intro.tex pypy/extradoc/talk/ecoop2009/tutorial/proposal.tex Log: (antocuni, cfbolz) minor fixes Modified: pypy/extradoc/talk/ecoop2009/intro.tex ============================================================================== --- pypy/extradoc/talk/ecoop2009/intro.tex (original) +++ pypy/extradoc/talk/ecoop2009/intro.tex Mon Jan 19 15:26:43 2009 @@ -4,7 +4,7 @@ The alternative is to write a compiler; writing a compiler that targets a high level virtual machine like CLI or JVM is easier than targeting a real CPU, but -it still require a lot of work, as IronPython, Jython, JRuby demonstrate. +it still requires a lot of work, as IronPython, Jython, JRuby demonstrate. Moreover, writing a static compiler is often not enough to get high performance; IronPython and JRuby are going in the direction of JIT compiling Modified: pypy/extradoc/talk/ecoop2009/tutorial/proposal.tex ============================================================================== --- pypy/extradoc/talk/ecoop2009/tutorial/proposal.tex (original) +++ pypy/extradoc/talk/ecoop2009/tutorial/proposal.tex Mon Jan 19 15:26:43 2009 @@ -86,7 +86,7 @@ to write an interpreter for it; however, interpreters are slow. An alternative is to write a compiler; writing a compiler that targets a high level virtual machine like CLI or JVM is easier than targeting a real CPU, but it still -require a lot of work, as demonstrated by the IronPython, Jython, JRuby +requires a lot of work, as demonstrated by the IronPython, Jython, JRuby projects. Moreover, the various platforms (either VM or real hardware) have to be targeted independently. @@ -95,7 +95,7 @@ aims to make the implementation of dynamic languages easier by providing a toolchain that allows to compile an interpreter to various target platforms, including the JVM, .NET and C/Posix. -In addition, we are working on automatically transforming the +In addition, we are working on being able to automatically transform the interpreter into a specializing JIT-compiler to vastly increase performance. The goal is to minimize the effort required to get a fast implementation for a dynamic language. @@ -104,7 +104,7 @@ toolchain by giving a step-by-step introduction. The topics covered are how to write an interpreter for a dynamic language with PyPy and make it possible to automatically generate a JIT for it. We will showcase a typical interpreter for a -small dynamic language as a running example. +small object-oriented dynamic language as a running example. Outline of the tutorial: @@ -116,7 +116,7 @@ \item \textbf{Translation:} Show how to compile the interpreter to various platforms, including .NET and C/Posix. \item \textbf{JIT-Generation:} Show how to apply the JIT-generator to the - interpreter to automatically get a JIT for the language. + interpreter by placing a few hints to automatically get a JIT for the language. \end{itemize} From cfbolz at codespeak.net Mon Jan 19 15:36:02 2009 From: cfbolz at codespeak.net (cfbolz at codespeak.net) Date: Mon, 19 Jan 2009 15:36:02 +0100 (CET) Subject: [pypy-svn] r61118 - pypy/extradoc/talk/ecoop2009/tutorial Message-ID: <20090119143602.6CC011684F8@codespeak.net> Author: cfbolz Date: Mon Jan 19 15:36:02 2009 New Revision: 61118 Modified: pypy/extradoc/talk/ecoop2009/tutorial/proposal.bib pypy/extradoc/talk/ecoop2009/tutorial/proposal.tex Log: (arigo, antocuni, cfbolz): more advertisement Modified: pypy/extradoc/talk/ecoop2009/tutorial/proposal.bib ============================================================================== --- pypy/extradoc/talk/ecoop2009/tutorial/proposal.bib (original) +++ pypy/extradoc/talk/ecoop2009/tutorial/proposal.bib Mon Jan 19 15:36:02 2009 @@ -34,3 +34,11 @@ pages = {944-953}, } + at techreport{PyPyJIT, + title = "{JIT} Compiler Architecture", + author = {Armin Rigo and Samuele Pedroni}, + year = "2007", + institution = "PyPy Consortium", + number = "D08.2", + note = "http://codespeak.net/pypy/dist/pypy/doc/index-report.html" +} Modified: pypy/extradoc/talk/ecoop2009/tutorial/proposal.tex ============================================================================== --- pypy/extradoc/talk/ecoop2009/tutorial/proposal.tex (original) +++ pypy/extradoc/talk/ecoop2009/tutorial/proposal.tex Mon Jan 19 15:36:02 2009 @@ -123,7 +123,8 @@ There is a current resurgence in research on JIT-compilers for dynamic languages, mostly focusing on JavaScript implementations. PyPy generates such JITs so that they don't have to be hand-written. This requires much less effort -for the language implementor. +for the language implementor. PyPy is the first project that attempts to +generate JITs at this scale \cite{PyPyJIT}. The presenters are part of the PyPy core development team and are all involved in the ongoing research on the JIT generator. From fijal at codespeak.net Mon Jan 19 16:55:38 2009 From: fijal at codespeak.net (fijal at codespeak.net) Date: Mon, 19 Jan 2009 16:55:38 +0100 (CET) Subject: [pypy-svn] r61125 - pypy/trunk/lib-python/modified-2.5.2/test Message-ID: <20090119155538.AC02A1684B3@codespeak.net> Author: fijal Date: Mon Jan 19 16:55:37 2009 New Revision: 61125 Modified: pypy/trunk/lib-python/modified-2.5.2/test/test_codecs.py Log: oops, this was not suppose to be checked in Modified: pypy/trunk/lib-python/modified-2.5.2/test/test_codecs.py ============================================================================== --- pypy/trunk/lib-python/modified-2.5.2/test/test_codecs.py (original) +++ pypy/trunk/lib-python/modified-2.5.2/test/test_codecs.py Mon Jan 19 16:55:37 2009 @@ -997,7 +997,7 @@ "base64_codec", #"big5", #"big5hkscs", - #"charmap", + "charmap", "cp037", "cp1006", "cp1026", From fijal at codespeak.net Mon Jan 19 16:56:47 2009 From: fijal at codespeak.net (fijal at codespeak.net) Date: Mon, 19 Jan 2009 16:56:47 +0100 (CET) Subject: [pypy-svn] r61126 - pypy/trunk/lib-python/modified-2.5.2/test Message-ID: <20090119155647.562221684B3@codespeak.net> Author: fijal Date: Mon Jan 19 16:56:46 2009 New Revision: 61126 Added: pypy/trunk/lib-python/modified-2.5.2/test/test_pyexpat.py - copied, changed from r61094, pypy/trunk/lib-python/2.5.2/test/test_pyexpat.py Log: I would say that reuse of the same string is an impl detail Copied: pypy/trunk/lib-python/modified-2.5.2/test/test_pyexpat.py (from r61094, pypy/trunk/lib-python/2.5.2/test/test_pyexpat.py) ============================================================================== --- pypy/trunk/lib-python/2.5.2/test/test_pyexpat.py (original) +++ pypy/trunk/lib-python/modified-2.5.2/test/test_pyexpat.py Mon Jan 19 16:56:46 2009 @@ -6,7 +6,7 @@ import pyexpat from xml.parsers import expat -from test.test_support import sortdict, TestFailed +from test.test_support import sortdict, TestFailed, check_impl_detail class Outputter: def StartElementHandler(self, name, attrs): @@ -212,12 +212,13 @@ tag = L[0] if len(L) != 6: print "L should only contain 6 entries; found", len(L) -for entry in L: - if tag is not entry: - print "expected L to contain many references to the same string", - print "(it didn't)" - print "L =", repr(L) - break +if check_impl_detail(): + for entry in L: + if tag is not entry: + print "expected L to contain many references to the same string", + print "(it didn't)" + print "L =", repr(L) + break # Tests of the buffer_text attribute. import sys From fijal at codespeak.net Mon Jan 19 17:04:50 2009 From: fijal at codespeak.net (fijal at codespeak.net) Date: Mon, 19 Jan 2009 17:04:50 +0100 (CET) Subject: [pypy-svn] r61127 - in pypy/trunk/pypy/module/signal: . test Message-ID: <20090119160450.B59AA1684B3@codespeak.net> Author: fijal Date: Mon Jan 19 17:04:49 2009 New Revision: 61127 Modified: pypy/trunk/pypy/module/signal/__init__.py pypy/trunk/pypy/module/signal/interp_signal.py pypy/trunk/pypy/module/signal/test/test_signal.py Log: implement alarm, pure fun Modified: pypy/trunk/pypy/module/signal/__init__.py ============================================================================== --- pypy/trunk/pypy/module/signal/__init__.py (original) +++ pypy/trunk/pypy/module/signal/__init__.py Mon Jan 19 17:04:49 2009 @@ -8,6 +8,7 @@ 'NSIG': 'space.wrap(interp_signal.NSIG)', 'SIG_DFL': 'space.wrap(interp_signal.SIG_DFL)', 'SIG_IGN': 'space.wrap(interp_signal.SIG_IGN)', + 'alarm': 'interp_signal.alarm', } appleveldefs = { Modified: pypy/trunk/pypy/module/signal/interp_signal.py ============================================================================== --- pypy/trunk/pypy/module/signal/interp_signal.py (original) +++ pypy/trunk/pypy/module/signal/interp_signal.py Mon Jan 19 17:04:49 2009 @@ -42,6 +42,7 @@ lltype.Signed, _nowrapper=True) pypysig_set_occurred = external('pypysig_set_occurred', [lltype.Signed], lltype.Void, _nowrapper=True) +c_alarm = external('alarm', [rffi.INT], rffi.INT) class SignalActionFlag(AbstractActionFlag): @@ -150,6 +151,9 @@ return space.wrap(SIG_DFL) getsignal.unwrap_spec = [ObjSpace, int] +def alarm(space, timeout): + return c_alarm(timeout) +alarm.unwrap_spec = [ObjSpace, int] def signal(space, signum, w_handler): """ Modified: pypy/trunk/pypy/module/signal/test/test_signal.py ============================================================================== --- pypy/trunk/pypy/module/signal/test/test_signal.py (original) +++ pypy/trunk/pypy/module/signal/test/test_signal.py Mon Jan 19 17:04:49 2009 @@ -115,3 +115,20 @@ assert getsignal(SIGUSR1) is handler finally: signal(SIGUSR1, SIG_DFL) + + def test_alarm(self): + from signal import alarm, signal, SIG_DFL, SIGALRM + import time + l = [] + def handler(*a): + l.append(42) + + try: + signal(SIGALRM, handler) + alarm(1) + time.sleep(2) + assert l == [42] + alarm(0) + assert l == [42] + finally: + signal(SIGALRM, SIG_DFL) From cfbolz at codespeak.net Mon Jan 19 17:56:01 2009 From: cfbolz at codespeak.net (cfbolz at codespeak.net) Date: Mon, 19 Jan 2009 17:56:01 +0100 (CET) Subject: [pypy-svn] r61134 - pypy/trunk/pypy/rlib/parsing Message-ID: <20090119165601.1536F1684CB@codespeak.net> Author: cfbolz Date: Mon Jan 19 17:56:00 2009 New Revision: 61134 Modified: pypy/trunk/pypy/rlib/parsing/deterministic.py Log: nicer __str__ Modified: pypy/trunk/pypy/rlib/parsing/deterministic.py ============================================================================== --- pypy/trunk/pypy/rlib/parsing/deterministic.py (original) +++ pypy/trunk/pypy/rlib/parsing/deterministic.py Mon Jan 19 17:56:00 2009 @@ -65,6 +65,9 @@ result.append("LexerError") return "\n".join(result) + def __str__(self): + return self.nice_error_message() + class DFA(object): def __init__(self, num_states=0, transitions=None, final_states=None, unmergeable_states=None, names=None): From fijal at codespeak.net Mon Jan 19 18:14:47 2009 From: fijal at codespeak.net (fijal at codespeak.net) Date: Mon, 19 Jan 2009 18:14:47 +0100 (CET) Subject: [pypy-svn] r61137 - pypy/branch/oo-jit/pypy/rpython/lltypesystem Message-ID: <20090119171447.74DCA168498@codespeak.net> Author: fijal Date: Mon Jan 19 18:14:47 2009 New Revision: 61137 Modified: pypy/branch/oo-jit/pypy/rpython/lltypesystem/ll2ctypes.py Log: a missing cast Modified: pypy/branch/oo-jit/pypy/rpython/lltypesystem/ll2ctypes.py ============================================================================== --- pypy/branch/oo-jit/pypy/rpython/lltypesystem/ll2ctypes.py (original) +++ pypy/branch/oo-jit/pypy/rpython/lltypesystem/ll2ctypes.py Mon Jan 19 18:14:47 2009 @@ -930,6 +930,9 @@ def _cast_to_int(self): return self.intval + def _cast_to_adr(self): + return _lladdress(ctypes.c_void_p(self.intval)) + def cast_adr_to_int(addr): if isinstance(addr, llmemory.fakeaddress): # use ll2ctypes to obtain a real ctypes-based representation of From fijal at codespeak.net Mon Jan 19 18:15:47 2009 From: fijal at codespeak.net (fijal at codespeak.net) Date: Mon, 19 Jan 2009 18:15:47 +0100 (CET) Subject: [pypy-svn] r61138 - pypy/branch/oo-jit/pypy/rpython/lltypesystem Message-ID: <20090119171547.148F2168498@codespeak.net> Author: fijal Date: Mon Jan 19 18:15:46 2009 New Revision: 61138 Modified: pypy/branch/oo-jit/pypy/rpython/lltypesystem/ll2ctypes.py Log: this cast is not needed after all Modified: pypy/branch/oo-jit/pypy/rpython/lltypesystem/ll2ctypes.py ============================================================================== --- pypy/branch/oo-jit/pypy/rpython/lltypesystem/ll2ctypes.py (original) +++ pypy/branch/oo-jit/pypy/rpython/lltypesystem/ll2ctypes.py Mon Jan 19 18:15:46 2009 @@ -930,9 +930,6 @@ def _cast_to_int(self): return self.intval - def _cast_to_adr(self): - return _lladdress(ctypes.c_void_p(self.intval)) - def cast_adr_to_int(addr): if isinstance(addr, llmemory.fakeaddress): # use ll2ctypes to obtain a real ctypes-based representation of From fijal at codespeak.net Mon Jan 19 18:17:40 2009 From: fijal at codespeak.net (fijal at codespeak.net) Date: Mon, 19 Jan 2009 18:17:40 +0100 (CET) Subject: [pypy-svn] r61139 - pypy/branch/oo-jit/pypy/rpython/lltypesystem Message-ID: <20090119171740.3D699168498@codespeak.net> Author: fijal Date: Mon Jan 19 18:17:39 2009 New Revision: 61139 Modified: pypy/branch/oo-jit/pypy/rpython/lltypesystem/ll2ctypes.py Log: keepalive issue Modified: pypy/branch/oo-jit/pypy/rpython/lltypesystem/ll2ctypes.py ============================================================================== --- pypy/branch/oo-jit/pypy/rpython/lltypesystem/ll2ctypes.py (original) +++ pypy/branch/oo-jit/pypy/rpython/lltypesystem/ll2ctypes.py Mon Jan 19 18:17:39 2009 @@ -937,10 +937,7 @@ if addr.ptr is None: res = 0 else: - c = lltype2ctypes(addr.ptr) - c = ctypes.cast(c, ctypes.c_void_p) - assert c.value - res = c.value + res = force_cast(lltype.Signed, addr.ptr) else: res = addr._cast_to_int() if res > sys.maxint: From fijal at codespeak.net Mon Jan 19 23:17:44 2009 From: fijal at codespeak.net (fijal at codespeak.net) Date: Mon, 19 Jan 2009 23:17:44 +0100 (CET) Subject: [pypy-svn] r61146 - pypy/branch/oo-jit/pypy/rpython/lltypesystem Message-ID: <20090119221744.52384168464@codespeak.net> Author: fijal Date: Mon Jan 19 23:17:42 2009 New Revision: 61146 Modified: pypy/branch/oo-jit/pypy/rpython/lltypesystem/ll2ctypes.py Log: * missing casts * off-by-one error. I was wondering why my ptrs % 4 == 2 Modified: pypy/branch/oo-jit/pypy/rpython/lltypesystem/ll2ctypes.py ============================================================================== --- pypy/branch/oo-jit/pypy/rpython/lltypesystem/ll2ctypes.py (original) +++ pypy/branch/oo-jit/pypy/rpython/lltypesystem/ll2ctypes.py Mon Jan 19 23:17:42 2009 @@ -899,13 +899,22 @@ def __new__(cls, void_p): self = long.__new__(cls, void_p.value) self.void_p = void_p + self.intval = void_p.value + if self.intval > sys.maxint: + self.intval = int(self.intval - 2*(sys.maxint + 1)) return self + def _cast_to_ptr(self, TP): + return force_cast(TP, self.intval) + def __repr__(self): return '<_lladdress %s>' % (self.void_p,) - def _cast_to_int(self): - return ctypes.cast(self.void_p, ctypes.c_long) + def __eq__(self, other): + return cast_adr_to_int(other) == self.intval + + def __ne__(self, other): + return not self == other class _llgcref(object): _TYPE = llmemory.GCREF @@ -930,6 +939,9 @@ def _cast_to_int(self): return self.intval + def _cast_to_adr(self): + return _lladdress(ctypes.c_void_p(self.intval)) + def cast_adr_to_int(addr): if isinstance(addr, llmemory.fakeaddress): # use ll2ctypes to obtain a real ctypes-based representation of @@ -941,7 +953,7 @@ else: res = addr._cast_to_int() if res > sys.maxint: - res = res - 2*sys.maxint + res = res - 2*(sys.maxint + 1) assert int(res) == res return int(res) return res From fijal at codespeak.net Tue Jan 20 00:29:35 2009 From: fijal at codespeak.net (fijal at codespeak.net) Date: Tue, 20 Jan 2009 00:29:35 +0100 (CET) Subject: [pypy-svn] r61148 - pypy/branch/oo-jit/pypy/annotation/test Message-ID: <20090119232935.58BC4168489@codespeak.net> Author: fijal Date: Tue Jan 20 00:29:32 2009 New Revision: 61148 Modified: pypy/branch/oo-jit/pypy/annotation/test/test_annrpython.py Log: a problem with constant folding, unsure if I want to tackle it right now Modified: pypy/branch/oo-jit/pypy/annotation/test/test_annrpython.py ============================================================================== --- pypy/branch/oo-jit/pypy/annotation/test/test_annrpython.py (original) +++ pypy/branch/oo-jit/pypy/annotation/test/test_annrpython.py Tue Jan 20 00:29:32 2009 @@ -3059,6 +3059,48 @@ assert s.const == 42 + def test_list_of_pbcs(self): + class X: + def __init__(self, a, b): + self.a = a + self.b = b + + def m(self): + return self.a + + class Y(X): + def __init__(self, a, b): + self.a = 10 + + def m(self): + return self.a + + class Z(X): + pass + + class XX(X): + def __init__(self, c): + self.c = c + + def m(self): + return self.c + + l = [Z(1, 2), Z(3, 4), Y("a", "b"), X(5, 6), X(1, 2)] + def f(n): + elem = l[n] + if isinstance(elem, Y): + return elem.m() + elif isinstance(elem, Z): + return elem.m() + elif isinstance(elem, XX): + return elem.m() + else: + return 3 + + a = self.RPythonAnnotator() + a.build_types(f, [int]) + # assert did not explode + def g(n): return [0,1,2,n] From fijal at codespeak.net Tue Jan 20 09:07:38 2009 From: fijal at codespeak.net (fijal at codespeak.net) Date: Tue, 20 Jan 2009 09:07:38 +0100 (CET) Subject: [pypy-svn] r61151 - pypy/trunk/pypy/module/signal Message-ID: <20090120080738.545EA16847E@codespeak.net> Author: fijal Date: Tue Jan 20 09:07:36 2009 New Revision: 61151 Modified: pypy/trunk/pypy/module/signal/interp_signal.py Log: translation fix Modified: pypy/trunk/pypy/module/signal/interp_signal.py ============================================================================== --- pypy/trunk/pypy/module/signal/interp_signal.py (original) +++ pypy/trunk/pypy/module/signal/interp_signal.py Tue Jan 20 09:07:36 2009 @@ -152,7 +152,7 @@ getsignal.unwrap_spec = [ObjSpace, int] def alarm(space, timeout): - return c_alarm(timeout) + return space.wrap(c_alarm(timeout)) alarm.unwrap_spec = [ObjSpace, int] def signal(space, signum, w_handler): From antocuni at codespeak.net Tue Jan 20 10:36:31 2009 From: antocuni at codespeak.net (antocuni at codespeak.net) Date: Tue, 20 Jan 2009 10:36:31 +0100 (CET) Subject: [pypy-svn] r61152 - pypy/trunk/pypy/module/signal Message-ID: <20090120093631.5141E16847A@codespeak.net> Author: antocuni Date: Tue Jan 20 10:36:29 2009 New Revision: 61152 Modified: pypy/trunk/pypy/module/signal/__init__.py Log: comment out alarm, as it seems that r61127 broke translation Modified: pypy/trunk/pypy/module/signal/__init__.py ============================================================================== --- pypy/trunk/pypy/module/signal/__init__.py (original) +++ pypy/trunk/pypy/module/signal/__init__.py Tue Jan 20 10:36:29 2009 @@ -8,7 +8,7 @@ 'NSIG': 'space.wrap(interp_signal.NSIG)', 'SIG_DFL': 'space.wrap(interp_signal.SIG_DFL)', 'SIG_IGN': 'space.wrap(interp_signal.SIG_IGN)', - 'alarm': 'interp_signal.alarm', +## 'alarm': 'interp_signal.alarm', } appleveldefs = { From antocuni at codespeak.net Tue Jan 20 11:33:42 2009 From: antocuni at codespeak.net (antocuni at codespeak.net) Date: Tue, 20 Jan 2009 11:33:42 +0100 (CET) Subject: [pypy-svn] r61153 - pypy/trunk/pypy/module/signal Message-ID: <20090120103342.E9B2C168473@codespeak.net> Author: antocuni Date: Tue Jan 20 11:33:41 2009 New Revision: 61153 Modified: pypy/trunk/pypy/module/signal/__init__.py Log: re-enable fixed function Modified: pypy/trunk/pypy/module/signal/__init__.py ============================================================================== --- pypy/trunk/pypy/module/signal/__init__.py (original) +++ pypy/trunk/pypy/module/signal/__init__.py Tue Jan 20 11:33:41 2009 @@ -8,7 +8,7 @@ 'NSIG': 'space.wrap(interp_signal.NSIG)', 'SIG_DFL': 'space.wrap(interp_signal.SIG_DFL)', 'SIG_IGN': 'space.wrap(interp_signal.SIG_IGN)', -## 'alarm': 'interp_signal.alarm', + 'alarm': 'interp_signal.alarm', } appleveldefs = { From fijal at codespeak.net Tue Jan 20 14:15:25 2009 From: fijal at codespeak.net (fijal at codespeak.net) Date: Tue, 20 Jan 2009 14:15:25 +0100 (CET) Subject: [pypy-svn] r61156 - pypy/branch/oo-jit/pypy/translator/c Message-ID: <20090120131525.B1957168471@codespeak.net> Author: fijal Date: Tue Jan 20 14:15:22 2009 New Revision: 61156 Modified: pypy/branch/oo-jit/pypy/translator/c/database.py Log: an ability to render GCREFs. I'm not sure if this is cool btw. I tried a lot to write a test for it, gave up for now Modified: pypy/branch/oo-jit/pypy/translator/c/database.py ============================================================================== --- pypy/branch/oo-jit/pypy/translator/c/database.py (original) +++ pypy/branch/oo-jit/pypy/translator/c/database.py Tue Jan 20 14:15:22 2009 @@ -3,7 +3,8 @@ Struct, Array, FuncType, PyObject, Void, \ ContainerType, OpaqueType, FixedSizeArray, _uninitialized from pypy.rpython.lltypesystem import lltype -from pypy.rpython.lltypesystem.llmemory import Address, WeakRef, _WeakRefType +from pypy.rpython.lltypesystem.llmemory import Address, WeakRef, _WeakRefType,\ + GCREF from pypy.rpython.lltypesystem.rffi import CConstant from pypy.tool.sourcetools import valid_identifier from pypy.translator.c.primitive import PrimitiveName, PrimitiveType @@ -145,6 +146,8 @@ raise Exception("don't know about type %r" % (T,)) def getcontainernode(self, container, _dont_write_c_code=True, **buildkwds): + if typeOf(container) == GCREF.TO: + container = container.container try: node = self.containernodes[container] except KeyError: From antocuni at codespeak.net Tue Jan 20 15:35:55 2009 From: antocuni at codespeak.net (antocuni at codespeak.net) Date: Tue, 20 Jan 2009 15:35:55 +0100 (CET) Subject: [pypy-svn] r61160 - pypy/trunk/pypy/interpreter Message-ID: <20090120143555.4D3561684A6@codespeak.net> Author: antocuni Date: Tue Jan 20 15:35:52 2009 New Revision: 61160 Modified: pypy/trunk/pypy/interpreter/generator.py pypy/trunk/pypy/interpreter/typedef.py Log: implement __del__ for generator objects, but comment out it as it triggers a bug in the hybrid gc Modified: pypy/trunk/pypy/interpreter/generator.py ============================================================================== --- pypy/trunk/pypy/interpreter/generator.py (original) +++ pypy/trunk/pypy/interpreter/generator.py Tue Jan 20 15:35:52 2009 @@ -111,5 +111,15 @@ msg = "generator ignored GeneratorExit" raise OperationError(space.w_RuntimeError, space.wrap(msg)) + def descr__del__(self): + """ + applevel __del__, which is called at a safe point after the + interp-level __del__ enqueued the object for destruction + """ + self.descr_close() + +## # it seems there is a bug in the hybrid gc, if we add a __del__ it +## # segfaults. With mark&sweep it works correctly ## def __del__(self): -## self.descr_close() +## if not self.frame.frame_finished_execution: +## self._enqueue_for_destruction(self.space) Modified: pypy/trunk/pypy/interpreter/typedef.py ============================================================================== --- pypy/trunk/pypy/interpreter/typedef.py (original) +++ pypy/trunk/pypy/interpreter/typedef.py Tue Jan 20 15:35:52 2009 @@ -863,6 +863,8 @@ descrmismatch='close'), __iter__ = interp2app(GeneratorIterator.descr__iter__, descrmismatch='__iter__'), + __del__ = interp2app(GeneratorIterator.descr__del__, + descrmismatch='__del__'), gi_running = interp_attrproperty('running', cls=GeneratorIterator), gi_frame = interp_attrproperty('frame', cls=GeneratorIterator), __weakref__ = make_weakref_descr(GeneratorIterator), From antocuni at codespeak.net Tue Jan 20 16:03:37 2009 From: antocuni at codespeak.net (antocuni at codespeak.net) Date: Tue, 20 Jan 2009 16:03:37 +0100 (CET) Subject: [pypy-svn] r61162 - in pypy/trunk/pypy/module/__builtin__: . test Message-ID: <20090120150337.D9F381684AD@codespeak.net> Author: antocuni Date: Tue Jan 20 16:03:37 2009 New Revision: 61162 Modified: pypy/trunk/pypy/module/__builtin__/importing.py pypy/trunk/pypy/module/__builtin__/test/test_import.py Log: add a new test for imports, and simplify part of the importing logic. Hopefully, this should not be less correct than the previous one :-) Modified: pypy/trunk/pypy/module/__builtin__/importing.py ============================================================================== --- pypy/trunk/pypy/module/__builtin__/importing.py (original) +++ pypy/trunk/pypy/module/__builtin__/importing.py Tue Jan 20 16:03:37 2009 @@ -143,7 +143,6 @@ space.wrap("Empty module name")) w = space.wrap - ctxt_name = None if w_globals is not None and not space.is_w(w_globals, space.w_None): ctxt_w_name = try_getitem(space, w_globals, w('__name__')) @@ -156,7 +155,7 @@ raise else: ctxt_w_path = None - + rel_modulename = None if ctxt_name is not None: if level == 0: @@ -164,22 +163,18 @@ rel_modulename = modulename else: ctxt_name_prefix_parts = ctxt_name.split('.') - if ctxt_w_path is None: # context is a plain module - if level < 0: - ctxt_name_prefix_parts = ctxt_name_prefix_parts[:-1] - else: - cnpp = ctxt_name_prefix_parts - ctxt_name_prefix_parts = [ ctxt_name_prefix_parts[i] - for i in range(len(cnpp)-level) ] - if ctxt_name_prefix_parts: - rel_modulename = '.'.join(ctxt_name_prefix_parts) - if modulename: - rel_modulename += '.' + modulename - else: # context is a package module - rel_modulename = ctxt_name + if level > 0: + n = len(ctxt_name_prefix_parts)-level+1 + assert n>=0 + ctxt_name_prefix_parts = ctxt_name_prefix_parts[:n] + if ctxt_w_path is None: # plain module + ctxt_name_prefix_parts.pop() + if ctxt_name_prefix_parts: + rel_modulename = '.'.join(ctxt_name_prefix_parts) if modulename: rel_modulename += '.' + modulename baselevel = len(ctxt_name_prefix_parts) + if rel_modulename is not None: w_mod = check_sys_modules(space, w(rel_modulename)) if (w_mod is None or Modified: pypy/trunk/pypy/module/__builtin__/test/test_import.py ============================================================================== --- pypy/trunk/pypy/module/__builtin__/test/test_import.py (original) +++ pypy/trunk/pypy/module/__builtin__/test/test_import.py Tue Jan 20 16:03:37 2009 @@ -327,6 +327,15 @@ res = __import__('', mydict, mydict, ('bar',), 1) assert res is foo + def test_relative_import_pkg(self): + import sys + import imp + pkg = imp.new_module('pkg') + sys.modules['pkg'] = pkg + mydict = {'__name__': 'pkg.foo', '__path__': '/some/path'} + res = __import__('', mydict, None, ['bar'], 2) + assert res is pkg + def test_universal_newlines(self): import pkg_univnewlines assert pkg_univnewlines.a == 5 From afa at codespeak.net Tue Jan 20 17:34:27 2009 From: afa at codespeak.net (afa at codespeak.net) Date: Tue, 20 Jan 2009 17:34:27 +0100 (CET) Subject: [pypy-svn] r61166 - pypy/trunk/pypy/module/signal Message-ID: <20090120163427.5BF85168450@codespeak.net> Author: afa Date: Tue Jan 20 17:34:25 2009 New Revision: 61166 Modified: pypy/trunk/pypy/module/signal/__init__.py Log: signal.alarm does not exist on Windows Modified: pypy/trunk/pypy/module/signal/__init__.py ============================================================================== --- pypy/trunk/pypy/module/signal/__init__.py (original) +++ pypy/trunk/pypy/module/signal/__init__.py Tue Jan 20 17:34:25 2009 @@ -1,5 +1,6 @@ from pypy.interpreter.mixedmodule import MixedModule +import os class Module(MixedModule): interpleveldefs = { @@ -8,9 +9,11 @@ 'NSIG': 'space.wrap(interp_signal.NSIG)', 'SIG_DFL': 'space.wrap(interp_signal.SIG_DFL)', 'SIG_IGN': 'space.wrap(interp_signal.SIG_IGN)', - 'alarm': 'interp_signal.alarm', } + if os.name == 'posix': + interpleveldefs['alarm'] = 'interp_signal.alarm' + appleveldefs = { 'default_int_handler': 'app_signal.default_int_handler', } From afa at codespeak.net Tue Jan 20 18:12:29 2009 From: afa at codespeak.net (afa at codespeak.net) Date: Tue, 20 Jan 2009 18:12:29 +0100 (CET) Subject: [pypy-svn] r61167 - pypy/trunk/pypy/translator/platform Message-ID: <20090120171229.F0ED5168458@codespeak.net> Author: afa Date: Tue Jan 20 18:12:26 2009 New Revision: 61167 Modified: pypy/trunk/pypy/translator/platform/windows.py Log: On windows, increase the stack size when compiling in non-optimized mode. 4Mb seems enough for most tests. Modified: pypy/trunk/pypy/translator/platform/windows.py ============================================================================== --- pypy/trunk/pypy/translator/platform/windows.py (original) +++ pypy/trunk/pypy/translator/platform/windows.py Tue Jan 20 18:12:26 2009 @@ -65,6 +65,12 @@ self.cflags = ['/MDd', '/Z7', '/Od'] self.link_flags = ['/debug'] + # Increase stack size, for the linker and the stack check code. + stack_size = 1 << 22 # 4 Mb + self.link_flags.append('/STACK:%d' % stack_size) + # The following symbol is used in c/src/stack.h + self.cflags.append('/DMAX_STACK_SIZE=%d' % (stack_size - 1024)) + self.add_cpython_dirs = True def _preprocess_dirs(self, include_dirs): From fijal at codespeak.net Tue Jan 20 22:07:01 2009 From: fijal at codespeak.net (fijal at codespeak.net) Date: Tue, 20 Jan 2009 22:07:01 +0100 (CET) Subject: [pypy-svn] r61168 - pypy/trunk/lib-python Message-ID: <20090120210701.587A0168464@codespeak.net> Author: fijal Date: Tue Jan 20 22:07:00 2009 New Revision: 61168 Modified: pypy/trunk/lib-python/conftest.py Log: it's not like cpython has profile module Modified: pypy/trunk/lib-python/conftest.py ============================================================================== --- pypy/trunk/lib-python/conftest.py (original) +++ pypy/trunk/lib-python/conftest.py Tue Jan 20 22:07:00 2009 @@ -329,7 +329,7 @@ RegrTest('test_posixpath.py'), RegrTest('test_pow.py', core=True), RegrTest('test_pprint.py', core=True), - RegrTest('test_profile.py'), + RegrTest('test_profile.py', skip="unsupported module, even by cpython"), RegrTest('test_profilehooks.py', core=True), RegrTest('test_pty.py', skip="unsupported extension module"), RegrTest('test_pwd.py'), From fijal at codespeak.net Tue Jan 20 23:57:28 2009 From: fijal at codespeak.net (fijal at codespeak.net) Date: Tue, 20 Jan 2009 23:57:28 +0100 (CET) Subject: [pypy-svn] r61169 - in pypy/trunk/pypy/module/signal: . test Message-ID: <20090120225728.75BF3168068@codespeak.net> Author: fijal Date: Tue Jan 20 23:57:27 2009 New Revision: 61169 Modified: pypy/trunk/pypy/module/signal/interp_signal.py pypy/trunk/pypy/module/signal/test/test_signal.py Log: a test and a fix Modified: pypy/trunk/pypy/module/signal/interp_signal.py ============================================================================== --- pypy/trunk/pypy/module/signal/interp_signal.py (original) +++ pypy/trunk/pypy/module/signal/interp_signal.py Tue Jan 20 23:57:27 2009 @@ -145,6 +145,7 @@ None -- if an unknown handler is in effect (XXX UNIMPLEMENTED) anything else -- the callable Python object used as a handler """ + check_signum(space, signum) action = space.check_signal_action if signum in action.handlers_w: return action.handlers_w[signum] @@ -155,6 +156,11 @@ return space.wrap(c_alarm(timeout)) alarm.unwrap_spec = [ObjSpace, int] +def check_signum(space, signum): + if signum < 1 or signum >= NSIG: + raise OperationError(space.w_ValueError, + space.wrap("signal number out of range")) + def signal(space, signum, w_handler): """ signal(sig, action) -> action Modified: pypy/trunk/pypy/module/signal/test/test_signal.py ============================================================================== --- pypy/trunk/pypy/module/signal/test/test_signal.py (original) +++ pypy/trunk/pypy/module/signal/test/test_signal.py Tue Jan 20 23:57:27 2009 @@ -116,6 +116,9 @@ finally: signal(SIGUSR1, SIG_DFL) + raises(ValueError, getsignal, 4444) + raises(ValueError, signal, 4444, lambda *args: None) + def test_alarm(self): from signal import alarm, signal, SIG_DFL, SIGALRM import time From fijal at codespeak.net Wed Jan 21 00:12:49 2009 From: fijal at codespeak.net (fijal at codespeak.net) Date: Wed, 21 Jan 2009 00:12:49 +0100 (CET) Subject: [pypy-svn] r61171 - in pypy/trunk/pypy/interpreter: astcompiler test Message-ID: <20090120231249.8DA39168456@codespeak.net> Author: fijal Date: Wed Jan 21 00:12:45 2009 New Revision: 61171 Modified: pypy/trunk/pypy/interpreter/astcompiler/consts.py pypy/trunk/pypy/interpreter/astcompiler/pyassem.py pypy/trunk/pypy/interpreter/astcompiler/pycodegen.py pypy/trunk/pypy/interpreter/test/test_code.py Log: *cough*. Make sure that we behave like cpython. This is rather obscure, but I bet *someone* depends on it Modified: pypy/trunk/pypy/interpreter/astcompiler/consts.py ============================================================================== --- pypy/trunk/pypy/interpreter/astcompiler/consts.py (original) +++ pypy/trunk/pypy/interpreter/astcompiler/consts.py Wed Jan 21 00:12:45 2009 @@ -17,6 +17,7 @@ CO_VARKEYWORDS = 0x0008 CO_NESTED = 0x0010 CO_GENERATOR = 0x0020 +CO_NOFREE = 0x0040 CO_GENERATOR_ALLOWED = 0x1000 CO_FUTURE_DIVISION = 0x2000 CO_FUTURE_ABSOLUTE_IMPORT = 0x4000 Modified: pypy/trunk/pypy/interpreter/astcompiler/pyassem.py ============================================================================== --- pypy/trunk/pypy/interpreter/astcompiler/pyassem.py (original) +++ pypy/trunk/pypy/interpreter/astcompiler/pyassem.py Wed Jan 21 00:12:45 2009 @@ -194,7 +194,6 @@ _convert_LOOKUP_METHOD = _convert_NAME def _convert_DEREF(self, arg): - self._lookupName(arg, self.names) return self._lookupClosureName(arg) _convert_LOAD_DEREF = _convert_DEREF _convert_STORE_DEREF = _convert_DEREF Modified: pypy/trunk/pypy/interpreter/astcompiler/pycodegen.py ============================================================================== --- pypy/trunk/pypy/interpreter/astcompiler/pycodegen.py (original) +++ pypy/trunk/pypy/interpreter/astcompiler/pycodegen.py Wed Jan 21 00:12:45 2009 @@ -10,7 +10,8 @@ SC_FREE, SC_CELL, SC_DEFAULT, OP_APPLY, OP_ASSIGN, OP_DELETE, OP_NONE from pypy.interpreter.astcompiler.consts import CO_VARARGS, CO_VARKEYWORDS, \ CO_NEWLOCALS, CO_NESTED, CO_GENERATOR, CO_GENERATOR_ALLOWED, \ - CO_FUTURE_DIVISION, CO_FUTURE_WITH_STATEMENT, CO_FUTURE_ABSOLUTE_IMPORT + CO_FUTURE_DIVISION, CO_FUTURE_WITH_STATEMENT, CO_FUTURE_ABSOLUTE_IMPORT, \ + CO_NOFREE from pypy.interpreter.pyparser.error import SyntaxError from pypy.interpreter.astcompiler.opt import is_constant_false from pypy.interpreter.astcompiler.opt import is_constant_true @@ -1398,6 +1399,8 @@ self.graph.setFlag(CO_VARARGS) if func.kwargs: self.graph.setFlag(CO_VARKEYWORDS) + if not graph.freevars and not graph.cellvars: + self.graph.setFlag(CO_NOFREE) self.set_lineno(func) self.generateArgUnpack(func.argnames) Modified: pypy/trunk/pypy/interpreter/test/test_code.py ============================================================================== --- pypy/trunk/pypy/interpreter/test/test_code.py (original) +++ pypy/trunk/pypy/interpreter/test/test_code.py Wed Jan 21 00:12:45 2009 @@ -167,3 +167,12 @@ 'line'] for i in expected: assert i in res + + def test_code_extra(self): + def f(): + "docstring" + 'stuff' + 56 + + # check for new flag, CO_NOFREE + assert f.func_code.co_flags & 0x40 From fijal at codespeak.net Wed Jan 21 00:38:51 2009 From: fijal at codespeak.net (fijal at codespeak.net) Date: Wed, 21 Jan 2009 00:38:51 +0100 (CET) Subject: [pypy-svn] r61172 - pypy/trunk/pypy/lib Message-ID: <20090120233851.841C4168461@codespeak.net> Author: fijal Date: Wed Jan 21 00:38:49 2009 New Revision: 61172 Modified: pypy/trunk/pypy/lib/pyexpat.py Log: Enough support to pass test_sax, good :) Modified: pypy/trunk/pypy/lib/pyexpat.py ============================================================================== --- pypy/trunk/pypy/lib/pyexpat.py (original) +++ pypy/trunk/pypy/lib/pyexpat.py Wed Jan 21 00:38:49 2009 @@ -75,6 +75,9 @@ c_void_p], None) declare_external('XML_FreeContentModel', [XML_Parser, POINTER(XML_Content)], None) +declare_external('XML_ExternalEntityParserCreate', [XML_Parser,c_char_p, + c_char_p], + XML_Parser) handler_names = [ 'StartElement', @@ -125,17 +128,18 @@ ordered_attributes = 0 returns_unicode = 1 encoding = 'utf-8' - def __init__(self, encoding, namespace_separator): + def __init__(self, encoding, namespace_separator, _hook_external_entity=False): self.returns_unicode = 1 if encoding: self.encoding = encoding - if namespace_separator is None: - self.itself = XML_ParserCreate(encoding) - else: - self.itself = XML_ParserCreateNS(encoding, ord(namespace_separator)) - if not self.itself: - raise RuntimeError("Creating parser failed") - self._set_unknown_encoding_handler() + if not _hook_external_entity: + if namespace_separator is None: + self.itself = XML_ParserCreate(encoding) + else: + self.itself = XML_ParserCreateNS(encoding, ord(namespace_separator)) + if not self.itself: + raise RuntimeError("Creating parser failed") + self._set_unknown_encoding_handler() self.storage = {} self.buffer = None self.buffer_size = 8192 @@ -432,8 +436,18 @@ def SetBase(self, base): XML_SetBase(self.itself, base) + def ExternalEntityParserCreate(self, context, encoding=None): + """ExternalEntityParserCreate(context[, encoding]) + Create a parser for parsing an external entity based on the + information passed to the ExternalEntityRefHandler.""" + new_parser = XMLParserType(encoding, None, True) + new_parser.itself = XML_ExternalEntityParserCreate(self.itself, + context, encoding) + new_parser._set_unknown_encoding_handler() + return new_parser + def ErrorString(errno): - xxx + return XML_ErrorString(errno)[:200] def ParserCreate(encoding=None, namespace_separator=None, intern=None): if (not isinstance(encoding, str) and From fijal at codespeak.net Wed Jan 21 00:40:58 2009 From: fijal at codespeak.net (fijal at codespeak.net) Date: Wed, 21 Jan 2009 00:40:58 +0100 (CET) Subject: [pypy-svn] r61173 - pypy/trunk/lib-python Message-ID: <20090120234058.9C4D1168461@codespeak.net> Author: fijal Date: Wed Jan 21 00:40:58 2009 New Revision: 61173 Modified: pypy/trunk/lib-python/failure_list.txt Log: those are fixed/skipped Modified: pypy/trunk/lib-python/failure_list.txt ============================================================================== --- pypy/trunk/lib-python/failure_list.txt (original) +++ pypy/trunk/lib-python/failure_list.txt Wed Jan 21 00:40:58 2009 @@ -2,9 +2,7 @@ ------------------------------------------------------------------------------------------- test_builtin this is our issue383 test_cProfile ! we still need to fix module/cProfile to respect builtin calls -test_capi CPython only test_code obscure differences in code objects produced by compiler -test_codeccallbacks ! unknown test_codecs ! unknown test_coding ! hah. fix buildbot :-/ test_commands ! unknown @@ -48,7 +46,6 @@ test_quopri ! check if test_script{en,de}code() shows a real bug test_random should probably be fixed, but no hurry i guess test_repr implementation detail -test_sax ! unknown test_sets ! is this another CPython implementation detail test? test_shelve ! unknown test_signal ! missing signal.alarm(), probably easy to add From fijal at codespeak.net Wed Jan 21 00:49:32 2009 From: fijal at codespeak.net (fijal at codespeak.net) Date: Wed, 21 Jan 2009 00:49:32 +0100 (CET) Subject: [pypy-svn] r61174 - pypy/trunk/pypy/lib Message-ID: <20090120234932.599C3168440@codespeak.net> Author: fijal Date: Wed Jan 21 00:49:31 2009 New Revision: 61174 Modified: pypy/trunk/pypy/lib/dbm.py Log: missing delitem for dbm Modified: pypy/trunk/pypy/lib/dbm.py ============================================================================== --- pypy/trunk/pypy/lib/dbm.py (original) +++ pypy/trunk/pypy/lib/dbm.py Wed Jan 21 00:49:31 2009 @@ -124,6 +124,14 @@ raise error("dbm mappings have string indices only") self._set(key, value) + def __delitem__(self, key): + if not isinstance(key, str): + raise error("dbm mappings have string indices only") + dat = datum() + dat.dptr = c_char_p(key) + dat.dsize = c_int(len(key)) + getattr(lib, funcs['delete'])(self._aobj, dat) + # initialization for Berkeley DB _bdb_funcs = { 'open': '__db_ndbm_open', From fijal at codespeak.net Wed Jan 21 01:03:08 2009 From: fijal at codespeak.net (fijal at codespeak.net) Date: Wed, 21 Jan 2009 01:03:08 +0100 (CET) Subject: [pypy-svn] r61175 - pypy/trunk/lib-python/modified-2.5.2/test Message-ID: <20090121000308.85F0D168441@codespeak.net> Author: fijal Date: Wed Jan 21 01:03:07 2009 New Revision: 61175 Modified: pypy/trunk/lib-python/modified-2.5.2/test/test_sort.py Log: I think it's ok to call it an impl detail Modified: pypy/trunk/lib-python/modified-2.5.2/test/test_sort.py ============================================================================== --- pypy/trunk/lib-python/modified-2.5.2/test/test_sort.py (original) +++ pypy/trunk/lib-python/modified-2.5.2/test/test_sort.py Wed Jan 21 01:03:07 2009 @@ -228,6 +228,7 @@ return x self.assertRaises(ValueError, data.sort, key=k) + @test_support.impl_detail("__del__ not called") def test_key_with_mutating_del(self): data = range(10) class SortKiller(object): From fijal at codespeak.net Wed Jan 21 01:06:17 2009 From: fijal at codespeak.net (fijal at codespeak.net) Date: Wed, 21 Jan 2009 01:06:17 +0100 (CET) Subject: [pypy-svn] r61176 - pypy/trunk/pypy/lib Message-ID: <20090121000617.C944A168441@codespeak.net> Author: fijal Date: Wed Jan 21 01:06:17 2009 New Revision: 61176 Added: pypy/trunk/pypy/lib/sqlite3 (contents, props changed) Log: Add a link sqlite3 to pysqlite2 Added: pypy/trunk/pypy/lib/sqlite3 ============================================================================== --- (empty file) +++ pypy/trunk/pypy/lib/sqlite3 Wed Jan 21 01:06:17 2009 @@ -0,0 +1 @@ +link pysqlite2/ \ No newline at end of file From fijal at codespeak.net Wed Jan 21 01:06:39 2009 From: fijal at codespeak.net (fijal at codespeak.net) Date: Wed, 21 Jan 2009 01:06:39 +0100 (CET) Subject: [pypy-svn] r61177 - pypy/trunk/lib-python/modified-2.5.2/test Message-ID: <20090121000639.3E8BE168441@codespeak.net> Author: fijal Date: Wed Jan 21 01:06:38 2009 New Revision: 61177 Added: pypy/trunk/lib-python/modified-2.5.2/test/test_sqlite.py - copied, changed from r61167, pypy/trunk/lib-python/2.5.2/test/test_sqlite.py Log: don't try to import C module first. There are failures though :( Copied: pypy/trunk/lib-python/modified-2.5.2/test/test_sqlite.py (from r61167, pypy/trunk/lib-python/2.5.2/test/test_sqlite.py) ============================================================================== --- pypy/trunk/lib-python/2.5.2/test/test_sqlite.py (original) +++ pypy/trunk/lib-python/modified-2.5.2/test/test_sqlite.py Wed Jan 21 01:06:38 2009 @@ -2,7 +2,7 @@ import unittest try: - import _sqlite3 + import sqlite3 except ImportError: raise TestSkipped('no sqlite available') from sqlite3.test import (dbapi, types, userfunctions, From afa at codespeak.net Wed Jan 21 02:15:01 2009 From: afa at codespeak.net (afa at codespeak.net) Date: Wed, 21 Jan 2009 02:15:01 +0100 (CET) Subject: [pypy-svn] r61178 - pypy/trunk/pypy/translator/platform Message-ID: <20090121011501.17EFA16844F@codespeak.net> Author: afa Date: Wed Jan 21 02:14:57 2009 New Revision: 61178 Modified: pypy/trunk/pypy/translator/platform/windows.py Log: Embed manifest in generated executables when using a Microsoft compiler that supports it. This should correct the case when CPython uses ctypes to load a library built with a different compiler. Modified: pypy/trunk/pypy/translator/platform/windows.py ============================================================================== --- pypy/trunk/pypy/translator/platform/windows.py (original) +++ pypy/trunk/pypy/translator/platform/windows.py Wed Jan 21 02:14:57 2009 @@ -1,5 +1,5 @@ -import py, os, sys +import py, os, sys, re from pypy.translator.platform import CompilationError, ExecutionResult from pypy.translator.platform import log, _run_subprocess from pypy.translator.platform import Platform, posix @@ -60,6 +60,11 @@ def __init__(self, cc=None): self.cc = 'cl.exe' + # detect version of current compiler + returncode, stdout, stderr = _run_subprocess(self.cc, []) + r = re.search('Version ([0-9]+)\.([0-9]+)', stderr) + self.version = int(''.join(r.groups())) / 10 - 60 + # Install debug options only when interpreter is in debug mode if sys.executable.lower().endswith('_d.exe'): self.cflags = ['/MDd', '/Z7', '/Od'] @@ -110,7 +115,27 @@ args += ['/out:%s' % (exe_name,), '/incremental:no'] if not standalone: args = self._args_for_shared(args) + + if self.version >= 80: + # Tell the linker to generate a manifest file + temp_manifest = ofile.dirpath().join( + ofile.purebasename + '.manifest') + args += ["/MANIFESTFILE:%s" % (temp_manifest,)] + self._execute_c_compiler(self.link, args, exe_name) + + if self.version >= 80: + # Now, embed the manifest into the program + if standalone: + mfid = 1 + else: + mfid = 2 + out_arg = '-outputresource:%s;%s' % (exe_name, mfid) + args = ['-nologo', '-manifest', str(temp_manifest), out_arg] + log.execute('mt.exe ' + ' '.join(args)) + returncode, stdout, stderr = _run_subprocess('mt.exe', args) + self._handle_error(returncode, stderr, stdout, exe_name) + return exe_name def _handle_error(self, returncode, stderr, stdout, outname): From fijal at codespeak.net Wed Jan 21 03:15:57 2009 From: fijal at codespeak.net (fijal at codespeak.net) Date: Wed, 21 Jan 2009 03:15:57 +0100 (CET) Subject: [pypy-svn] r61179 - pypy/trunk/lib-python Message-ID: <20090121021557.F2F0E168461@codespeak.net> Author: fijal Date: Wed Jan 21 03:15:55 2009 New Revision: 61179 Modified: pypy/trunk/lib-python/conftest.py Log: skip this file on windows (for now), since it timeouts and we don't have a proper support for timeouts on windows Modified: pypy/trunk/lib-python/conftest.py ============================================================================== --- pypy/trunk/lib-python/conftest.py (original) +++ pypy/trunk/lib-python/conftest.py Wed Jan 21 03:15:55 2009 @@ -382,7 +382,7 @@ RegrTest('test_struct.py', usemodules='struct'), RegrTest('test_structmembers.py', skip="CPython specific"), RegrTest('test_structseq.py'), - RegrTest('test_subprocess.py', usemodules='signal'), + RegrTest('test_subprocess.py', usemodules='signal', skip=(sys.platform=='win32')), RegrTest('test_sunaudiodev.py', skip=True), RegrTest('test_sundry.py'), RegrTest('test_symtable.py', skip="implementation detail"), From fijal at codespeak.net Wed Jan 21 12:18:36 2009 From: fijal at codespeak.net (fijal at codespeak.net) Date: Wed, 21 Jan 2009 12:18:36 +0100 (CET) Subject: [pypy-svn] r61181 - in pypy/trunk/pypy/interpreter: astcompiler test Message-ID: <20090121111836.3FC5E168441@codespeak.net> Author: fijal Date: Wed Jan 21 12:18:34 2009 New Revision: 61181 Modified: pypy/trunk/pypy/interpreter/astcompiler/pycodegen.py pypy/trunk/pypy/interpreter/test/test_code.py Log: A test and a fix for yet another flag in code object Modified: pypy/trunk/pypy/interpreter/astcompiler/pycodegen.py ============================================================================== --- pypy/trunk/pypy/interpreter/astcompiler/pycodegen.py (original) +++ pypy/trunk/pypy/interpreter/astcompiler/pycodegen.py Wed Jan 21 12:18:34 2009 @@ -1447,6 +1447,9 @@ node = self.scope.return_with_arg raise SyntaxError("'return' with argument inside generator", node.lineno) + if (self.scope.parent and + isinstance(self.scope.parent, symbols.FunctionScope)): + self.graph.setFlag(CO_NESTED) class GenExprCodeGenerator(AbstractFunctionCode): Modified: pypy/trunk/pypy/interpreter/test/test_code.py ============================================================================== --- pypy/trunk/pypy/interpreter/test/test_code.py (original) +++ pypy/trunk/pypy/interpreter/test/test_code.py Wed Jan 21 12:18:34 2009 @@ -169,10 +169,23 @@ assert i in res def test_code_extra(self): + exec """if 1: def f(): "docstring" 'stuff' 56 + """ in locals() # check for new flag, CO_NOFREE assert f.func_code.co_flags & 0x40 + + exec """if 1: + def f(x): + def g(y): + return x+y + return g + """ in locals() + + # CO_NESTED + assert f(4).func_code.co_flags & 0x10 + assert f.func_code.co_flags & 0x10 == 0 From fijal at codespeak.net Wed Jan 21 12:49:49 2009 From: fijal at codespeak.net (fijal at codespeak.net) Date: Wed, 21 Jan 2009 12:49:49 +0100 (CET) Subject: [pypy-svn] r61182 - pypy/trunk/lib-python Message-ID: <20090121114949.49C4816843E@codespeak.net> Author: fijal Date: Wed Jan 21 12:49:47 2009 New Revision: 61182 Modified: pypy/trunk/lib-python/conftest.py pypy/trunk/lib-python/failure_list.txt Log: update info on failure list Modified: pypy/trunk/lib-python/conftest.py ============================================================================== --- pypy/trunk/lib-python/conftest.py (original) +++ pypy/trunk/lib-python/conftest.py Wed Jan 21 12:49:47 2009 @@ -293,8 +293,7 @@ RegrTest('test_minidom.py'), RegrTest('test_mmap.py'), RegrTest('test_module.py', core=True), - RegrTest('test_multibytecodec.py'), - RegrTest('test_multibytecodec_support.py', core=True), + RegrTest('test_multibytecodec.py', skip="unsupported codecs"), RegrTest('test_multifile.py'), RegrTest('test_mutants.py', core="possibly"), RegrTest('test_netrc.py'), @@ -478,8 +477,8 @@ RegrTest('test_with.py'), RegrTest('test_wsgiref.py'), RegrTest('test_xdrlib.py'), - RegrTest('test_xml_etree.py'), - RegrTest('test_xml_etree_c.py'), + RegrTest('test_xml_etree.py', skip="unsupported ext module"), + RegrTest('test_xml_etree_c.py', skip="unsupported ext module"), RegrTest('test_zipfile64.py'), ] Modified: pypy/trunk/lib-python/failure_list.txt ============================================================================== --- pypy/trunk/lib-python/failure_list.txt (original) +++ pypy/trunk/lib-python/failure_list.txt Wed Jan 21 12:49:47 2009 @@ -28,10 +28,7 @@ test_inspect ! test_wrapped_decorator: try to fix; isbuiltin([].append): cry and maaaybe try to fix test_iterlen somehow implementation detail (missing __length_hint__()) test_itertools same as test_iterlen -test_logging ! shallow. let's just fix the __repr__ of types -test_multibytecodec ! unknown -test_mutants the test is probably too precise in the failure it expects -test_new new.instancemethod(x, None) should fail, but no hurry +test_logging ! exception classes have different repr than the rest in cpython test_normalization test skipped test_optparse ! test needs some fixes, but still, some failures are strange # SHOULD BE FIXED N?OW test_parser missing parser.compilest(). I don't think we care for now @@ -46,12 +43,10 @@ test_quopri ! check if test_script{en,de}code() shows a real bug test_random should probably be fixed, but no hurry i guess test_repr implementation detail -test_sets ! is this another CPython implementation detail test? test_shelve ! unknown test_signal ! missing signal.alarm(), probably easy to add test_site ! fix me test_socketserver test skipped -test_sort implementation detail test_sqlite ! why no sqlite available? test_structmembers CPython-only test_subprocess ! missing resource.error. no clue about os.fpathconf(). @@ -73,7 +68,6 @@ test_wait4 no os.wait4() test_weakref probably missing some gc.collect() test_with minor hacking in the ast compiler -test_xml_etree_c import _elementtree test_xmlrpc sys.setdefaultencoding missing test_zipfile64 skipped test From arigo at codespeak.net Wed Jan 21 14:03:48 2009 From: arigo at codespeak.net (arigo at codespeak.net) Date: Wed, 21 Jan 2009 14:03:48 +0100 (CET) Subject: [pypy-svn] r61183 - in pypy/trunk/pypy/objspace/std: . test Message-ID: <20090121130348.31C8F16843D@codespeak.net> Author: arigo Date: Wed Jan 21 14:03:46 2009 New Revision: 61183 Modified: pypy/trunk/pypy/objspace/std/test/test_typeobject.py pypy/trunk/pypy/objspace/std/typeobject.py Log: Fix the repr of exceptions to say "type" instead of "class". Modified: pypy/trunk/pypy/objspace/std/test/test_typeobject.py ============================================================================== --- pypy/trunk/pypy/objspace/std/test/test_typeobject.py (original) +++ pypy/trunk/pypy/objspace/std/test/test_typeobject.py Wed Jan 21 14:03:46 2009 @@ -704,6 +704,7 @@ assert repr(type(type)) == "" assert repr(complex) == "" assert repr(property) == "" + assert repr(TypeError) == "" def test_invalid_mro(self): class A(object): Modified: pypy/trunk/pypy/objspace/std/typeobject.py ============================================================================== --- pypy/trunk/pypy/objspace/std/typeobject.py (original) +++ pypy/trunk/pypy/objspace/std/typeobject.py Wed Jan 21 14:03:46 2009 @@ -592,7 +592,8 @@ mod = None else: mod = space.str_w(w_mod) - if not w_obj.is_heaptype() or (mod is not None and mod == '__builtin__'): + if (not w_obj.is_heaptype() or + (mod == '__builtin__' or mod == 'exceptions')): kind = 'type' else: kind = 'class' From antocuni at codespeak.net Wed Jan 21 14:44:08 2009 From: antocuni at codespeak.net (antocuni at codespeak.net) Date: Wed, 21 Jan 2009 14:44:08 +0100 (CET) Subject: [pypy-svn] r61185 - in pypy/trunk/lib-python: . modified-2.5.2/test Message-ID: <20090121134408.A7440168438@codespeak.net> Author: antocuni Date: Wed Jan 21 14:44:08 2009 New Revision: 61185 Added: pypy/trunk/lib-python/modified-2.5.2/test/test_importhooks.py - copied, changed from r61183, pypy/trunk/lib-python/2.5.2/test/test_importhooks.py Modified: pypy/trunk/lib-python/failure_list.txt Log: try hard not to remove 'exceptions' from sys.modules Modified: pypy/trunk/lib-python/failure_list.txt ============================================================================== --- pypy/trunk/lib-python/failure_list.txt (original) +++ pypy/trunk/lib-python/failure_list.txt Wed Jan 21 14:44:08 2009 @@ -5,7 +5,6 @@ test_code obscure differences in code objects produced by compiler test_codecs ! unknown test_coding ! hah. fix buildbot :-/ -test_commands ! unknown test_compiler ! unknown test_ctypes ! implementation details but also some real crashes test_decimal missing decimal.ROUND_05UP @@ -24,7 +23,6 @@ test_gettext ! check this use of unicode() test_grammar implementation detail test_import importing from pyc-files-without-py-file disabled by default -test_importhooks ! unknown # SHOULD BE FIXED NOW, check nightly tests test_inspect ! test_wrapped_decorator: try to fix; isbuiltin([].append): cry and maaaybe try to fix test_iterlen somehow implementation detail (missing __length_hint__()) test_itertools same as test_iterlen Copied: pypy/trunk/lib-python/modified-2.5.2/test/test_importhooks.py (from r61183, pypy/trunk/lib-python/2.5.2/test/test_importhooks.py) ============================================================================== --- pypy/trunk/lib-python/2.5.2/test/test_importhooks.py (original) +++ pypy/trunk/lib-python/modified-2.5.2/test/test_importhooks.py Wed Jan 21 14:44:08 2009 @@ -238,15 +238,26 @@ def testBlocker(self): mname = "exceptions" # an arbitrary harmless builtin module + mod = None if mname in sys.modules: + mod = sys.modules[mname] del sys.modules[mname] - sys.meta_path.append(ImportBlocker(mname)) + blocker = ImportBlocker(mname) + sys.meta_path.append(blocker) try: __import__(mname) except ImportError: pass else: self.fail("'%s' was not supposed to be importable" % mname) + finally: + # try hard to re-insert exceptions into sys.modules, else pypy-c + # complains before exiting + assert sys.meta_path[-1] is blocker + sys.meta_path.pop() + self.tracker.imports.remove(mname) + if mod: + sys.modules[mname] = mod def testImpWrapper(self): i = ImpWrapper() From antocuni at codespeak.net Wed Jan 21 14:44:50 2009 From: antocuni at codespeak.net (antocuni at codespeak.net) Date: Wed, 21 Jan 2009 14:44:50 +0100 (CET) Subject: [pypy-svn] r61186 - pypy/trunk/lib-python Message-ID: <20090121134450.6CA1F168438@codespeak.net> Author: antocuni Date: Wed Jan 21 14:44:49 2009 New Revision: 61186 Modified: pypy/trunk/lib-python/failure_list.txt Log: this tests passes now Modified: pypy/trunk/lib-python/failure_list.txt ============================================================================== --- pypy/trunk/lib-python/failure_list.txt (original) +++ pypy/trunk/lib-python/failure_list.txt Wed Jan 21 14:44:49 2009 @@ -28,7 +28,6 @@ test_itertools same as test_iterlen test_logging ! exception classes have different repr than the rest in cpython test_normalization test skipped -test_optparse ! test needs some fixes, but still, some failures are strange # SHOULD BE FIXED N?OW test_parser missing parser.compilest(). I don't think we care for now test_peepholer implementation detail (might be useful to look, though) test_pep277 NT only From arigo at codespeak.net Wed Jan 21 14:49:19 2009 From: arigo at codespeak.net (arigo at codespeak.net) Date: Wed, 21 Jan 2009 14:49:19 +0100 (CET) Subject: [pypy-svn] r61187 - pypy/trunk/lib-python/2.5.2 Message-ID: <20090121134919.19AD7168446@codespeak.net> Author: arigo Date: Wed Jan 21 14:49:18 2009 New Revision: 61187 Added: pypy/trunk/lib-python/2.5.2/profile.py (contents, props changed) pypy/trunk/lib-python/2.5.2/pstats.py (contents, props changed) Log: Add the two missing modules from Python 2.5.2. I guess that the original import was done from a Debian installation, in which these two modules are removed. Added: pypy/trunk/lib-python/2.5.2/profile.py ============================================================================== --- (empty file) +++ pypy/trunk/lib-python/2.5.2/profile.py Wed Jan 21 14:49:18 2009 @@ -0,0 +1,619 @@ +#! /usr/bin/env python +# +# Class for profiling python code. rev 1.0 6/2/94 +# +# Based on prior profile module by Sjoerd Mullender... +# which was hacked somewhat by: Guido van Rossum + +"""Class for profiling Python code.""" + +# Copyright 1994, by InfoSeek Corporation, all rights reserved. +# Written by James Roskind +# +# Permission to use, copy, modify, and distribute this Python software +# and its associated documentation for any purpose (subject to the +# restriction in the following sentence) without fee is hereby granted, +# provided that the above copyright notice appears in all copies, and +# that both that copyright notice and this permission notice appear in +# supporting documentation, and that the name of InfoSeek not be used in +# advertising or publicity pertaining to distribution of the software +# without specific, written prior permission. This permission is +# explicitly restricted to the copying and modification of the software +# to remain in Python, compiled Python, or other languages (such as C) +# wherein the modified or derived code is exclusively imported into a +# Python module. +# +# INFOSEEK CORPORATION DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS +# SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND +# FITNESS. IN NO EVENT SHALL INFOSEEK CORPORATION BE LIABLE FOR ANY +# SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER +# RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF +# CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN +# CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + + + +import sys +import os +import time +import marshal +from optparse import OptionParser + +__all__ = ["run", "runctx", "help", "Profile"] + +# Sample timer for use with +#i_count = 0 +#def integer_timer(): +# global i_count +# i_count = i_count + 1 +# return i_count +#itimes = integer_timer # replace with C coded timer returning integers + +#************************************************************************** +# The following are the static member functions for the profiler class +# Note that an instance of Profile() is *not* needed to call them. +#************************************************************************** + +def run(statement, filename=None, sort=-1): + """Run statement under profiler optionally saving results in filename + + This function takes a single argument that can be passed to the + "exec" statement, and an optional file name. In all cases this + routine attempts to "exec" its first argument and gather profiling + statistics from the execution. If no file name is present, then this + function automatically prints a simple profiling report, sorted by the + standard name string (file/line/function-name) that is presented in + each line. + """ + prof = Profile() + try: + prof = prof.run(statement) + except SystemExit: + pass + if filename is not None: + prof.dump_stats(filename) + else: + return prof.print_stats(sort) + +def runctx(statement, globals, locals, filename=None): + """Run statement under profiler, supplying your own globals and locals, + optionally saving results in filename. + + statement and filename have the same semantics as profile.run + """ + prof = Profile() + try: + prof = prof.runctx(statement, globals, locals) + except SystemExit: + pass + + if filename is not None: + prof.dump_stats(filename) + else: + return prof.print_stats() + +# Backwards compatibility. +def help(): + print "Documentation for the profile module can be found " + print "in the Python Library Reference, section 'The Python Profiler'." + +if os.name == "mac": + import MacOS + def _get_time_mac(timer=MacOS.GetTicks): + return timer() / 60.0 + +if hasattr(os, "times"): + def _get_time_times(timer=os.times): + t = timer() + return t[0] + t[1] + +# Using getrusage(3) is better than clock(3) if available: +# on some systems (e.g. FreeBSD), getrusage has a higher resolution +# Furthermore, on a POSIX system, returns microseconds, which +# wrap around after 36min. +_has_res = 0 +try: + import resource + resgetrusage = lambda: resource.getrusage(resource.RUSAGE_SELF) + def _get_time_resource(timer=resgetrusage): + t = timer() + return t[0] + t[1] + _has_res = 1 +except ImportError: + pass + +class Profile: + """Profiler class. + + self.cur is always a tuple. Each such tuple corresponds to a stack + frame that is currently active (self.cur[-2]). The following are the + definitions of its members. We use this external "parallel stack" to + avoid contaminating the program that we are profiling. (old profiler + used to write into the frames local dictionary!!) Derived classes + can change the definition of some entries, as long as they leave + [-2:] intact (frame and previous tuple). In case an internal error is + detected, the -3 element is used as the function name. + + [ 0] = Time that needs to be charged to the parent frame's function. + It is used so that a function call will not have to access the + timing data for the parent frame. + [ 1] = Total time spent in this frame's function, excluding time in + subfunctions (this latter is tallied in cur[2]). + [ 2] = Total time spent in subfunctions, excluding time executing the + frame's function (this latter is tallied in cur[1]). + [-3] = Name of the function that corresponds to this frame. + [-2] = Actual frame that we correspond to (used to sync exception handling). + [-1] = Our parent 6-tuple (corresponds to frame.f_back). + + Timing data for each function is stored as a 5-tuple in the dictionary + self.timings[]. The index is always the name stored in self.cur[-3]. + The following are the definitions of the members: + + [0] = The number of times this function was called, not counting direct + or indirect recursion, + [1] = Number of times this function appears on the stack, minus one + [2] = Total time spent internal to this function + [3] = Cumulative time that this function was present on the stack. In + non-recursive functions, this is the total execution time from start + to finish of each invocation of a function, including time spent in + all subfunctions. + [4] = A dictionary indicating for each function name, the number of times + it was called by us. + """ + + bias = 0 # calibration constant + + def __init__(self, timer=None, bias=None): + self.timings = {} + self.cur = None + self.cmd = "" + self.c_func_name = "" + + if bias is None: + bias = self.bias + self.bias = bias # Materialize in local dict for lookup speed. + + if not timer: + if _has_res: + self.timer = resgetrusage + self.dispatcher = self.trace_dispatch + self.get_time = _get_time_resource + elif os.name == 'mac': + self.timer = MacOS.GetTicks + self.dispatcher = self.trace_dispatch_mac + self.get_time = _get_time_mac + elif hasattr(time, 'clock'): + self.timer = self.get_time = time.clock + self.dispatcher = self.trace_dispatch_i + elif hasattr(os, 'times'): + self.timer = os.times + self.dispatcher = self.trace_dispatch + self.get_time = _get_time_times + else: + self.timer = self.get_time = time.time + self.dispatcher = self.trace_dispatch_i + else: + self.timer = timer + t = self.timer() # test out timer function + try: + length = len(t) + except TypeError: + self.get_time = timer + self.dispatcher = self.trace_dispatch_i + else: + if length == 2: + self.dispatcher = self.trace_dispatch + else: + self.dispatcher = self.trace_dispatch_l + # This get_time() implementation needs to be defined + # here to capture the passed-in timer in the parameter + # list (for performance). Note that we can't assume + # the timer() result contains two values in all + # cases. + def get_time_timer(timer=timer, sum=sum): + return sum(timer()) + self.get_time = get_time_timer + self.t = self.get_time() + self.simulate_call('profiler') + + # Heavily optimized dispatch routine for os.times() timer + + def trace_dispatch(self, frame, event, arg): + timer = self.timer + t = timer() + t = t[0] + t[1] - self.t - self.bias + + if event == "c_call": + self.c_func_name = arg.__name__ + + if self.dispatch[event](self, frame,t): + t = timer() + self.t = t[0] + t[1] + else: + r = timer() + self.t = r[0] + r[1] - t # put back unrecorded delta + + # Dispatch routine for best timer program (return = scalar, fastest if + # an integer but float works too -- and time.clock() relies on that). + + def trace_dispatch_i(self, frame, event, arg): + timer = self.timer + t = timer() - self.t - self.bias + + if event == "c_call": + self.c_func_name = arg.__name__ + + if self.dispatch[event](self, frame, t): + self.t = timer() + else: + self.t = timer() - t # put back unrecorded delta + + # Dispatch routine for macintosh (timer returns time in ticks of + # 1/60th second) + + def trace_dispatch_mac(self, frame, event, arg): + timer = self.timer + t = timer()/60.0 - self.t - self.bias + + if event == "c_call": + self.c_func_name = arg.__name__ + + if self.dispatch[event](self, frame, t): + self.t = timer()/60.0 + else: + self.t = timer()/60.0 - t # put back unrecorded delta + + # SLOW generic dispatch routine for timer returning lists of numbers + + def trace_dispatch_l(self, frame, event, arg): + get_time = self.get_time + t = get_time() - self.t - self.bias + + if event == "c_call": + self.c_func_name = arg.__name__ + + if self.dispatch[event](self, frame, t): + self.t = get_time() + else: + self.t = get_time() - t # put back unrecorded delta + + # In the event handlers, the first 3 elements of self.cur are unpacked + # into vrbls w/ 3-letter names. The last two characters are meant to be + # mnemonic: + # _pt self.cur[0] "parent time" time to be charged to parent frame + # _it self.cur[1] "internal time" time spent directly in the function + # _et self.cur[2] "external time" time spent in subfunctions + + def trace_dispatch_exception(self, frame, t): + rpt, rit, ret, rfn, rframe, rcur = self.cur + if (rframe is not frame) and rcur: + return self.trace_dispatch_return(rframe, t) + self.cur = rpt, rit+t, ret, rfn, rframe, rcur + return 1 + + + def trace_dispatch_call(self, frame, t): + if self.cur and frame.f_back is not self.cur[-2]: + rpt, rit, ret, rfn, rframe, rcur = self.cur + if not isinstance(rframe, Profile.fake_frame): + assert rframe.f_back is frame.f_back, ("Bad call", rfn, + rframe, rframe.f_back, + frame, frame.f_back) + self.trace_dispatch_return(rframe, 0) + assert (self.cur is None or \ + frame.f_back is self.cur[-2]), ("Bad call", + self.cur[-3]) + fcode = frame.f_code + fn = (fcode.co_filename, fcode.co_firstlineno, fcode.co_name) + self.cur = (t, 0, 0, fn, frame, self.cur) + timings = self.timings + if fn in timings: + cc, ns, tt, ct, callers = timings[fn] + timings[fn] = cc, ns + 1, tt, ct, callers + else: + timings[fn] = 0, 0, 0, 0, {} + return 1 + + def trace_dispatch_c_call (self, frame, t): + fn = ("", 0, self.c_func_name) + self.cur = (t, 0, 0, fn, frame, self.cur) + timings = self.timings + if timings.has_key(fn): + cc, ns, tt, ct, callers = timings[fn] + timings[fn] = cc, ns+1, tt, ct, callers + else: + timings[fn] = 0, 0, 0, 0, {} + return 1 + + def trace_dispatch_return(self, frame, t): + if frame is not self.cur[-2]: + assert frame is self.cur[-2].f_back, ("Bad return", self.cur[-3]) + self.trace_dispatch_return(self.cur[-2], 0) + + # Prefix "r" means part of the Returning or exiting frame. + # Prefix "p" means part of the Previous or Parent or older frame. + + rpt, rit, ret, rfn, frame, rcur = self.cur + rit = rit + t + frame_total = rit + ret + + ppt, pit, pet, pfn, pframe, pcur = rcur + self.cur = ppt, pit + rpt, pet + frame_total, pfn, pframe, pcur + + timings = self.timings + cc, ns, tt, ct, callers = timings[rfn] + if not ns: + # This is the only occurrence of the function on the stack. + # Else this is a (directly or indirectly) recursive call, and + # its cumulative time will get updated when the topmost call to + # it returns. + ct = ct + frame_total + cc = cc + 1 + + if pfn in callers: + callers[pfn] = callers[pfn] + 1 # hack: gather more + # stats such as the amount of time added to ct courtesy + # of this specific call, and the contribution to cc + # courtesy of this call. + else: + callers[pfn] = 1 + + timings[rfn] = cc, ns - 1, tt + rit, ct, callers + + return 1 + + + dispatch = { + "call": trace_dispatch_call, + "exception": trace_dispatch_exception, + "return": trace_dispatch_return, + "c_call": trace_dispatch_c_call, + "c_exception": trace_dispatch_return, # the C function returned + "c_return": trace_dispatch_return, + } + + + # The next few functions play with self.cmd. By carefully preloading + # our parallel stack, we can force the profiled result to include + # an arbitrary string as the name of the calling function. + # We use self.cmd as that string, and the resulting stats look + # very nice :-). + + def set_cmd(self, cmd): + if self.cur[-1]: return # already set + self.cmd = cmd + self.simulate_call(cmd) + + class fake_code: + def __init__(self, filename, line, name): + self.co_filename = filename + self.co_line = line + self.co_name = name + self.co_firstlineno = 0 + + def __repr__(self): + return repr((self.co_filename, self.co_line, self.co_name)) + + class fake_frame: + def __init__(self, code, prior): + self.f_code = code + self.f_back = prior + + def simulate_call(self, name): + code = self.fake_code('profile', 0, name) + if self.cur: + pframe = self.cur[-2] + else: + pframe = None + frame = self.fake_frame(code, pframe) + self.dispatch['call'](self, frame, 0) + + # collect stats from pending stack, including getting final + # timings for self.cmd frame. + + def simulate_cmd_complete(self): + get_time = self.get_time + t = get_time() - self.t + while self.cur[-1]: + # We *can* cause assertion errors here if + # dispatch_trace_return checks for a frame match! + self.dispatch['return'](self, self.cur[-2], t) + t = 0 + self.t = get_time() - t + + + def print_stats(self, sort=-1): + import pstats + pstats.Stats(self).strip_dirs().sort_stats(sort). \ + print_stats() + + def dump_stats(self, file): + f = open(file, 'wb') + self.create_stats() + marshal.dump(self.stats, f) + f.close() + + def create_stats(self): + self.simulate_cmd_complete() + self.snapshot_stats() + + def snapshot_stats(self): + self.stats = {} + for func, (cc, ns, tt, ct, callers) in self.timings.iteritems(): + callers = callers.copy() + nc = 0 + for callcnt in callers.itervalues(): + nc += callcnt + self.stats[func] = cc, nc, tt, ct, callers + + + # The following two methods can be called by clients to use + # a profiler to profile a statement, given as a string. + + def run(self, cmd): + import __main__ + dict = __main__.__dict__ + return self.runctx(cmd, dict, dict) + + def runctx(self, cmd, globals, locals): + self.set_cmd(cmd) + sys.setprofile(self.dispatcher) + try: + exec cmd in globals, locals + finally: + sys.setprofile(None) + return self + + # This method is more useful to profile a single function call. + def runcall(self, func, *args, **kw): + self.set_cmd(repr(func)) + sys.setprofile(self.dispatcher) + try: + return func(*args, **kw) + finally: + sys.setprofile(None) + + + #****************************************************************** + # The following calculates the overhead for using a profiler. The + # problem is that it takes a fair amount of time for the profiler + # to stop the stopwatch (from the time it receives an event). + # Similarly, there is a delay from the time that the profiler + # re-starts the stopwatch before the user's code really gets to + # continue. The following code tries to measure the difference on + # a per-event basis. + # + # Note that this difference is only significant if there are a lot of + # events, and relatively little user code per event. For example, + # code with small functions will typically benefit from having the + # profiler calibrated for the current platform. This *could* be + # done on the fly during init() time, but it is not worth the + # effort. Also note that if too large a value specified, then + # execution time on some functions will actually appear as a + # negative number. It is *normal* for some functions (with very + # low call counts) to have such negative stats, even if the + # calibration figure is "correct." + # + # One alternative to profile-time calibration adjustments (i.e., + # adding in the magic little delta during each event) is to track + # more carefully the number of events (and cumulatively, the number + # of events during sub functions) that are seen. If this were + # done, then the arithmetic could be done after the fact (i.e., at + # display time). Currently, we track only call/return events. + # These values can be deduced by examining the callees and callers + # vectors for each functions. Hence we *can* almost correct the + # internal time figure at print time (note that we currently don't + # track exception event processing counts). Unfortunately, there + # is currently no similar information for cumulative sub-function + # time. It would not be hard to "get all this info" at profiler + # time. Specifically, we would have to extend the tuples to keep + # counts of this in each frame, and then extend the defs of timing + # tuples to include the significant two figures. I'm a bit fearful + # that this additional feature will slow the heavily optimized + # event/time ratio (i.e., the profiler would run slower, fur a very + # low "value added" feature.) + #************************************************************** + + def calibrate(self, m, verbose=0): + if self.__class__ is not Profile: + raise TypeError("Subclasses must override .calibrate().") + + saved_bias = self.bias + self.bias = 0 + try: + return self._calibrate_inner(m, verbose) + finally: + self.bias = saved_bias + + def _calibrate_inner(self, m, verbose): + get_time = self.get_time + + # Set up a test case to be run with and without profiling. Include + # lots of calls, because we're trying to quantify stopwatch overhead. + # Do not raise any exceptions, though, because we want to know + # exactly how many profile events are generated (one call event, + + # one return event, per Python-level call). + + def f1(n): + for i in range(n): + x = 1 + + def f(m, f1=f1): + for i in range(m): + f1(100) + + f(m) # warm up the cache + + # elapsed_noprofile <- time f(m) takes without profiling. + t0 = get_time() + f(m) + t1 = get_time() + elapsed_noprofile = t1 - t0 + if verbose: + print "elapsed time without profiling =", elapsed_noprofile + + # elapsed_profile <- time f(m) takes with profiling. The difference + # is profiling overhead, only some of which the profiler subtracts + # out on its own. + p = Profile() + t0 = get_time() + p.runctx('f(m)', globals(), locals()) + t1 = get_time() + elapsed_profile = t1 - t0 + if verbose: + print "elapsed time with profiling =", elapsed_profile + + # reported_time <- "CPU seconds" the profiler charged to f and f1. + total_calls = 0.0 + reported_time = 0.0 + for (filename, line, funcname), (cc, ns, tt, ct, callers) in \ + p.timings.items(): + if funcname in ("f", "f1"): + total_calls += cc + reported_time += tt + + if verbose: + print "'CPU seconds' profiler reported =", reported_time + print "total # calls =", total_calls + if total_calls != m + 1: + raise ValueError("internal error: total calls = %d" % total_calls) + + # reported_time - elapsed_noprofile = overhead the profiler wasn't + # able to measure. Divide by twice the number of calls (since there + # are two profiler events per call in this test) to get the hidden + # overhead per event. + mean = (reported_time - elapsed_noprofile) / 2.0 / total_calls + if verbose: + print "mean stopwatch overhead per profile event =", mean + return mean + +#**************************************************************************** +def Stats(*args): + print 'Report generating functions are in the "pstats" module\a' + +def main(): + usage = "profile.py [-o output_file_path] [-s sort] scriptfile [arg] ..." + parser = OptionParser(usage=usage) + parser.allow_interspersed_args = False + parser.add_option('-o', '--outfile', dest="outfile", + help="Save stats to ", default=None) + parser.add_option('-s', '--sort', dest="sort", + help="Sort order when printing to stdout, based on pstats.Stats class", default=-1) + + if not sys.argv[1:]: + parser.print_usage() + sys.exit(2) + + (options, args) = parser.parse_args() + sys.argv[:] = args + + if (len(sys.argv) > 0): + sys.path.insert(0, os.path.dirname(sys.argv[0])) + run('execfile(%r)' % (sys.argv[0],), options.outfile, options.sort) + else: + parser.print_usage() + return parser + +# When invoked as main program, invoke the profiler on a script +if __name__ == '__main__': + main() Added: pypy/trunk/lib-python/2.5.2/pstats.py ============================================================================== --- (empty file) +++ pypy/trunk/lib-python/2.5.2/pstats.py Wed Jan 21 14:49:18 2009 @@ -0,0 +1,684 @@ +"""Class for printing reports on profiled python code.""" + +# Class for printing reports on profiled python code. rev 1.0 4/1/94 +# +# Based on prior profile module by Sjoerd Mullender... +# which was hacked somewhat by: Guido van Rossum +# +# see profile.doc and profile.py for more info. + +# Copyright 1994, by InfoSeek Corporation, all rights reserved. +# Written by James Roskind +# +# Permission to use, copy, modify, and distribute this Python software +# and its associated documentation for any purpose (subject to the +# restriction in the following sentence) without fee is hereby granted, +# provided that the above copyright notice appears in all copies, and +# that both that copyright notice and this permission notice appear in +# supporting documentation, and that the name of InfoSeek not be used in +# advertising or publicity pertaining to distribution of the software +# without specific, written prior permission. This permission is +# explicitly restricted to the copying and modification of the software +# to remain in Python, compiled Python, or other languages (such as C) +# wherein the modified or derived code is exclusively imported into a +# Python module. +# +# INFOSEEK CORPORATION DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS +# SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND +# FITNESS. IN NO EVENT SHALL INFOSEEK CORPORATION BE LIABLE FOR ANY +# SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER +# RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF +# CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN +# CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + + +import sys +import os +import time +import marshal +import re + +__all__ = ["Stats"] + +class Stats: + """This class is used for creating reports from data generated by the + Profile class. It is a "friend" of that class, and imports data either + by direct access to members of Profile class, or by reading in a dictionary + that was emitted (via marshal) from the Profile class. + + The big change from the previous Profiler (in terms of raw functionality) + is that an "add()" method has been provided to combine Stats from + several distinct profile runs. Both the constructor and the add() + method now take arbitrarily many file names as arguments. + + All the print methods now take an argument that indicates how many lines + to print. If the arg is a floating point number between 0 and 1.0, then + it is taken as a decimal percentage of the available lines to be printed + (e.g., .1 means print 10% of all available lines). If it is an integer, + it is taken to mean the number of lines of data that you wish to have + printed. + + The sort_stats() method now processes some additional options (i.e., in + addition to the old -1, 0, 1, or 2). It takes an arbitrary number of + quoted strings to select the sort order. For example sort_stats('time', + 'name') sorts on the major key of 'internal function time', and on the + minor key of 'the name of the function'. Look at the two tables in + sort_stats() and get_sort_arg_defs(self) for more examples. + + All methods return self, so you can string together commands like: + Stats('foo', 'goo').strip_dirs().sort_stats('calls').\ + print_stats(5).print_callers(5) + """ + + def __init__(self, *args, **kwds): + # I can't figure out how to explictly specify a stream keyword arg + # with *args: + # def __init__(self, *args, stream=sys.stdout): ... + # so I use **kwds and sqauwk if something unexpected is passed in. + self.stream = sys.stdout + if "stream" in kwds: + self.stream = kwds["stream"] + del kwds["stream"] + if kwds: + keys = kwds.keys() + keys.sort() + extras = ", ".join(["%s=%s" % (k, kwds[k]) for k in keys]) + raise ValueError, "unrecognized keyword args: %s" % extras + if not len(args): + arg = None + else: + arg = args[0] + args = args[1:] + self.init(arg) + self.add(*args) + + def init(self, arg): + self.all_callees = None # calc only if needed + self.files = [] + self.fcn_list = None + self.total_tt = 0 + self.total_calls = 0 + self.prim_calls = 0 + self.max_name_len = 0 + self.top_level = {} + self.stats = {} + self.sort_arg_dict = {} + self.load_stats(arg) + trouble = 1 + try: + self.get_top_level_stats() + trouble = 0 + finally: + if trouble: + print >> self.stream, "Invalid timing data", + if self.files: print >> self.stream, self.files[-1], + print >> self.stream + + def load_stats(self, arg): + if not arg: self.stats = {} + elif isinstance(arg, basestring): + f = open(arg, 'rb') + self.stats = marshal.load(f) + f.close() + try: + file_stats = os.stat(arg) + arg = time.ctime(file_stats.st_mtime) + " " + arg + except: # in case this is not unix + pass + self.files = [ arg ] + elif hasattr(arg, 'create_stats'): + arg.create_stats() + self.stats = arg.stats + arg.stats = {} + if not self.stats: + raise TypeError, "Cannot create or construct a %r object from '%r''" % ( + self.__class__, arg) + return + + def get_top_level_stats(self): + for func, (cc, nc, tt, ct, callers) in self.stats.items(): + self.total_calls += nc + self.prim_calls += cc + self.total_tt += tt + if callers.has_key(("jprofile", 0, "profiler")): + self.top_level[func] = None + if len(func_std_string(func)) > self.max_name_len: + self.max_name_len = len(func_std_string(func)) + + def add(self, *arg_list): + if not arg_list: return self + if len(arg_list) > 1: self.add(*arg_list[1:]) + other = arg_list[0] + if type(self) != type(other) or self.__class__ != other.__class__: + other = Stats(other) + self.files += other.files + self.total_calls += other.total_calls + self.prim_calls += other.prim_calls + self.total_tt += other.total_tt + for func in other.top_level: + self.top_level[func] = None + + if self.max_name_len < other.max_name_len: + self.max_name_len = other.max_name_len + + self.fcn_list = None + + for func, stat in other.stats.iteritems(): + if func in self.stats: + old_func_stat = self.stats[func] + else: + old_func_stat = (0, 0, 0, 0, {},) + self.stats[func] = add_func_stats(old_func_stat, stat) + return self + + def dump_stats(self, filename): + """Write the profile data to a file we know how to load back.""" + f = file(filename, 'wb') + try: + marshal.dump(self.stats, f) + finally: + f.close() + + # list the tuple indices and directions for sorting, + # along with some printable description + sort_arg_dict_default = { + "calls" : (((1,-1), ), "call count"), + "cumulative": (((3,-1), ), "cumulative time"), + "file" : (((4, 1), ), "file name"), + "line" : (((5, 1), ), "line number"), + "module" : (((4, 1), ), "file name"), + "name" : (((6, 1), ), "function name"), + "nfl" : (((6, 1),(4, 1),(5, 1),), "name/file/line"), + "pcalls" : (((0,-1), ), "call count"), + "stdname" : (((7, 1), ), "standard name"), + "time" : (((2,-1), ), "internal time"), + } + + def get_sort_arg_defs(self): + """Expand all abbreviations that are unique.""" + if not self.sort_arg_dict: + self.sort_arg_dict = dict = {} + bad_list = {} + for word, tup in self.sort_arg_dict_default.iteritems(): + fragment = word + while fragment: + if not fragment: + break + if fragment in dict: + bad_list[fragment] = 0 + break + dict[fragment] = tup + fragment = fragment[:-1] + for word in bad_list: + del dict[word] + return self.sort_arg_dict + + def sort_stats(self, *field): + if not field: + self.fcn_list = 0 + return self + if len(field) == 1 and type(field[0]) == type(1): + # Be compatible with old profiler + field = [ {-1: "stdname", + 0:"calls", + 1:"time", + 2: "cumulative" } [ field[0] ] ] + + sort_arg_defs = self.get_sort_arg_defs() + sort_tuple = () + self.sort_type = "" + connector = "" + for word in field: + sort_tuple = sort_tuple + sort_arg_defs[word][0] + self.sort_type += connector + sort_arg_defs[word][1] + connector = ", " + + stats_list = [] + for func, (cc, nc, tt, ct, callers) in self.stats.iteritems(): + stats_list.append((cc, nc, tt, ct) + func + + (func_std_string(func), func)) + + stats_list.sort(TupleComp(sort_tuple).compare) + + self.fcn_list = fcn_list = [] + for tuple in stats_list: + fcn_list.append(tuple[-1]) + return self + + def reverse_order(self): + if self.fcn_list: + self.fcn_list.reverse() + return self + + def strip_dirs(self): + oldstats = self.stats + self.stats = newstats = {} + max_name_len = 0 + for func, (cc, nc, tt, ct, callers) in oldstats.iteritems(): + newfunc = func_strip_path(func) + if len(func_std_string(newfunc)) > max_name_len: + max_name_len = len(func_std_string(newfunc)) + newcallers = {} + for func2, caller in callers.iteritems(): + newcallers[func_strip_path(func2)] = caller + + if newfunc in newstats: + newstats[newfunc] = add_func_stats( + newstats[newfunc], + (cc, nc, tt, ct, newcallers)) + else: + newstats[newfunc] = (cc, nc, tt, ct, newcallers) + old_top = self.top_level + self.top_level = new_top = {} + for func in old_top: + new_top[func_strip_path(func)] = None + + self.max_name_len = max_name_len + + self.fcn_list = None + self.all_callees = None + return self + + def calc_callees(self): + if self.all_callees: return + self.all_callees = all_callees = {} + for func, (cc, nc, tt, ct, callers) in self.stats.iteritems(): + if not func in all_callees: + all_callees[func] = {} + for func2, caller in callers.iteritems(): + if not func2 in all_callees: + all_callees[func2] = {} + all_callees[func2][func] = caller + return + + #****************************************************************** + # The following functions support actual printing of reports + #****************************************************************** + + # Optional "amount" is either a line count, or a percentage of lines. + + def eval_print_amount(self, sel, list, msg): + new_list = list + if type(sel) == type(""): + new_list = [] + for func in list: + if re.search(sel, func_std_string(func)): + new_list.append(func) + else: + count = len(list) + if type(sel) == type(1.0) and 0.0 <= sel < 1.0: + count = int(count * sel + .5) + new_list = list[:count] + elif type(sel) == type(1) and 0 <= sel < count: + count = sel + new_list = list[:count] + if len(list) != len(new_list): + msg = msg + " List reduced from %r to %r due to restriction <%r>\n" % ( + len(list), len(new_list), sel) + + return new_list, msg + + def get_print_list(self, sel_list): + width = self.max_name_len + if self.fcn_list: + list = self.fcn_list[:] + msg = " Ordered by: " + self.sort_type + '\n' + else: + list = self.stats.keys() + msg = " Random listing order was used\n" + + for selection in sel_list: + list, msg = self.eval_print_amount(selection, list, msg) + + count = len(list) + + if not list: + return 0, list + print >> self.stream, msg + if count < len(self.stats): + width = 0 + for func in list: + if len(func_std_string(func)) > width: + width = len(func_std_string(func)) + return width+2, list + + def print_stats(self, *amount): + for filename in self.files: + print >> self.stream, filename + if self.files: print >> self.stream + indent = ' ' * 8 + for func in self.top_level: + print >> self.stream, indent, func_get_function_name(func) + + print >> self.stream, indent, self.total_calls, "function calls", + if self.total_calls != self.prim_calls: + print >> self.stream, "(%d primitive calls)" % self.prim_calls, + print >> self.stream, "in %.3f CPU seconds" % self.total_tt + print >> self.stream + width, list = self.get_print_list(amount) + if list: + self.print_title() + for func in list: + self.print_line(func) + print >> self.stream + print >> self.stream + return self + + def print_callees(self, *amount): + width, list = self.get_print_list(amount) + if list: + self.calc_callees() + + self.print_call_heading(width, "called...") + for func in list: + if func in self.all_callees: + self.print_call_line(width, func, self.all_callees[func]) + else: + self.print_call_line(width, func, {}) + print >> self.stream + print >> self.stream + return self + + def print_callers(self, *amount): + width, list = self.get_print_list(amount) + if list: + self.print_call_heading(width, "was called by...") + for func in list: + cc, nc, tt, ct, callers = self.stats[func] + self.print_call_line(width, func, callers, "<-") + print >> self.stream + print >> self.stream + return self + + def print_call_heading(self, name_size, column_title): + print >> self.stream, "Function ".ljust(name_size) + column_title + # print sub-header only if we have new-style callers + subheader = False + for cc, nc, tt, ct, callers in self.stats.itervalues(): + if callers: + value = callers.itervalues().next() + subheader = isinstance(value, tuple) + break + if subheader: + print >> self.stream, " "*name_size + " ncalls tottime cumtime" + + def print_call_line(self, name_size, source, call_dict, arrow="->"): + print >> self.stream, func_std_string(source).ljust(name_size) + arrow, + if not call_dict: + print >> self.stream + return + clist = call_dict.keys() + clist.sort() + indent = "" + for func in clist: + name = func_std_string(func) + value = call_dict[func] + if isinstance(value, tuple): + nc, cc, tt, ct = value + if nc != cc: + substats = '%d/%d' % (nc, cc) + else: + substats = '%d' % (nc,) + substats = '%s %s %s %s' % (substats.rjust(7+2*len(indent)), + f8(tt), f8(ct), name) + left_width = name_size + 1 + else: + substats = '%s(%r) %s' % (name, value, f8(self.stats[func][3])) + left_width = name_size + 3 + print >> self.stream, indent*left_width + substats + indent = " " + + def print_title(self): + print >> self.stream, ' ncalls tottime percall cumtime percall', + print >> self.stream, 'filename:lineno(function)' + + def print_line(self, func): # hack : should print percentages + cc, nc, tt, ct, callers = self.stats[func] + c = str(nc) + if nc != cc: + c = c + '/' + str(cc) + print >> self.stream, c.rjust(9), + print >> self.stream, f8(tt), + if nc == 0: + print >> self.stream, ' '*8, + else: + print >> self.stream, f8(tt/nc), + print >> self.stream, f8(ct), + if cc == 0: + print >> self.stream, ' '*8, + else: + print >> self.stream, f8(ct/cc), + print >> self.stream, func_std_string(func) + +class TupleComp: + """This class provides a generic function for comparing any two tuples. + Each instance records a list of tuple-indices (from most significant + to least significant), and sort direction (ascending or decending) for + each tuple-index. The compare functions can then be used as the function + argument to the system sort() function when a list of tuples need to be + sorted in the instances order.""" + + def __init__(self, comp_select_list): + self.comp_select_list = comp_select_list + + def compare (self, left, right): + for index, direction in self.comp_select_list: + l = left[index] + r = right[index] + if l < r: + return -direction + if l > r: + return direction + return 0 + +#************************************************************************** +# func_name is a triple (file:string, line:int, name:string) + +def func_strip_path(func_name): + filename, line, name = func_name + return os.path.basename(filename), line, name + +def func_get_function_name(func): + return func[2] + +def func_std_string(func_name): # match what old profile produced + if func_name[:2] == ('~', 0): + # special case for built-in functions + name = func_name[2] + if name.startswith('<') and name.endswith('>'): + return '{%s}' % name[1:-1] + else: + return name + else: + return "%s:%d(%s)" % func_name + +#************************************************************************** +# The following functions combine statists for pairs functions. +# The bulk of the processing involves correctly handling "call" lists, +# such as callers and callees. +#************************************************************************** + +def add_func_stats(target, source): + """Add together all the stats for two profile entries.""" + cc, nc, tt, ct, callers = source + t_cc, t_nc, t_tt, t_ct, t_callers = target + return (cc+t_cc, nc+t_nc, tt+t_tt, ct+t_ct, + add_callers(t_callers, callers)) + +def add_callers(target, source): + """Combine two caller lists in a single list.""" + new_callers = {} + for func, caller in target.iteritems(): + new_callers[func] = caller + for func, caller in source.iteritems(): + if func in new_callers: + new_callers[func] = caller + new_callers[func] + else: + new_callers[func] = caller + return new_callers + +def count_calls(callers): + """Sum the caller statistics to get total number of calls received.""" + nc = 0 + for calls in callers.itervalues(): + nc += calls + return nc + +#************************************************************************** +# The following functions support printing of reports +#************************************************************************** + +def f8(x): + return "%8.3f" % x + +#************************************************************************** +# Statistics browser added by ESR, April 2001 +#************************************************************************** + +if __name__ == '__main__': + import cmd + try: + import readline + except ImportError: + pass + + class ProfileBrowser(cmd.Cmd): + def __init__(self, profile=None): + cmd.Cmd.__init__(self) + self.prompt = "% " + if profile is not None: + self.stats = Stats(profile) + self.stream = self.stats.stream + else: + self.stats = None + self.stream = sys.stdout + + def generic(self, fn, line): + args = line.split() + processed = [] + for term in args: + try: + processed.append(int(term)) + continue + except ValueError: + pass + try: + frac = float(term) + if frac > 1 or frac < 0: + print >> self.stream, "Fraction argument must be in [0, 1]" + continue + processed.append(frac) + continue + except ValueError: + pass + processed.append(term) + if self.stats: + getattr(self.stats, fn)(*processed) + else: + print >> self.stream, "No statistics object is loaded." + return 0 + def generic_help(self): + print >> self.stream, "Arguments may be:" + print >> self.stream, "* An integer maximum number of entries to print." + print >> self.stream, "* A decimal fractional number between 0 and 1, controlling" + print >> self.stream, " what fraction of selected entries to print." + print >> self.stream, "* A regular expression; only entries with function names" + print >> self.stream, " that match it are printed." + + def do_add(self, line): + self.stats.add(line) + return 0 + def help_add(self): + print >> self.stream, "Add profile info from given file to current statistics object." + + def do_callees(self, line): + return self.generic('print_callees', line) + def help_callees(self): + print >> self.stream, "Print callees statistics from the current stat object." + self.generic_help() + + def do_callers(self, line): + return self.generic('print_callers', line) + def help_callers(self): + print >> self.stream, "Print callers statistics from the current stat object." + self.generic_help() + + def do_EOF(self, line): + print >> self.stream, "" + return 1 + def help_EOF(self): + print >> self.stream, "Leave the profile brower." + + def do_quit(self, line): + return 1 + def help_quit(self): + print >> self.stream, "Leave the profile brower." + + def do_read(self, line): + if line: + try: + self.stats = Stats(line) + except IOError, args: + print >> self.stream, args[1] + return + self.prompt = line + "% " + elif len(self.prompt) > 2: + line = self.prompt[-2:] + else: + print >> self.stream, "No statistics object is current -- cannot reload." + return 0 + def help_read(self): + print >> self.stream, "Read in profile data from a specified file." + + def do_reverse(self, line): + self.stats.reverse_order() + return 0 + def help_reverse(self): + print >> self.stream, "Reverse the sort order of the profiling report." + + def do_sort(self, line): + abbrevs = self.stats.get_sort_arg_defs() + if line and not filter(lambda x,a=abbrevs: x not in a,line.split()): + self.stats.sort_stats(*line.split()) + else: + print >> self.stream, "Valid sort keys (unique prefixes are accepted):" + for (key, value) in Stats.sort_arg_dict_default.iteritems(): + print >> self.stream, "%s -- %s" % (key, value[1]) + return 0 + def help_sort(self): + print >> self.stream, "Sort profile data according to specified keys." + print >> self.stream, "(Typing `sort' without arguments lists valid keys.)" + def complete_sort(self, text, *args): + return [a for a in Stats.sort_arg_dict_default if a.startswith(text)] + + def do_stats(self, line): + return self.generic('print_stats', line) + def help_stats(self): + print >> self.stream, "Print statistics from the current stat object." + self.generic_help() + + def do_strip(self, line): + self.stats.strip_dirs() + return 0 + def help_strip(self): + print >> self.stream, "Strip leading path information from filenames in the report." + + def postcmd(self, stop, line): + if stop: + return stop + return None + + import sys + if len(sys.argv) > 1: + initprofile = sys.argv[1] + else: + initprofile = None + try: + browser = ProfileBrowser(initprofile) + print >> browser.stream, "Welcome to the profile statistics browser." + browser.cmdloop() + print >> browser.stream, "Goodbye." + except KeyboardInterrupt: + pass + +# That's all, folks. From fijal at codespeak.net Wed Jan 21 14:50:48 2009 From: fijal at codespeak.net (fijal at codespeak.net) Date: Wed, 21 Jan 2009 14:50:48 +0100 (CET) Subject: [pypy-svn] r61188 - pypy/trunk/lib-python Message-ID: <20090121135048.F0185168448@codespeak.net> Author: fijal Date: Wed Jan 21 14:50:48 2009 New Revision: 61188 Modified: pypy/trunk/lib-python/conftest.py Log: reenable this test Modified: pypy/trunk/lib-python/conftest.py ============================================================================== --- pypy/trunk/lib-python/conftest.py (original) +++ pypy/trunk/lib-python/conftest.py Wed Jan 21 14:50:48 2009 @@ -328,7 +328,7 @@ RegrTest('test_posixpath.py'), RegrTest('test_pow.py', core=True), RegrTest('test_pprint.py', core=True), - RegrTest('test_profile.py', skip="unsupported module, even by cpython"), + RegrTest('test_profile.py'), RegrTest('test_profilehooks.py', core=True), RegrTest('test_pty.py', skip="unsupported extension module"), RegrTest('test_pwd.py'), From arigo at codespeak.net Wed Jan 21 14:56:54 2009 From: arigo at codespeak.net (arigo at codespeak.net) Date: Wed, 21 Jan 2009 14:56:54 +0100 (CET) Subject: [pypy-svn] r61189 - pypy/trunk/lib-python/modified-2.5.2/distutils Message-ID: <20090121135654.29A73168449@codespeak.net> Author: arigo Date: Wed Jan 21 14:56:53 2009 New Revision: 61189 Added: pypy/trunk/lib-python/modified-2.5.2/distutils/ - copied from r61033, pypy/trunk/lib-python/2.5.2/distutils/ Log: A copy of distutils. From arigo at codespeak.net Wed Jan 21 15:07:50 2009 From: arigo at codespeak.net (arigo at codespeak.net) Date: Wed, 21 Jan 2009 15:07:50 +0100 (CET) Subject: [pypy-svn] r61190 - in pypy/trunk: lib-python/modified-2.5.2 pypy/module/sys Message-ID: <20090121140750.02F4816844E@codespeak.net> Author: arigo Date: Wed Jan 21 15:07:50 2009 New Revision: 61190 Modified: pypy/trunk/lib-python/modified-2.5.2/site.py pypy/trunk/pypy/module/sys/__init__.py pypy/trunk/pypy/module/sys/state.py Log: Kill sys.prefix and sys.exec_prefix, and replace them with sys.pypy_prefix. It points to the root of the checkout. Modified: pypy/trunk/lib-python/modified-2.5.2/site.py ============================================================================== --- pypy/trunk/lib-python/modified-2.5.2/site.py (original) +++ pypy/trunk/lib-python/modified-2.5.2/site.py Wed Jan 21 15:07:50 2009 @@ -175,38 +175,11 @@ return known_paths def addsitepackages(known_paths): - """Add site-packages (and possibly site-python) to sys.path""" - prefixes = [sys.prefix] - if sys.exec_prefix != sys.prefix: - prefixes.append(sys.exec_prefix) - for prefix in prefixes: - if prefix: - if sys.platform in ('os2emx', 'riscos'): - sitedirs = [os.path.join(prefix, "Lib", "site-packages")] - elif os.sep == '/': - sitedirs = [os.path.join(prefix, - "lib", - "python" + sys.version[:3], - "site-packages"), - os.path.join(prefix, "lib", "site-python")] - else: - sitedirs = [prefix, os.path.join(prefix, "lib", "site-packages")] - if sys.platform == 'darwin': - # for framework builds *only* we add the standard Apple - # locations. Currently only per-user, but /Library and - # /Network/Library could be added too - if 'Python.framework' in prefix: - home = os.environ.get('HOME') - if home: - sitedirs.append( - os.path.join(home, - 'Library', - 'Python', - sys.version[:3], - 'site-packages')) - for sitedir in sitedirs: - if os.path.isdir(sitedir): - addsitedir(sitedir, known_paths) + """Add site-packages to sys.path, in a PyPy-specific way.""" + if hasattr(sys, 'pypy_prefix'): + sitedir = os.path.join(sys.pypy_prefix, "site-packages") + if os.path.isdir(sitedir): + addsitedir(sitedir, known_paths) return None Modified: pypy/trunk/pypy/module/sys/__init__.py ============================================================================== --- pypy/trunk/pypy/module/sys/__init__.py (original) +++ pypy/trunk/pypy/module/sys/__init__.py Wed Jan 21 15:07:50 2009 @@ -18,8 +18,6 @@ 'platform' : 'space.wrap(sys.platform)', 'maxint' : 'space.wrap(sys.maxint)', 'byteorder' : 'space.wrap(sys.byteorder)', - 'exec_prefix' : 'space.wrap(sys.exec_prefix)', - 'prefix' : 'space.wrap(sys.prefix)', 'maxunicode' : 'space.wrap(sys.maxunicode)', 'maxint' : 'space.wrap(sys.maxint)', 'stdin' : 'state.getio(space).w_stdin', @@ -29,6 +27,8 @@ 'stderr' : 'state.getio(space).w_stderr', '__stderr__' : 'state.getio(space).w_stderr', 'pypy_objspaceclass' : 'space.wrap(repr(space))', + #'pypy_prefix': added by pypy_initial_path() when it succeeds, pointing + # to the trunk of a checkout or to the dir /usr/share/pypy-1.1 . 'path' : 'state.get(space).w_path', 'modules' : 'state.get(space).w_modules', Modified: pypy/trunk/pypy/module/sys/state.py ============================================================================== --- pypy/trunk/pypy/module/sys/state.py (original) +++ pypy/trunk/pypy/module/sys/state.py Wed Jan 21 15:07:50 2009 @@ -62,6 +62,8 @@ except OSError: return space.w_None else: + space.setitem(space.sys.w_dict, space.wrap('pypy_prefix'), + space.wrap(srcdir)) return space.newlist([space.wrap(p) for p in path]) pypy_initial_path.unwrap_spec = [ObjSpace, str] From antocuni at codespeak.net Wed Jan 21 15:34:01 2009 From: antocuni at codespeak.net (antocuni at codespeak.net) Date: Wed, 21 Jan 2009 15:34:01 +0100 (CET) Subject: [pypy-svn] r61191 - in pypy/trunk/pypy/interpreter: pyparser test Message-ID: <20090121143401.332AA168433@codespeak.net> Author: antocuni Date: Wed Jan 21 15:33:58 2009 New Revision: 61191 Modified: pypy/trunk/pypy/interpreter/pyparser/pythonparse.py pypy/trunk/pypy/interpreter/test/test_syntax.py Log: raise SyntaxError in case the encoding declaration contains a bad codec Modified: pypy/trunk/pypy/interpreter/pyparser/pythonparse.py ============================================================================== --- pypy/trunk/pypy/interpreter/pyparser/pythonparse.py (original) +++ pypy/trunk/pypy/interpreter/pyparser/pythonparse.py Wed Jan 21 15:33:58 2009 @@ -5,6 +5,7 @@ using file_input, single_input and eval_input targets """ from pypy.interpreter import gateway +from pypy.interpreter.error import OperationError from pypy.interpreter.pyparser.error import SyntaxError from pypy.interpreter.pyparser.pythonlexer import Source, match_encoding_declaration from pypy.interpreter.astcompiler.consts import CO_FUTURE_WITH_STATEMENT @@ -107,7 +108,16 @@ else: enc = _normalize_encoding(_check_for_encoding(textsrc)) if enc is not None and enc not in ('utf-8', 'iso-8859-1'): - textsrc = recode_to_utf8(builder.space, textsrc, enc) + try: + textsrc = recode_to_utf8(builder.space, textsrc, enc) + except OperationError, e: + # if the codec is not found, LookupError is raised. we + # check using 'is_w' not to mask potential IndexError or + # KeyError + space = builder.space + if space.is_w(e.w_type, space.w_LookupError): + raise SyntaxError("Unknown encoding: %s" % enc) + raise lines = [line + '\n' for line in textsrc.split('\n')] builder.source_encoding = enc Modified: pypy/trunk/pypy/interpreter/test/test_syntax.py ============================================================================== --- pypy/trunk/pypy/interpreter/test/test_syntax.py (original) +++ pypy/trunk/pypy/interpreter/test/test_syntax.py Wed Jan 21 15:33:58 2009 @@ -621,6 +621,13 @@ else: raise Exception("no SyntaxError??") + def test_bad_encoding(self): + program = """ +# -*- coding: uft-8 -*- +pass +""" + raises(SyntaxError, "exec program") + if __name__ == '__main__': # only to check on top of CPython (you need 2.4) From arigo at codespeak.net Wed Jan 21 15:55:15 2009 From: arigo at codespeak.net (arigo at codespeak.net) Date: Wed, 21 Jan 2009 15:55:15 +0100 (CET) Subject: [pypy-svn] r61192 - in pypy/trunk/lib-python/modified-2.5.2/distutils: . command Message-ID: <20090121145515.CF492168447@codespeak.net> Author: arigo Date: Wed Jan 21 15:55:15 2009 New Revision: 61192 Added: pypy/trunk/lib-python/modified-2.5.2/distutils/sysconfig.py pypy/trunk/lib-python/modified-2.5.2/distutils/sysconfig_cpython.py - copied unchanged from r61189, pypy/trunk/lib-python/modified-2.5.2/distutils/sysconfig.py pypy/trunk/lib-python/modified-2.5.2/distutils/sysconfig_pypy.py (contents, props changed) Modified: pypy/trunk/lib-python/modified-2.5.2/distutils/command/install.py Log: distutils works, at least the 'build' and 'install' commands. Modified: pypy/trunk/lib-python/modified-2.5.2/distutils/command/install.py ============================================================================== --- pypy/trunk/lib-python/modified-2.5.2/distutils/command/install.py (original) +++ pypy/trunk/lib-python/modified-2.5.2/distutils/command/install.py Wed Jan 21 15:55:15 2009 @@ -65,6 +65,13 @@ 'headers': '$base/Include/$dist_name', 'scripts': '$base/Scripts', 'data' : '$base', + }, + 'pypy': { + 'purelib': '$base/site-packages', + 'platlib': '$base/site-packages', + 'headers': '$base/include', + 'scripts': '$base/bin', + 'data' : '$base', } } @@ -385,8 +392,12 @@ raise DistutilsOptionError, \ "must not supply exec-prefix without prefix" - self.prefix = os.path.normpath(sys.prefix) - self.exec_prefix = os.path.normpath(sys.exec_prefix) + if hasattr(sys, 'pypy_prefix'): + self.prefix = os.path.normpath(sys.pypy_prefix) + self.exec_prefix = self.prefix + else: + self.prefix = os.path.normpath(sys.prefix) + self.exec_prefix = os.path.normpath(sys.exec_prefix) else: if self.exec_prefix is None: @@ -406,7 +417,10 @@ self.select_scheme("unix_home") else: if self.prefix is None: - self.prefix = os.path.normpath(sys.prefix) + if hasattr(sys, 'pypy_prefix'): + self.prefix = os.path.normpath(sys.pypy_prefix) + else: + self.prefix = os.path.normpath(sys.prefix) self.install_base = self.install_platbase = self.prefix try: @@ -420,6 +434,8 @@ def select_scheme (self, name): # it's the caller's problem if they supply a bad name! + if hasattr(sys, 'pypy_prefix'): + name = 'pypy' scheme = INSTALL_SCHEMES[name] for key in SCHEME_KEYS: attrname = 'install_' + key Added: pypy/trunk/lib-python/modified-2.5.2/distutils/sysconfig.py ============================================================================== --- (empty file) +++ pypy/trunk/lib-python/modified-2.5.2/distutils/sysconfig.py Wed Jan 21 15:55:15 2009 @@ -0,0 +1,23 @@ +"""Provide access to Python's configuration information. The specific +configuration variables available depend heavily on the platform and +configuration. The values may be retrieved using +get_config_var(name), and the list of variables is available via +get_config_vars().keys(). Additional convenience functions are also +available. + +Written by: Fred L. Drake, Jr. +Email: +""" + +__revision__ = "$Id: sysconfig.py 52234 2006-10-08 17:50:26Z ronald.oussoren $" + +import sys + + +# The content of this file is redirected from +# sysconfig_cpython or sysconfig_pypy. + +if '__pypy__' in sys.builtin_module_names: + from distutils.sysconfig_pypy import * +else: + from distutils.sysconfig_cpython import * Added: pypy/trunk/lib-python/modified-2.5.2/distutils/sysconfig_pypy.py ============================================================================== --- (empty file) +++ pypy/trunk/lib-python/modified-2.5.2/distutils/sysconfig_pypy.py Wed Jan 21 15:55:15 2009 @@ -0,0 +1,63 @@ +"""PyPy's minimal configuration information. +""" + +import sys +import os + + +PYPY_PREFIX = os.path.normpath(sys.pypy_prefix) +python_build = False + + +_config_vars = None + +def _init_posix(): + """Initialize the module as appropriate for POSIX systems.""" + g = {} + g['EXE'] = "" + + global _config_vars + _config_vars = g + + +def _init_nt(): + """Initialize the module as appropriate for NT""" + g = {} + g['EXE'] = ".exe" + + global _config_vars + _config_vars = g + + +def get_config_vars(*args): + """With no arguments, return a dictionary of all configuration + variables relevant for the current platform. Generally this includes + everything needed to build extensions and install both pure modules and + extensions. On Unix, this means every variable defined in Python's + installed Makefile; on Windows and Mac OS it's a much smaller set. + + With arguments, return a list of values that result from looking up + each argument in the configuration variable dictionary. + """ + global _config_vars + if _config_vars is None: + func = globals().get("_init_" + os.name) + if func: + func() + else: + _config_vars = {} + + if args: + vals = [] + for name in args: + vals.append(_config_vars.get(name)) + return vals + else: + return _config_vars + +def get_config_var(name): + """Return the value of a single variable using the dictionary + returned by 'get_config_vars()'. Equivalent to + get_config_vars().get(name) + """ + return get_config_vars().get(name) From cfbolz at codespeak.net Wed Jan 21 16:03:40 2009 From: cfbolz at codespeak.net (cfbolz at codespeak.net) Date: Wed, 21 Jan 2009 16:03:40 +0100 (CET) Subject: [pypy-svn] r61194 - in pypy/trunk/pypy: module/__builtin__ objspace/std/test Message-ID: <20090121150340.96344168447@codespeak.net> Author: cfbolz Date: Wed Jan 21 16:03:40 2009 New Revision: 61194 Modified: pypy/trunk/pypy/module/__builtin__/operation.py pypy/trunk/pypy/objspace/std/test/test_dictmultiobject.py Log: issue383 fixed decided on a slightly different behaviour for getattr and setattr: they always transform their first argument into a string, even if it is a subclass of string. Modified: pypy/trunk/pypy/module/__builtin__/operation.py ============================================================================== --- pypy/trunk/pypy/module/__builtin__/operation.py (original) +++ pypy/trunk/pypy/module/__builtin__/operation.py Wed Jan 21 16:03:40 2009 @@ -46,7 +46,7 @@ # space.{get,set,del}attr()... # Note that if w_name is already a string (or a subclass of str), # it must be returned unmodified (and not e.g. unwrapped-rewrapped). - if not space.is_true(space.isinstance(w_name, space.w_str)): + if not space.is_true(space.is_(w_name, space.w_str)): name = space.str_w(w_name) # typecheck w_name = space.wrap(name) # rewrap as a real string return w_name Modified: pypy/trunk/pypy/objspace/std/test/test_dictmultiobject.py ============================================================================== --- pypy/trunk/pypy/objspace/std/test/test_dictmultiobject.py (original) +++ pypy/trunk/pypy/objspace/std/test/test_dictmultiobject.py Wed Jan 21 16:03:40 2009 @@ -18,7 +18,6 @@ raises(TypeError, "{}[['x']]") def test_string_subclass_via_setattr(self): - skip("issue383") class A(object): pass class S(str): @@ -27,7 +26,9 @@ a = A() s = S("abc") setattr(a, s, 42) - assert a.__dict__.keys()[0] is s + key = a.__dict__.keys()[0] + assert key == s + assert type(key) is str assert getattr(a, s) == 42 From cfbolz at codespeak.net Wed Jan 21 16:04:44 2009 From: cfbolz at codespeak.net (cfbolz at codespeak.net) Date: Wed, 21 Jan 2009 16:04:44 +0100 (CET) Subject: [pypy-svn] r61195 - pypy/trunk/lib-python/modified-2.5.2/test Message-ID: <20090121150444.80E39168432@codespeak.net> Author: cfbolz Date: Wed Jan 21 16:04:43 2009 New Revision: 61195 Modified: pypy/trunk/lib-python/modified-2.5.2/test/test_builtin.py Log: This should be fixed. Modified: pypy/trunk/lib-python/modified-2.5.2/test/test_builtin.py ============================================================================== --- pypy/trunk/lib-python/modified-2.5.2/test/test_builtin.py (original) +++ pypy/trunk/lib-python/modified-2.5.2/test/test_builtin.py Wed Jan 21 16:04:43 2009 @@ -885,7 +885,6 @@ # call intern internally, e.g. PyObject_SetAttr(). s = S("abc") setattr(s, s, s) - # see pypy issue #383 self.assertEqual(getattr(s, s), s) def test_iter(self): From fijal at codespeak.net Wed Jan 21 16:34:38 2009 From: fijal at codespeak.net (fijal at codespeak.net) Date: Wed, 21 Jan 2009 16:34:38 +0100 (CET) Subject: [pypy-svn] r61197 - pypy/extradoc/talk/wroclaw2009 Message-ID: <20090121153438.36CD5168441@codespeak.net> Author: fijal Date: Wed Jan 21 16:34:36 2009 New Revision: 61197 Added: pypy/extradoc/talk/wroclaw2009/talk.txt (contents, props changed) Log: first draft of a talk Added: pypy/extradoc/talk/wroclaw2009/talk.txt ============================================================================== --- (empty file) +++ pypy/extradoc/talk/wroclaw2009/talk.txt Wed Jan 21 16:34:36 2009 @@ -0,0 +1,73 @@ +========================= +PyPy - XXX title +========================= + +Title page +========== + +What this talk is about? +======================== + +* general overview of dynamic languages vm + +* example: python + +* challenges of classic approach + +* possible solution - pypy + +Dynamic languages VM's +====================== + +* written in lower level language (C, Java) + +* usually hard coded design decisions + (ie GC, object layout, threading model) + +* hard to maintain + +* a challenge between performance and maintainability + +Example - python +================ + +* primary implementation - CPython + +* written in C + +* hard-coded - Global Interpreter Lock + +* hard-coded - refcounting for garbage collection + +Example - python (2) +==================== + +* Jython, IronPython - bound to a specific VM + +* not really winning in terms of performance + +* Java is still not the best language ever + +* both are compilers, harder to maintain + +Ideally, we would ... +===================== + +* use a high level language, to describe an interpreter + +* get performance by dynamic compilation + +* separate language semantics from designe decisions + +n*m*l problem +============= + +* n - dynamic languages + +* m - design decisions (GC, JIT, etc.) + +* l - platforms (JVM, .NET, C/Posix) + +* we want n+m+l effort, instead of n*m*l! + +XXX finish From arigo at codespeak.net Wed Jan 21 16:49:04 2009 From: arigo at codespeak.net (arigo at codespeak.net) Date: Wed, 21 Jan 2009 16:49:04 +0100 (CET) Subject: [pypy-svn] r61198 - pypy/trunk/lib-python/modified-2.5.2/distutils Message-ID: <20090121154904.717B6168441@codespeak.net> Author: arigo Date: Wed Jan 21 16:49:03 2009 New Revision: 61198 Modified: pypy/trunk/lib-python/modified-2.5.2/distutils/sysconfig_pypy.py Log: Some more functions, as needed by easy_install. Modified: pypy/trunk/lib-python/modified-2.5.2/distutils/sysconfig_pypy.py ============================================================================== --- pypy/trunk/lib-python/modified-2.5.2/distutils/sysconfig_pypy.py (original) +++ pypy/trunk/lib-python/modified-2.5.2/distutils/sysconfig_pypy.py Wed Jan 21 16:49:03 2009 @@ -4,11 +4,43 @@ import sys import os +from distutils.errors import DistutilsPlatformError + PYPY_PREFIX = os.path.normpath(sys.pypy_prefix) python_build = False +def get_python_version(): + """Return a string containing the major and minor Python version, + leaving off the patchlevel. Sample return values could be '1.5' + or '2.2'. + """ + return sys.version[:3] + + +def get_python_lib(plat_specific=0, standard_lib=0, prefix=None): + """Return the directory containing the Python library (standard or + site additions). + + If 'plat_specific' is true, return the directory containing + platform-specific modules, i.e. any module from a non-pure-Python + module distribution; otherwise, return the platform-shared library + directory. If 'standard_lib' is true, return the directory + containing standard Python library modules; otherwise, return the + directory for site-specific modules. + + If 'prefix' is supplied, use it instead of sys.prefix or + sys.exec_prefix -- i.e., ignore 'plat_specific'. + """ + if standard_lib: + raise DistutilsPlatformError( + "calls to get_python_lib(standard_lib=1) cannot succeed") + if prefix is None: + prefix = PYPY_PREFIX + return os.path.join(prefix, "site-packages") + + _config_vars = None def _init_posix(): From arigo at codespeak.net Wed Jan 21 16:49:24 2009 From: arigo at codespeak.net (arigo at codespeak.net) Date: Wed, 21 Jan 2009 16:49:24 +0100 (CET) Subject: [pypy-svn] r61199 - pypy/trunk/lib-python/modified-2.5.2 Message-ID: <20090121154924.93EA3168449@codespeak.net> Author: arigo Date: Wed Jan 21 16:49:24 2009 New Revision: 61199 Modified: pypy/trunk/lib-python/modified-2.5.2/socket.py Log: Fix for an abuse of socket._fileobject by urllib2.py. Modified: pypy/trunk/lib-python/modified-2.5.2/socket.py ============================================================================== --- pypy/trunk/lib-python/modified-2.5.2/socket.py (original) +++ pypy/trunk/lib-python/modified-2.5.2/socket.py Wed Jan 21 16:49:24 2009 @@ -249,7 +249,11 @@ self._sock = None if self._close: s.close() - s._drop() + try: + s._drop() + except AttributeError: + pass # for the abuse of socket._fileobject from + # urllib2.py :-( def __del__(self): try: From arigo at codespeak.net Wed Jan 21 17:04:18 2009 From: arigo at codespeak.net (arigo at codespeak.net) Date: Wed, 21 Jan 2009 17:04:18 +0100 (CET) Subject: [pypy-svn] r61200 - pypy/extradoc/talk/wroclaw2009 Message-ID: <20090121160418.A5B76168452@codespeak.net> Author: arigo Date: Wed Jan 21 17:04:18 2009 New Revision: 61200 Modified: pypy/extradoc/talk/wroclaw2009/talk.txt Log: "about the same performance as CPython". Plus typos. Modified: pypy/extradoc/talk/wroclaw2009/talk.txt ============================================================================== --- pypy/extradoc/talk/wroclaw2009/talk.txt (original) +++ pypy/extradoc/talk/wroclaw2009/talk.txt Wed Jan 21 17:04:18 2009 @@ -44,7 +44,7 @@ * Jython, IronPython - bound to a specific VM -* not really winning in terms of performance +* about the same performance as CPython * Java is still not the best language ever @@ -57,7 +57,7 @@ * get performance by dynamic compilation -* separate language semantics from designe decisions +* separate language semantics from design decisions n*m*l problem ============= @@ -68,6 +68,6 @@ * l - platforms (JVM, .NET, C/Posix) -* we want n+m+l effort, instead of n*m*l! +* we want an ``n+m+l`` effort, instead of ``n*m*l`` ! XXX finish From fijal at codespeak.net Wed Jan 21 20:21:24 2009 From: fijal at codespeak.net (fijal at codespeak.net) Date: Wed, 21 Jan 2009 20:21:24 +0100 (CET) Subject: [pypy-svn] r61207 - pypy/extradoc/talk/wroclaw2009 Message-ID: <20090121192124.9479F168449@codespeak.net> Author: fijal Date: Wed Jan 21 20:21:23 2009 New Revision: 61207 Added: pypy/extradoc/talk/wroclaw2009/author.latex - copied, changed from r60908, pypy/extradoc/talk/pycon-uk-2008/status/author.latex pypy/extradoc/talk/wroclaw2009/makepdf - copied, changed from r60908, pypy/extradoc/talk/pycon-uk-2008/status/makepdf pypy/extradoc/talk/wroclaw2009/merlinux-logo.jpg - copied unchanged from r60908, pypy/extradoc/talk/pycon-uk-2008/status/merlinux-logo.jpg pypy/extradoc/talk/wroclaw2009/stylesheet.latex - copied unchanged from r60908, pypy/extradoc/talk/pycon-uk-2008/status/stylesheet.latex pypy/extradoc/talk/wroclaw2009/talk.pdf (contents, props changed) pypy/extradoc/talk/wroclaw2009/title.latex - copied, changed from r60908, pypy/extradoc/talk/pycon-uk-2008/status/title.latex Modified: pypy/extradoc/talk/wroclaw2009/talk.txt Log: progress Copied: pypy/extradoc/talk/wroclaw2009/author.latex (from r60908, pypy/extradoc/talk/pycon-uk-2008/status/author.latex) ============================================================================== --- pypy/extradoc/talk/pycon-uk-2008/status/author.latex (original) +++ pypy/extradoc/talk/wroclaw2009/author.latex Wed Jan 21 20:21:23 2009 @@ -1,8 +1,8 @@ \definecolor{rrblitbackground}{rgb}{0.0, 0.0, 0.0} \title[PyPy status talk]{PyPy status talk} -\author[H. Krekel, M. Fijalkowski]{Holger Krekel \and Maciej Fijalkowski\\ +\author[M. Fijalkowski]{Maciej Fijalkowski\\ Merlinux GmbH} -\institute[PyCon UK 2008]{PyCon UK 2008 - Birmingham} -\date{September 13 2008} +\institute[Politechnika Wroclawska]{Politechnika Wroclawska} +\date{January 22 2009} Copied: pypy/extradoc/talk/wroclaw2009/makepdf (from r60908, pypy/extradoc/talk/pycon-uk-2008/status/makepdf) ============================================================================== --- pypy/extradoc/talk/pycon-uk-2008/status/makepdf (original) +++ pypy/extradoc/talk/wroclaw2009/makepdf Wed Jan 21 20:21:23 2009 @@ -6,7 +6,7 @@ # WARNING: to work, it needs this patch for docutils # https://sourceforge.net/tracker/?func=detail&atid=422032&aid=1459707&group_id=38414 -BASE=status +BASE=talk rst2beamer.py --stylesheet=stylesheet.latex --documentoptions=14pt $BASE.txt $BASE.latex || exit sed 's/\\date{}/\\input{author.latex}/' -i $BASE.latex || exit sed 's/\\maketitle/\\input{title.latex}/' -i $BASE.latex || exit Added: pypy/extradoc/talk/wroclaw2009/talk.pdf ============================================================================== Binary file. No diff available. Modified: pypy/extradoc/talk/wroclaw2009/talk.txt ============================================================================== --- pypy/extradoc/talk/wroclaw2009/talk.txt (original) +++ pypy/extradoc/talk/wroclaw2009/talk.txt Wed Jan 21 20:21:23 2009 @@ -2,9 +2,6 @@ PyPy - XXX title ========================= -Title page -========== - What this talk is about? ======================== @@ -39,6 +36,8 @@ * hard-coded - refcounting for garbage collection +* psyco - very hard to maintain + Example - python (2) ==================== @@ -70,4 +69,40 @@ * we want an ``n+m+l`` effort, instead of ``n*m*l`` ! -XXX finish +Happy snakes +============ + +.. image:: happy_snake.jpg + :align: center + :scale: 40 + +PyPy - high level goals +======================= + +* solve n*m*l problem + +* create a nice, fast and maintainable python implementation + +* that runs on C/Posix, .NET, JVM, whatever + +* with JIT + +PyPy - high level architecture +============================== + +.. image:: architecture.png + :scale: 60 + +PyPy - implementation language +============================== + +* RPython - restricted susbset of Python + +* but still a valid python + +* static enough to compile to efficient code + +* not necesarilly nice language + +* ... but better than C + Copied: pypy/extradoc/talk/wroclaw2009/title.latex (from r60908, pypy/extradoc/talk/pycon-uk-2008/status/title.latex) ============================================================================== --- pypy/extradoc/talk/pycon-uk-2008/status/title.latex (original) +++ pypy/extradoc/talk/wroclaw2009/title.latex Wed Jan 21 20:21:23 2009 @@ -2,6 +2,6 @@ \begin{figure}[h] \includegraphics[width=64px,height=64px]{merlinux-logo.jpg} \qquad -\includegraphics[width=80px]{../../img/py-web.png} +\includegraphics[width=80px]{../img/py-web.png} \end{figure} \end{titlepage} From exarkun at codespeak.net Wed Jan 21 20:49:02 2009 From: exarkun at codespeak.net (exarkun at codespeak.net) Date: Wed, 21 Jan 2009 20:49:02 +0100 (CET) Subject: [pypy-svn] r61208 - pypy/extradoc/talk/wroclaw2009 Message-ID: <20090121194902.85D7D168441@codespeak.net> Author: exarkun Date: Wed Jan 21 20:49:01 2009 New Revision: 61208 Modified: pypy/extradoc/talk/wroclaw2009/talk.txt Log: minor edits Modified: pypy/extradoc/talk/wroclaw2009/talk.txt ============================================================================== --- pypy/extradoc/talk/wroclaw2009/talk.txt (original) +++ pypy/extradoc/talk/wroclaw2009/talk.txt Wed Jan 21 20:49:01 2009 @@ -13,13 +13,13 @@ * possible solution - pypy -Dynamic languages VM's +Dynamic languages VMs ====================== * written in lower level language (C, Java) * usually hard coded design decisions - (ie GC, object layout, threading model) + (eg about GC, object layout, threading model) * hard to maintain @@ -96,13 +96,13 @@ PyPy - implementation language ============================== -* RPython - restricted susbset of Python +* RPython - restricted subset of Python -* but still a valid python +* but still valid python * static enough to compile to efficient code -* not necesarilly nice language +* not necessarily a nice language * ... but better than C From afa at codespeak.net Thu Jan 22 00:56:20 2009 From: afa at codespeak.net (afa at codespeak.net) Date: Thu, 22 Jan 2009 00:56:20 +0100 (CET) Subject: [pypy-svn] r61210 - pypy/trunk/pypy/translator/platform Message-ID: <20090121235620.6FA6116844B@codespeak.net> Author: afa Date: Thu Jan 22 00:56:18 2009 New Revision: 61210 Modified: pypy/trunk/pypy/translator/platform/__init__.py pypy/trunk/pypy/translator/platform/windows.py Log: There is no need to have the same compiler version as the one used to compile CPython. If the correct version cannot be found, pick the first one we find. Modified: pypy/trunk/pypy/translator/platform/__init__.py ============================================================================== --- pypy/trunk/pypy/translator/platform/__init__.py (original) +++ pypy/trunk/pypy/translator/platform/__init__.py Thu Jan 22 00:56:18 2009 @@ -47,7 +47,8 @@ class Platform(object): name = "abstract platform" - + c_environ = None + def __init__(self, cc): if self.__class__ is Platform: raise TypeError("You should not instantiate Platform class directly") @@ -91,7 +92,7 @@ def _execute_c_compiler(self, cc, args, outname): log.execute(cc + ' ' + ' '.join(args)) - returncode, stdout, stderr = _run_subprocess(cc, args) + returncode, stdout, stderr = _run_subprocess(cc, args, self.c_environ) self._handle_error(returncode, stderr, stdout, outname) def _handle_error(self, returncode, stderr, stdout, outname): Modified: pypy/trunk/pypy/translator/platform/windows.py ============================================================================== --- pypy/trunk/pypy/translator/platform/windows.py (original) +++ pypy/trunk/pypy/translator/platform/windows.py Thu Jan 22 00:56:18 2009 @@ -5,18 +5,12 @@ from pypy.translator.platform import Platform, posix from pypy.tool import autopath -def _install_msvc_env(): - # The same compiler must be used for the python interpreter - # and extension modules - msc_pos = sys.version.find('MSC v.') - if msc_pos == -1: - # Not a windows platform... - return +def _get_msvc_env(vsver): + try: + toolsdir = os.environ['VS%sCOMNTOOLS' % vsver] + except KeyError: + return None - msc_ver = int(sys.version[msc_pos+6:msc_pos+10]) - # 1300 -> 70, 1310 -> 71, 1400 -> 80, 1500 -> 90 - vsver = (msc_ver / 10) - 60 - toolsdir = os.environ['VS%sCOMNTOOLS' % vsver] vcvars = os.path.join(toolsdir, 'vsvars32.bat') import subprocess @@ -26,24 +20,42 @@ stdout, stderr = popen.communicate() if popen.wait() != 0: - raise IOError(stderr) + return + + env = {} for line in stdout.split("\n"): if '=' not in line: continue key, value = line.split('=', 1) if key.upper() in ['PATH', 'INCLUDE', 'LIB']: - os.environ[key] = value - log.msg(line) + env[key.upper()] = value log.msg("Updated environment with %s" % (vcvars,)) + return env -try: - _install_msvc_env() -except Exception, e: - print >>sys.stderr, "Could not find a suitable Microsoft Compiler" - import traceback - traceback.print_exc() +def find_msvc_env(): + # First, try to get the compiler which served to compile python + msc_pos = sys.version.find('MSC v.') + if msc_pos != -1: + msc_ver = int(sys.version[msc_pos+6:msc_pos+10]) + # 1300 -> 70, 1310 -> 71, 1400 -> 80, 1500 -> 90 + vsver = (msc_ver / 10) - 60 + env = _get_msvc_env(vsver) + + if env is not None: + return env + + # Then, try any other version + for vsver in (100, 90, 80, 71, 70): # All the versions I know + env = _get_msvc_env(vsver) + + if env is not None: + return env + + log.error("Could not find a Microsoft Compiler") # Assume that the compiler is already part of the environment +msvc_compiler_environ = find_msvc_env() + class Windows(Platform): name = "win32" so_ext = 'dll' @@ -56,12 +68,19 @@ link_flags = [] standalone_only = [] shared_only = [] + environ = None def __init__(self, cc=None): self.cc = 'cl.exe' + if msvc_compiler_environ: + self.c_environ = os.environ.copy() + self.c_environ.update(msvc_compiler_environ) + # XXX passing an environment to subprocess is not enough. Why? + os.environ.update(msvc_compiler_environ) # detect version of current compiler - returncode, stdout, stderr = _run_subprocess(self.cc, []) + returncode, stdout, stderr = _run_subprocess(self.cc, '', + env=self.c_environ) r = re.search('Version ([0-9]+)\.([0-9]+)', stderr) self.version = int(''.join(r.groups())) / 10 - 60 @@ -132,9 +151,7 @@ mfid = 2 out_arg = '-outputresource:%s;%s' % (exe_name, mfid) args = ['-nologo', '-manifest', str(temp_manifest), out_arg] - log.execute('mt.exe ' + ' '.join(args)) - returncode, stdout, stderr = _run_subprocess('mt.exe', args) - self._handle_error(returncode, stderr, stdout, exe_name) + self._execute_c_compiler('mt.exe', args, exe_name) return exe_name From afa at codespeak.net Thu Jan 22 01:03:19 2009 From: afa at codespeak.net (afa at codespeak.net) Date: Thu, 22 Jan 2009 01:03:19 +0100 (CET) Subject: [pypy-svn] r61211 - pypy/trunk/pypy/translator/platform Message-ID: <20090122000319.CB52E16844E@codespeak.net> Author: afa Date: Thu Jan 22 01:03:19 2009 New Revision: 61211 Modified: pypy/trunk/pypy/translator/platform/__init__.py Log: host_factory is the class used to build the 'host' instance. The next step is to turn some factories into functions that return different kind of Platforms depending on the 'cc' parameter. Modified: pypy/trunk/pypy/translator/platform/__init__.py ============================================================================== --- pypy/trunk/pypy/translator/platform/__init__.py (original) +++ pypy/trunk/pypy/translator/platform/__init__.py Thu Jan 22 01:03:19 2009 @@ -152,32 +152,32 @@ from pypy.translator.platform.linux import Linux, Linux64 import platform if platform.architecture()[0] == '32bit': - host = Linux() + host_factory = Linux else: - host = Linux64() + host_factory = Linux64 elif sys.platform == 'darwin': from pypy.translator.platform.darwin import Darwin - host = Darwin() + host_factory = Darwin elif sys.platform == 'freebsd7': from pypy.translator.platform.freebsd7 import Freebsd7, Freebsd7_64 import platform if platform.architecture()[0] == '32bit': - host = Freebsd7() + host_factory = Freebsd7 else: - host = Freebsd7_64() + host_factory = Freebsd7_64 elif os.name == 'nt': from pypy.translator.platform.windows import Windows - host = Windows() + host_factory = Windows else: # pray from pypy.translator.platform.distutils_platform import DistutilsPlatform - host = DistutilsPlatform() + host_factory = DistutilsPlatform -platform = host +platform = host = host_factory() def pick_platform(new_platform, cc): if new_platform == 'host': - return host.__class__(cc) + return host_factory(cc) elif new_platform == 'maemo': from pypy.translator.platform.maemo import Maemo return Maemo(cc) From afa at codespeak.net Thu Jan 22 01:38:43 2009 From: afa at codespeak.net (afa at codespeak.net) Date: Thu, 22 Jan 2009 01:38:43 +0100 (CET) Subject: [pypy-svn] r61212 - pypy/trunk/pypy/translator/platform Message-ID: <20090122003843.DEBBE16846A@codespeak.net> Author: afa Date: Thu Jan 22 01:38:41 2009 New Revision: 61212 Modified: pypy/trunk/pypy/translator/platform/windows.py Log: Add a Mingw compiler configuration. Select it with translate.py --cc=mingw32 Modified: pypy/trunk/pypy/translator/platform/windows.py ============================================================================== --- pypy/trunk/pypy/translator/platform/windows.py (original) +++ pypy/trunk/pypy/translator/platform/windows.py Thu Jan 22 01:38:41 2009 @@ -5,6 +5,12 @@ from pypy.translator.platform import Platform, posix from pypy.tool import autopath +def Windows(cc=None): + if cc == 'mingw32': + return MingwPlatform(cc) + else: + return MsvcPlatform(cc) + def _get_msvc_env(vsver): try: toolsdir = os.environ['VS%sCOMNTOOLS' % vsver] @@ -56,7 +62,7 @@ msvc_compiler_environ = find_msvc_env() -class Windows(Platform): +class MsvcPlatform(Platform): name = "win32" so_ext = 'dll' exe_ext = 'exe' @@ -120,7 +126,7 @@ return ['/dll'] + args def _link_args_from_eci(self, eci): - args = super(Windows, self)._link_args_from_eci(eci) + args = super(MsvcPlatform, self)._link_args_from_eci(eci) return args + ['/EXPORT:%s' % symbol for symbol in eci.export_symbols] def _compile_c_file(self, cc, cfile, compile_args): @@ -244,3 +250,19 @@ class NMakefile(posix.GnuMakefile): pass # for the moment + + +class MingwPlatform(posix.BasePosix): + name = 'mingw32' + standalone_only = [] + shared_only = [] + cflags = [] + link_flags = [] + so_ext = 'dll' + + def __init__(self, cc=None): + Platform.__init__(self, 'gcc') + + def _args_for_shared(self, args): + return ['-shared'] + args + From afa at codespeak.net Thu Jan 22 01:41:33 2009 From: afa at codespeak.net (afa at codespeak.net) Date: Thu, 22 Jan 2009 01:41:33 +0100 (CET) Subject: [pypy-svn] r61213 - pypy/trunk/pypy/translator/platform Message-ID: <20090122004133.5C2EF16846A@codespeak.net> Author: afa Date: Thu Jan 22 01:41:33 2009 New Revision: 61213 Modified: pypy/trunk/pypy/translator/platform/__init__.py Log: When changing the configuration for the 'host' platform, also change the platform installed in platform.host. Now --cc=mingw uses this compiler at all stages of the translation. Modified: pypy/trunk/pypy/translator/platform/__init__.py ============================================================================== --- pypy/trunk/pypy/translator/platform/__init__.py (original) +++ pypy/trunk/pypy/translator/platform/__init__.py Thu Jan 22 01:41:33 2009 @@ -186,10 +186,13 @@ return DistutilsPlatform() else: raise ValueError("platform = %s" % (new_platform,)) - + def set_platform(new_platform, cc): global platform log.msg("Setting platform to %r cc=%s" % (new_platform,cc)) platform = pick_platform(new_platform, cc) - + + if new_platform == 'host': + global host + host = platform From afa at codespeak.net Thu Jan 22 01:52:38 2009 From: afa at codespeak.net (afa at codespeak.net) Date: Thu, 22 Jan 2009 01:52:38 +0100 (CET) Subject: [pypy-svn] r61214 - pypy/trunk/pypy/rpython/ootypesystem Message-ID: <20090122005238.9F51B16841E@codespeak.net> Author: afa Date: Thu Jan 22 01:52:38 2009 New Revision: 61214 Modified: pypy/trunk/pypy/rpython/ootypesystem/bltregistry.py Log: Python 2.6 performs some nice code checks: SyntaxWarning : assertion is always true, perhaps remove parentheses? Now this assertion may start to raise... Modified: pypy/trunk/pypy/rpython/ootypesystem/bltregistry.py ============================================================================== --- pypy/trunk/pypy/rpython/ootypesystem/bltregistry.py (original) +++ pypy/trunk/pypy/rpython/ootypesystem/bltregistry.py Thu Jan 22 01:52:38 2009 @@ -52,8 +52,9 @@ def load_dict_args(varnames, defs, args): argcount = len(varnames) - assert(argcount < len(defs) + len(args), "Not enough information for describing method") - + assert argcount < len(defs) + len(args), \ + "Not enough information for describing method" + for arg in xrange(1, argcount - len(defs)): assert varnames[arg] in args, "Don't have type for arg %s" % varnames[arg] From afa at codespeak.net Thu Jan 22 01:57:33 2009 From: afa at codespeak.net (afa at codespeak.net) Date: Thu, 22 Jan 2009 01:57:33 +0100 (CET) Subject: [pypy-svn] r61215 - pypy/trunk/pypy/bin Message-ID: <20090122005733.6907D16841E@codespeak.net> Author: afa Date: Thu Jan 22 01:57:32 2009 New Revision: 61215 Modified: pypy/trunk/pypy/bin/py.py Log: Add the --cc option to py.py. I'm not sure it's the best place to put this. The same option also resides pypy/config/translationoption.py, with similar effect, except that py.py always executes on the 'host' platform. Modified: pypy/trunk/pypy/bin/py.py ============================================================================== --- pypy/trunk/pypy/bin/py.py (original) +++ pypy/trunk/pypy/bin/py.py Thu Jan 22 01:57:32 2009 @@ -55,11 +55,19 @@ ''').interphook('pypy_init') +def set_compiler(option, opt, value, parser): + from pypy.translator.platform import set_platform + set_platform('host', value) + def main_(argv=None): starttime = time.time() config, parser = option.get_standard_options() interactiveconfig = Config(cmdline_optiondescr) to_optparse(interactiveconfig, parser=parser) + parser.add_option( + '--cc', type=str, action="callback", + callback=set_compiler, + help="Compiler to use for compiling generated C") args = option.process_options(parser, argv[1:]) if interactiveconfig.verbose: error.RECORD_INTERPLEVEL_TRACEBACK = True From afa at codespeak.net Thu Jan 22 02:10:16 2009 From: afa at codespeak.net (afa at codespeak.net) Date: Thu, 22 Jan 2009 02:10:16 +0100 (CET) Subject: [pypy-svn] r61216 - pypy/trunk/pypy/rlib Message-ID: <20090122011016.E13E416844E@codespeak.net> Author: afa Date: Thu Jan 22 02:10:15 2009 New Revision: 61216 Modified: pypy/trunk/pypy/rlib/_rsocket_rffi.py pypy/trunk/pypy/rlib/rsocket.py Log: Adapt the socket module to the mingw32 compiler. Draw the lines between the WIN32 platform (the Windows XP API), and the MSVC and MINGW compilers (which may interpret differently the C standards) Modified: pypy/trunk/pypy/rlib/_rsocket_rffi.py ============================================================================== --- pypy/trunk/pypy/rlib/_rsocket_rffi.py (original) +++ pypy/trunk/pypy/rlib/_rsocket_rffi.py Thu Jan 22 02:10:15 2009 @@ -5,12 +5,15 @@ from pypy.rpython.lltypesystem.rffi import CCHARP from pypy.rlib.rposix import get_errno as geterrno from pypy.translator.tool.cbuild import ExternalCompilationInfo +from pypy.translator.platform import platform as target_platform from pypy.rlib.rarithmetic import intmask, r_uint import os,sys _POSIX = os.name == "posix" -_MS_WINDOWS = os.name == "nt" +_WIN32 = sys.platform == "win32" +_MSVC = target_platform == "msvc" +_MINGW = target_platform == "mingw32" _SOLARIS = sys.platform == "sunos5" if _POSIX: @@ -40,20 +43,26 @@ if _SOLARIS: libraries = libraries + ('socket', 'nsl') -if _MS_WINDOWS: +if _WIN32: includes = () libraries = ('ws2_32',) calling_conv = 'win' - HEADER = '\n'.join([ + header_lines = [ '#include ', '#include ', # winsock2 defines AF_UNIX, but not sockaddr_un '#undef AF_UNIX', - # these types do not exist on windows - 'typedef int ssize_t;', - 'typedef unsigned __int16 uint16_t;', - 'typedef unsigned __int32 uint32_t;', - ]) + ] + if _MSVC: + header_lines.extend([ + # these types do not exist on windows + 'typedef int ssize_t;', + 'typedef unsigned __int16 uint16_t;', + 'typedef unsigned __int32 uint32_t;', + ]) + else: + includes = ('stdint.h',) + HEADER = '\n'.join(header_lines) COND_HEADER = '' constants = {} @@ -91,8 +100,8 @@ class CConfig: _compilation_info_ = eci # constants - linux = platform.Defined('linux') - MS_WINDOWS = platform.Defined('_WIN32') + linux = platform.Defined('linux') + WIN32 = platform.Defined('_WIN32') O_NONBLOCK = platform.DefinedConstantInteger('O_NONBLOCK') F_GETFL = platform.DefinedConstantInteger('F_GETFL') @@ -219,7 +228,7 @@ setattr(CConfig, name, platform.DefinedConstantInteger(name)) # types -if _MS_WINDOWS: +if _MSVC: socketfd_type = rffi.UINT else: socketfd_type = rffi.INT @@ -298,7 +307,7 @@ [('fd', socketfd_type), ('events', rffi.SHORT), ('revents', rffi.SHORT)]) -if _MS_WINDOWS: +if _WIN32: CConfig.WSAEVENT = platform.SimpleType('WSAEVENT', rffi.VOIDP) CConfig.WSANETWORKEVENTS = platform.Struct( 'struct _WSANETWORKEVENTS', @@ -312,7 +321,7 @@ fd_set = rffi.COpaquePtr('fd_set', compilation_info=eci) -if _MS_WINDOWS: +if _WIN32: CConfig.WSAData = platform.Struct('struct WSAData', [('wVersion', rffi.USHORT), ('wHighVersion', rffi.USHORT), @@ -365,10 +374,10 @@ EAFNOSUPPORT = cConfig.EAFNOSUPPORT or cConfig.WSAEAFNOSUPPORT linux = cConfig.linux -MS_WINDOWS = cConfig.MS_WINDOWS -assert MS_WINDOWS == _MS_WINDOWS +WIN32 = cConfig.WIN32 +assert WIN32 == _WIN32 -if MS_WINDOWS: +if WIN32: def invalid_socket(fd): return fd == INVALID_SOCKET INVALID_SOCKET = cConfig.INVALID_SOCKET @@ -396,7 +405,7 @@ if _POSIX: nfds_t = cConfig.nfds_t pollfd = cConfig.pollfd -if MS_WINDOWS: +if WIN32: WSAEVENT = cConfig.WSAEVENT WSANETWORKEVENTS = cConfig.WSANETWORKEVENTS timeval = cConfig.timeval @@ -429,14 +438,14 @@ socket = external('socket', [rffi.INT, rffi.INT, rffi.INT], socketfd_type) -if MS_WINDOWS: +if WIN32: socketclose = external('closesocket', [socketfd_type], rffi.INT) else: socketclose = external('close', [socketfd_type], rffi.INT) socketconnect = external('connect', [socketfd_type, sockaddr_ptr, socklen_t], rffi.INT) -if not MS_WINDOWS: +if not WIN32: getaddrinfo = external('getaddrinfo', [CCHARP, CCHARP, addrinfo_ptr, lltype.Ptr(rffi.CArray(addrinfo_ptr))], rffi.INT) @@ -500,7 +509,7 @@ socketpair = external('socketpair', [rffi.INT, rffi.INT, rffi.INT, lltype.Ptr(socketpair_t)], rffi.INT) -if _MS_WINDOWS: +if _WIN32: ioctlsocket = external('ioctlsocket', [socketfd_type, rffi.LONG, rffi.ULONGP], rffi.INT) @@ -520,7 +529,7 @@ poll = external('poll', [lltype.Ptr(pollfdarray), nfds_t, rffi.INT], rffi.INT) -elif MS_WINDOWS: +elif WIN32: # # The following is for pypy.rlib.rpoll # @@ -544,7 +553,7 @@ lltype.Ptr(WSANETWORKEVENTS)], rffi.INT) -if MS_WINDOWS: +if WIN32: WSAData = cConfig.WSAData WSAStartup = external('WSAStartup', [rffi.INT, lltype.Ptr(WSAData)], rffi.INT) Modified: pypy/trunk/pypy/rlib/rsocket.py ============================================================================== --- pypy/trunk/pypy/rlib/rsocket.py (original) +++ pypy/trunk/pypy/rlib/rsocket.py Thu Jan 22 02:10:15 2009 @@ -27,7 +27,7 @@ constants = _c.constants locals().update(constants) # Define constants from _c -if _c.MS_WINDOWS: +if _c.WIN32: def rsocket_startup(): wsadata = lltype.malloc(_c.WSAData, flavor='raw', zero=True) res = _c.WSAStartup(1, wsadata) From afa at codespeak.net Thu Jan 22 02:21:41 2009 From: afa at codespeak.net (afa at codespeak.net) Date: Thu, 22 Jan 2009 02:21:41 +0100 (CET) Subject: [pypy-svn] r61217 - pypy/trunk/pypy/translator/platform Message-ID: <20090122012141.915C516849B@codespeak.net> Author: afa Date: Thu Jan 22 02:21:39 2009 New Revision: 61217 Modified: pypy/trunk/pypy/translator/platform/windows.py Log: 'msvc' is the platform name. Modified: pypy/trunk/pypy/translator/platform/windows.py ============================================================================== --- pypy/trunk/pypy/translator/platform/windows.py (original) +++ pypy/trunk/pypy/translator/platform/windows.py Thu Jan 22 02:21:39 2009 @@ -63,7 +63,7 @@ msvc_compiler_environ = find_msvc_env() class MsvcPlatform(Platform): - name = "win32" + name = "msvc" so_ext = 'dll' exe_ext = 'exe' From afa at codespeak.net Thu Jan 22 10:10:19 2009 From: afa at codespeak.net (afa at codespeak.net) Date: Thu, 22 Jan 2009 10:10:19 +0100 (CET) Subject: [pypy-svn] r61218 - pypy/trunk/pypy/rlib Message-ID: <20090122091019.AE1DD168449@codespeak.net> Author: afa Date: Thu Jan 22 10:10:18 2009 New Revision: 61218 Modified: pypy/trunk/pypy/rlib/libffi.py Log: Fix translation of _rawffi on Windows Modified: pypy/trunk/pypy/rlib/libffi.py ============================================================================== --- pypy/trunk/pypy/rlib/libffi.py (original) +++ pypy/trunk/pypy/rlib/libffi.py Thu Jan 22 10:10:18 2009 @@ -22,15 +22,41 @@ from pypy.translator.platform import platform # maaaybe isinstance here would be better. Think -_MS_WINDOWS = platform.name == "win32" +_MSVC = platform.name == "msvc" +_MINGW = platform.name == "mingw32" +_WIN32 = _MSVC or _MINGW _MAC_OS = platform.name == "darwin" _FREEBSD_7 = platform.name == "freebsd7" -if _MS_WINDOWS: +if _WIN32: from pypy.rlib import rwin32 -if not _MS_WINDOWS: - includes = ['dlfcn.h', 'ffi.h'] +if _WIN32: + separate_module_sources = [''' + #include + + /* Get the module where the "fopen" function resides in */ + HANDLE get_libc_handle() { + MEMORY_BASIC_INFORMATION mi; + char buf[1000]; + memset(&mi, 0, sizeof(mi)); + + if( !VirtualQueryEx(GetCurrentProcess(), &fopen, &mi, sizeof(mi)) ) + return 0; + + GetModuleFileName((HMODULE)mi.AllocationBase, buf, 500); + + return (HMODULE)mi.AllocationBase; + } + '''] +else: + separate_module_sources = [] + +if not _MSVC: + if _MINGW: + includes = ['windows.h', 'ffi.h'] + else: + includes = ['dlfcn.h', 'ffi.h'] include_dirs = platform.include_dirs_for_libffi() if _MAC_OS: @@ -38,7 +64,7 @@ else: pre_include_bits = [] - if _FREEBSD_7: + if _FREEBSD_7 or _MINGW: libraries = ['ffi'] else: libraries = ['ffi', 'dl'] @@ -47,6 +73,7 @@ pre_include_bits = pre_include_bits, includes = includes, libraries = libraries, + separate_module_sources = separate_module_sources, include_dirs = platform.include_dirs_for_libffi(), library_dirs = platform.library_dirs_for_libffi(), ) @@ -57,20 +84,7 @@ includes = ['ffi.h', 'windows.h'], libraries = ['kernel32'], include_dirs = [libffidir], - separate_module_sources = [''' - #include - - /* Get the module where the "fopen" function resides in */ - HANDLE get_libc_handle() { - MEMORY_BASIC_INFORMATION mi; - memset(&mi, 0, sizeof(mi)); - - if( !VirtualQueryEx(GetCurrentProcess(), &fopen, &mi, sizeof(mi)) ) - return 0; - - return (HMODULE)mi.AllocationBase; - } - '''], + separate_module_sources = separate_module_sources, separate_module_files = [libffidir.join('ffi.c'), libffidir.join('prep_cif.c'), libffidir.join('win32.c'), @@ -93,7 +107,7 @@ FFI_OK = rffi_platform.ConstantInteger('FFI_OK') FFI_BAD_TYPEDEF = rffi_platform.ConstantInteger('FFI_BAD_TYPEDEF') FFI_DEFAULT_ABI = rffi_platform.ConstantInteger('FFI_DEFAULT_ABI') - if _MS_WINDOWS: + if _WIN32: FFI_STDCALL = rffi_platform.ConstantInteger('FFI_STDCALL') FFI_TYPE_STRUCT = rffi_platform.ConstantInteger('FFI_TYPE_STRUCT') @@ -182,7 +196,7 @@ def winexternal(name, args, result): return rffi.llexternal(name, args, result, compilation_info=eci, calling_conv='win') -if not _MS_WINDOWS: +if not _WIN32: c_dlopen = external('dlopen', [rffi.CCHARP, rffi.INT], rffi.VOIDP) c_dlclose = external('dlclose', [rffi.VOIDP], rffi.INT) c_dlerror = external('dlerror', [], rffi.CCHARP) @@ -233,7 +247,7 @@ libc_name = ctypes.util.find_library('c') -if _MS_WINDOWS: +if _WIN32: def dlopen(name): res = rwin32.LoadLibrary(name) if not res: @@ -261,12 +275,14 @@ get_libc_handle = external('get_libc_handle', [], rwin32.HANDLE) libc_name = rwin32.GetModuleFileName(get_libc_handle()) - + assert "msvcr" in libc_name.lower(), \ + "Suspect msvcrt library: %s" % (libc_name,) + FFI_OK = cConfig.FFI_OK FFI_BAD_TYPEDEF = cConfig.FFI_BAD_TYPEDEF FFI_DEFAULT_ABI = rffi.cast(rffi.USHORT, cConfig.FFI_DEFAULT_ABI) -if _MS_WINDOWS: +if _WIN32: FFI_STDCALL = rffi.cast(rffi.USHORT, cConfig.FFI_STDCALL) FFI_TYPE_STRUCT = rffi.cast(rffi.USHORT, cConfig.FFI_TYPE_STRUCT) FFI_CIFP = rffi.COpaquePtr('ffi_cif', compilation_info=eci) @@ -377,12 +393,12 @@ self.ll_argtypes[i] = argtypes[i] self.ll_cif = lltype.malloc(FFI_CIFP.TO, flavor='raw') - if _MS_WINDOWS and (flags & FUNCFLAG_CDECL == 0): + if _WIN32 and (flags & FUNCFLAG_CDECL == 0): cc = FFI_STDCALL else: cc = FFI_DEFAULT_ABI - if _MS_WINDOWS: + if _MSVC: # This little trick works correctly with MSVC. # It returns small structures in registers if r_uint(restype.c_type) == FFI_TYPE_STRUCT: From afa at codespeak.net Thu Jan 22 10:25:57 2009 From: afa at codespeak.net (afa at codespeak.net) Date: Thu, 22 Jan 2009 10:25:57 +0100 (CET) Subject: [pypy-svn] r61219 - pypy/trunk/pypy/rlib Message-ID: <20090122092557.2CC7B168449@codespeak.net> Author: afa Date: Thu Jan 22 10:25:55 2009 New Revision: 61219 Modified: pypy/trunk/pypy/rlib/_rsocket_rffi.py Log: Fix a typo which breaks translation on win32 Modified: pypy/trunk/pypy/rlib/_rsocket_rffi.py ============================================================================== --- pypy/trunk/pypy/rlib/_rsocket_rffi.py (original) +++ pypy/trunk/pypy/rlib/_rsocket_rffi.py Thu Jan 22 10:25:55 2009 @@ -12,8 +12,8 @@ _POSIX = os.name == "posix" _WIN32 = sys.platform == "win32" -_MSVC = target_platform == "msvc" -_MINGW = target_platform == "mingw32" +_MSVC = target_platform.name == "msvc" +_MINGW = target_platform.name == "mingw32" _SOLARIS = sys.platform == "sunos5" if _POSIX: @@ -55,7 +55,7 @@ ] if _MSVC: header_lines.extend([ - # these types do not exist on windows + # these types do not exist on microsoft compilers 'typedef int ssize_t;', 'typedef unsigned __int16 uint16_t;', 'typedef unsigned __int32 uint32_t;', From fijal at codespeak.net Thu Jan 22 10:34:17 2009 From: fijal at codespeak.net (fijal at codespeak.net) Date: Thu, 22 Jan 2009 10:34:17 +0100 (CET) Subject: [pypy-svn] r61220 - pypy/trunk/lib-python Message-ID: <20090122093417.85D5A168460@codespeak.net> Author: fijal Date: Thu Jan 22 10:34:15 2009 New Revision: 61220 Modified: pypy/trunk/lib-python/conftest.py Log: we need to have RegrTest for each file starting with test_ anyway... Modified: pypy/trunk/lib-python/conftest.py ============================================================================== --- pypy/trunk/lib-python/conftest.py (original) +++ pypy/trunk/lib-python/conftest.py Thu Jan 22 10:34:15 2009 @@ -294,6 +294,7 @@ RegrTest('test_mmap.py'), RegrTest('test_module.py', core=True), RegrTest('test_multibytecodec.py', skip="unsupported codecs"), + RegrTest('test_multibytecodec.py_support', skip="not a test"), RegrTest('test_multifile.py'), RegrTest('test_mutants.py', core="possibly"), RegrTest('test_netrc.py'), From fijal at codespeak.net Thu Jan 22 11:16:28 2009 From: fijal at codespeak.net (fijal at codespeak.net) Date: Thu, 22 Jan 2009 11:16:28 +0100 (CET) Subject: [pypy-svn] r61221 - pypy/extradoc/talk/wroclaw2009 Message-ID: <20090122101628.D54BB168460@codespeak.net> Author: fijal Date: Thu Jan 22 11:16:25 2009 New Revision: 61221 Modified: pypy/extradoc/talk/wroclaw2009/talk.pdf pypy/extradoc/talk/wroclaw2009/talk.txt Log: more progress Modified: pypy/extradoc/talk/wroclaw2009/talk.pdf ============================================================================== Binary files. No diff available. Modified: pypy/extradoc/talk/wroclaw2009/talk.txt ============================================================================== --- pypy/extradoc/talk/wroclaw2009/talk.txt (original) +++ pypy/extradoc/talk/wroclaw2009/talk.txt Thu Jan 22 11:16:25 2009 @@ -93,6 +93,12 @@ .. image:: architecture.png :scale: 60 +PyPy - high level architecture (2) +================================== + +.. image:: architecture2.png + :scale: 60 + PyPy - implementation language ============================== @@ -106,3 +112,77 @@ * ... but better than C +PyPy - why so complex? +======================= + +* because we control translation toolchain, + we can have work done for us + +* nice example - garbage collection + +* hopefully even nicer example - JIT + +Python interpreter status +========================= + +* almost as fast as CPython (from 0.8x to 4x slower) + +* it's 99% compatible with CPython + +* comes with majority of CPython's stdlib (including ctypes) + +PyPy - garbage collection +========================= + +* written in RPython + +* completely separated from interpreter + +* nicely testable on top of Python + +* faster than CPython ones + +* very easy to write new ones + +JIT - idea +========== + +* dynamic compilation is a way to go for dynamic + languages + +* examples: psyco, strongtalk, modern JavaScript engines + +* python is a very complex language, far more complex + than JavaScript + +* hence, JIT generator is required! + +JIT - status +============ + +* 4th generation of JIT in PyPy + +* 1st generation was able to speed up examples + up to 60x (same as psyco) + +* not ready yet + +* based on tracing JIT by Michael Franz + (the same paper as tracemonkey is based on) + +JIT - the main idea +=================== + +* we find hotspot loops, which are executed + often enough + +* we "trace" those loops and produce machine code + +* next time we enter the loop, we execute fast + machine code + +* we do this on interpreter source level, + instead of doing that on python's source + code + + From fijal at codespeak.net Thu Jan 22 11:22:47 2009 From: fijal at codespeak.net (fijal at codespeak.net) Date: Thu, 22 Jan 2009 11:22:47 +0100 (CET) Subject: [pypy-svn] r61222 - pypy/extradoc/talk/wroclaw2009 Message-ID: <20090122102247.F1AF1168460@codespeak.net> Author: fijal Date: Thu Jan 22 11:22:47 2009 New Revision: 61222 Added: pypy/extradoc/talk/wroclaw2009/architecture.png (contents, props changed) pypy/extradoc/talk/wroclaw2009/architecture2.png (contents, props changed) pypy/extradoc/talk/wroclaw2009/happy_snake.jpg (contents, props changed) Modified: pypy/extradoc/talk/wroclaw2009/talk.txt Log: pics Added: pypy/extradoc/talk/wroclaw2009/architecture.png ============================================================================== Binary file. No diff available. Added: pypy/extradoc/talk/wroclaw2009/architecture2.png ============================================================================== Binary file. No diff available. Added: pypy/extradoc/talk/wroclaw2009/happy_snake.jpg ============================================================================== Binary file. No diff available. Modified: pypy/extradoc/talk/wroclaw2009/talk.txt ============================================================================== --- pypy/extradoc/talk/wroclaw2009/talk.txt (original) +++ pypy/extradoc/talk/wroclaw2009/talk.txt Thu Jan 22 11:22:47 2009 @@ -99,6 +99,19 @@ .. image:: architecture2.png :scale: 60 +An example of benefit +===================== + +* Python has complicated semantics + +* Python guarantees that it won't segfault on + a stack exhaustion + +* CPython includes some stack checks in the source, but they + don't catch every case + +* We include it automatically so all cases are guaranteed to be covered + PyPy - implementation language ============================== @@ -170,6 +183,8 @@ * based on tracing JIT by Michael Franz (the same paper as tracemonkey is based on) +* written in RPython! + JIT - the main idea =================== @@ -185,4 +200,22 @@ instead of doing that on python's source code +Project future +============== + +* more JIT + +* more funding + +* 1.1 release this spring + +* sprint in Wroclaw 7-14 February + +Q&A +=== + +* this slides: http://codespeak.net/svn/pypy/extradoc/talk/wroclaw2009/talk.pdf + +* blog: http://morepypy.blogspot.com +* project webpage: http://codespeak.net/pypy From fijal at codespeak.net Thu Jan 22 11:50:26 2009 From: fijal at codespeak.net (fijal at codespeak.net) Date: Thu, 22 Jan 2009 11:50:26 +0100 (CET) Subject: [pypy-svn] r61223 - pypy/trunk/lib-python Message-ID: <20090122105026.DE5D61684E6@codespeak.net> Author: fijal Date: Thu Jan 22 11:50:24 2009 New Revision: 61223 Modified: pypy/trunk/lib-python/conftest.py Log: argh Modified: pypy/trunk/lib-python/conftest.py ============================================================================== --- pypy/trunk/lib-python/conftest.py (original) +++ pypy/trunk/lib-python/conftest.py Thu Jan 22 11:50:24 2009 @@ -294,7 +294,7 @@ RegrTest('test_mmap.py'), RegrTest('test_module.py', core=True), RegrTest('test_multibytecodec.py', skip="unsupported codecs"), - RegrTest('test_multibytecodec.py_support', skip="not a test"), + RegrTest('test_multibytecodec_support.py', skip="not a test"), RegrTest('test_multifile.py'), RegrTest('test_mutants.py', core="possibly"), RegrTest('test_netrc.py'), From fijal at codespeak.net Thu Jan 22 13:03:23 2009 From: fijal at codespeak.net (fijal at codespeak.net) Date: Thu, 22 Jan 2009 13:03:23 +0100 (CET) Subject: [pypy-svn] r61230 - pypy/extradoc/talk/wroclaw2009 Message-ID: <20090122120323.64AC01684F4@codespeak.net> Author: fijal Date: Thu Jan 22 13:03:22 2009 New Revision: 61230 Modified: pypy/extradoc/talk/wroclaw2009/talk.txt Log: minor updates Modified: pypy/extradoc/talk/wroclaw2009/talk.txt ============================================================================== --- pypy/extradoc/talk/wroclaw2009/talk.txt (original) +++ pypy/extradoc/talk/wroclaw2009/talk.txt Thu Jan 22 13:03:22 2009 @@ -144,6 +144,8 @@ * comes with majority of CPython's stdlib (including ctypes) +* able to run django, twisted, pylons... + PyPy - garbage collection ========================= @@ -178,6 +180,9 @@ * 1st generation was able to speed up examples up to 60x (same as psyco) +* psyco (0th generation) was able to speedup + python programs up to the same as gcc -O0 + * not ready yet * based on tracing JIT by Michael Franz @@ -214,7 +219,8 @@ Q&A === -* this slides: http://codespeak.net/svn/pypy/extradoc/talk/wroclaw2009/talk.pdf +* this slides: http://codespeak.net/svn/pypy/extradoc/talk/ + wroclaw2009/talk.pdf * blog: http://morepypy.blogspot.com From fijal at codespeak.net Thu Jan 22 14:15:54 2009 From: fijal at codespeak.net (fijal at codespeak.net) Date: Thu, 22 Jan 2009 14:15:54 +0100 (CET) Subject: [pypy-svn] r61231 - pypy/extradoc/talk/wroclaw2009 Message-ID: <20090122131554.37C8E1684FA@codespeak.net> Author: fijal Date: Thu Jan 22 14:15:50 2009 New Revision: 61231 Modified: pypy/extradoc/talk/wroclaw2009/talk.txt Log: update Modified: pypy/extradoc/talk/wroclaw2009/talk.txt ============================================================================== --- pypy/extradoc/talk/wroclaw2009/talk.txt (original) +++ pypy/extradoc/talk/wroclaw2009/talk.txt Thu Jan 22 14:15:50 2009 @@ -99,19 +99,6 @@ .. image:: architecture2.png :scale: 60 -An example of benefit -===================== - -* Python has complicated semantics - -* Python guarantees that it won't segfault on - a stack exhaustion - -* CPython includes some stack checks in the source, but they - don't catch every case - -* We include it automatically so all cases are guaranteed to be covered - PyPy - implementation language ============================== @@ -121,13 +108,31 @@ * static enough to compile to efficient code +* static enough to be able to analyze it + * not necessarily a nice language * ... but better than C +An example of benefit +===================== + +* Python has complicated semantics + +* Python guarantees that it won't segfault on + a stack exhaustion + +* CPython includes some stack checks in the source, but they + don't catch every case + +* We include it automatically so all cases are guaranteed to be covered + PyPy - why so complex? ======================= +* interpreter is just a relatively small piece + of code + * because we control translation toolchain, we can have work done for us @@ -159,7 +164,7 @@ * very easy to write new ones -JIT - idea +JIT - why? ========== * dynamic compilation is a way to go for dynamic @@ -205,6 +210,22 @@ instead of doing that on python's source code +JIT - a zoom into tracing +========================= + +* first, hot spot is found + +* then, it's traced by a jit to find out + what operations really occured + +* a loop is closed by a jump back + +* assembler code from list of operations + performed is generated + +* there are insterted guards, which check + for branches + Project future ============== From arigo at codespeak.net Thu Jan 22 15:08:24 2009 From: arigo at codespeak.net (arigo at codespeak.net) Date: Thu, 22 Jan 2009 15:08:24 +0100 (CET) Subject: [pypy-svn] r61232 - in pypy/trunk/pypy/lib: app_test test2 Message-ID: <20090122140824.01E23168449@codespeak.net> Author: arigo Date: Thu Jan 22 15:08:23 2009 New Revision: 61232 Added: pypy/trunk/pypy/lib/app_test/test_hashlib.py (contents, props changed) Removed: pypy/trunk/pypy/lib/test2/test_hashlib.py Log: Kill the complicated app-level logic and just run the test directly. Added: pypy/trunk/pypy/lib/app_test/test_hashlib.py ============================================================================== --- (empty file) +++ pypy/trunk/pypy/lib/app_test/test_hashlib.py Thu Jan 22 15:08:23 2009 @@ -0,0 +1,4 @@ +from pypy.lib import hashlib, _hashlib + +def test_unicode(): + assert isinstance(hashlib.new('sha1', u'xxx'), _hashlib.hash) From fijal at codespeak.net Thu Jan 22 15:08:43 2009 From: fijal at codespeak.net (fijal at codespeak.net) Date: Thu, 22 Jan 2009 15:08:43 +0100 (CET) Subject: [pypy-svn] r61233 - in pypy/trunk/pypy/module/_codecs: . test Message-ID: <20090122140843.80B6A1684E1@codespeak.net> Author: fijal Date: Thu Jan 22 15:08:42 2009 New Revision: 61233 Modified: pypy/trunk/pypy/module/_codecs/app_codecs.py pypy/trunk/pypy/module/_codecs/test/test_codecs.py Log: a test and a fix Modified: pypy/trunk/pypy/module/_codecs/app_codecs.py ============================================================================== --- pypy/trunk/pypy/module/_codecs/app_codecs.py (original) +++ pypy/trunk/pypy/module/_codecs/app_codecs.py Thu Jan 22 15:08:42 2009 @@ -207,7 +207,7 @@ res = ''.join(res) return res, len(data) -def charmap_decode( data, errors='strict', mapping=None): +def charmap_decode( data, errors='strict', mapping='latin-1'): """None """ res = PyUnicode_DecodeCharmap(data, mapping, errors) @@ -856,9 +856,9 @@ size = len(s) ## /* Default to Latin-1 */ - if (mapping == None): + if (mapping == 'latin-1'): import _codecs - return _codecs.latin_1_decode(s, size, errors)[0] + return _codecs.latin_1_decode(s, errors)[0] if (size == 0): return u'' Modified: pypy/trunk/pypy/module/_codecs/test/test_codecs.py ============================================================================== --- pypy/trunk/pypy/module/_codecs/test/test_codecs.py (original) +++ pypy/trunk/pypy/module/_codecs/test/test_codecs.py Thu Jan 22 15:08:42 2009 @@ -496,8 +496,16 @@ def test_charmap_encode(self): assert 'xxx'.encode('charmap') == 'xxx' + def test_charmap_decode(self): + assert 'foo'.decode('charmap') == 'foo' + class TestDirect: def test_charmap_encode(self): from pypy.module._codecs.app_codecs import charmap_encode - assert charmap_encode('xxx') == ('xxx', 3) - assert charmap_encode('xxx', 'strict', {ord('x'): 'XX'}) == ('XXXXXX', 6) + assert charmap_encode(u'xxx') == ('xxx', 3) + assert charmap_encode(u'xxx', 'strict', {ord('x'): 'XX'}) == ('XXXXXX', 6) + + def test_charmap_decode(self): + from pypy.module._codecs.app_codecs import charmap_decode + assert charmap_decode('xxx') == ('xxx', 3) + assert charmap_decode('xxx', 'strict', {ord('x'): u'XX'}) == ('XXXXXX', 3) From arigo at codespeak.net Thu Jan 22 15:29:36 2009 From: arigo at codespeak.net (arigo at codespeak.net) Date: Thu, 22 Jan 2009 15:29:36 +0100 (CET) Subject: [pypy-svn] r61235 - pypy/trunk/lib-python/modified-2.5.2 Message-ID: <20090122142936.9C32016844A@codespeak.net> Author: arigo Date: Thu Jan 22 15:29:36 2009 New Revision: 61235 Added: pypy/trunk/lib-python/modified-2.5.2/gettext.py - copied, changed from r61233, pypy/trunk/lib-python/2.5.2/gettext.py Log: Remove the default value of find(localedir=...) when running on PyPy. This default value is a bit useless, and it is computed based on sys.prefix. Copied: pypy/trunk/lib-python/modified-2.5.2/gettext.py (from r61233, pypy/trunk/lib-python/2.5.2/gettext.py) ============================================================================== --- pypy/trunk/lib-python/2.5.2/gettext.py (original) +++ pypy/trunk/lib-python/modified-2.5.2/gettext.py Thu Jan 22 15:29:36 2009 @@ -55,7 +55,11 @@ 'dgettext', 'dngettext', 'gettext', 'ngettext', ] -_default_localedir = os.path.join(sys.prefix, 'share', 'locale') +# PyPy: we cannot provide a sensible default because there is no sys.prefix +if hasattr(sys, 'prefix'): + _default_localedir = os.path.join(sys.prefix, 'share', 'locale') +else: + _default_localedir = None def test(condition, true, false): @@ -422,6 +426,8 @@ # Get some reasonable defaults for arguments that were not supplied if localedir is None: localedir = _default_localedir + if localedir is None: + raise TypeError("'localedir' argument required on PyPy") if languages is None: languages = [] for envar in ('LANGUAGE', 'LC_ALL', 'LC_MESSAGES', 'LANG'): From fijal at codespeak.net Thu Jan 22 15:36:00 2009 From: fijal at codespeak.net (fijal at codespeak.net) Date: Thu, 22 Jan 2009 15:36:00 +0100 (CET) Subject: [pypy-svn] r61237 - pypy/trunk/lib-python/modified-2.5.2/test Message-ID: <20090122143600.D8C191684FB@codespeak.net> Author: fijal Date: Thu Jan 22 15:36:00 2009 New Revision: 61237 Modified: pypy/trunk/lib-python/modified-2.5.2/test/test_file.py Log: this test looks bogus anyway, but let's skip it if stdin is not a tty Modified: pypy/trunk/lib-python/modified-2.5.2/test/test_file.py ============================================================================== --- pypy/trunk/lib-python/modified-2.5.2/test/test_file.py (original) +++ pypy/trunk/lib-python/modified-2.5.2/test/test_file.py Thu Jan 22 15:36:00 2009 @@ -140,14 +140,15 @@ self.fail('%r is an invalid file mode' % mode) def testStdin(self): - # This causes the interpreter to exit on OSF1 v5.1. - if sys.platform != 'osf1V5': - self.assertRaises(IOError, sys.stdin.seek, -1) - else: - print >>sys.__stdout__, ( - ' Skipping sys.stdin.seek(-1), it may crash the interpreter.' - ' Test manually.') - self.assertRaises(IOError, sys.stdin.truncate) + if os.isatty(sys.stdin.fileno()): + # This causes the interpreter to exit on OSF1 v5.1. + if sys.platform != 'osf1V5': + self.assertRaises(IOError, sys.stdin.seek, -1) + else: + print >>sys.__stdout__, ( + ' Skipping sys.stdin.seek(-1), it may crash the interpreter.' + ' Test manually.') + self.assertRaises(IOError, sys.stdin.truncate) def testUnicodeOpen(self): # verify repr works for unicode too From arigo at codespeak.net Thu Jan 22 15:54:49 2009 From: arigo at codespeak.net (arigo at codespeak.net) Date: Thu, 22 Jan 2009 15:54:49 +0100 (CET) Subject: [pypy-svn] r61238 - pypy/trunk/lib-python/modified-2.5.2 Message-ID: <20090122145449.A790E168501@codespeak.net> Author: arigo Date: Thu Jan 22 15:54:49 2009 New Revision: 61238 Modified: pypy/trunk/lib-python/modified-2.5.2/gettext.py Log: Raising an exception is too strong. Instead, just returns None or an empty list as appropriate. Modified: pypy/trunk/lib-python/modified-2.5.2/gettext.py ============================================================================== --- pypy/trunk/lib-python/modified-2.5.2/gettext.py (original) +++ pypy/trunk/lib-python/modified-2.5.2/gettext.py Thu Jan 22 15:54:49 2009 @@ -426,8 +426,6 @@ # Get some reasonable defaults for arguments that were not supplied if localedir is None: localedir = _default_localedir - if localedir is None: - raise TypeError("'localedir' argument required on PyPy") if languages is None: languages = [] for envar in ('LANGUAGE', 'LC_ALL', 'LC_MESSAGES', 'LANG'): @@ -448,6 +446,8 @@ result = [] else: result = None + if localedir is None: # PyPy only: no default + return result for lang in nelangs: if lang == 'C': break From arigo at codespeak.net Thu Jan 22 15:59:05 2009 From: arigo at codespeak.net (arigo at codespeak.net) Date: Thu, 22 Jan 2009 15:59:05 +0100 (CET) Subject: [pypy-svn] r61239 - pypy/trunk/lib-python/modified-2.5.2 Message-ID: <20090122145905.6D8911684E0@codespeak.net> Author: arigo Date: Thu Jan 22 15:59:05 2009 New Revision: 61239 Modified: pypy/trunk/lib-python/modified-2.5.2/pydoc.py Log: Remove the dependency of pydoc on sys.prefix. Modified: pypy/trunk/lib-python/modified-2.5.2/pydoc.py ============================================================================== --- pypy/trunk/lib-python/modified-2.5.2/pydoc.py (original) +++ pypy/trunk/lib-python/modified-2.5.2/pydoc.py Thu Jan 22 15:59:05 2009 @@ -1627,14 +1627,17 @@ self.docdir = None execdir = os.path.dirname(sys.executable) homedir = os.environ.get('PYTHONHOME') - for dir in [os.environ.get('PYTHONDOCS'), - homedir and os.path.join(homedir, 'doc'), - os.path.join(execdir, 'doc'), - '/usr/doc/python-docs-' + split(sys.version)[0], - '/usr/doc/python-' + split(sys.version)[0], - '/usr/doc/python-docs-' + sys.version[:3], - '/usr/doc/python-' + sys.version[:3], - os.path.join(sys.prefix, 'Resources/English.lproj/Documentation')]: + dirs = [os.environ.get('PYTHONDOCS'), + homedir and os.path.join(homedir, 'doc'), + os.path.join(execdir, 'doc'), + '/usr/doc/python-docs-' + split(sys.version)[0], + '/usr/doc/python-' + split(sys.version)[0], + '/usr/doc/python-docs-' + sys.version[:3], + '/usr/doc/python-' + sys.version[:3]] + if hasattr(sys, 'prefix'): + dirs.append(os.path.join(sys.prefix, + 'Resources/English.lproj/Documentation')) + for dir in dirs: if dir and os.path.isdir(os.path.join(dir, 'lib')): self.docdir = dir From arigo at codespeak.net Thu Jan 22 16:03:10 2009 From: arigo at codespeak.net (arigo at codespeak.net) Date: Thu, 22 Jan 2009 16:03:10 +0100 (CET) Subject: [pypy-svn] r61240 - pypy/trunk/lib-python/modified-2.5.2 Message-ID: <20090122150310.D5CE21684F2@codespeak.net> Author: arigo Date: Thu Jan 22 16:03:10 2009 New Revision: 61240 Added: pypy/trunk/lib-python/modified-2.5.2/trace.py - copied, changed from r61238, pypy/trunk/lib-python/2.5.2/trace.py Log: Only support the $prefix and $exec_prefix command-line arguments to trace.py if we are running on CPython. Copied: pypy/trunk/lib-python/modified-2.5.2/trace.py (from r61238, pypy/trunk/lib-python/2.5.2/trace.py) ============================================================================== --- pypy/trunk/lib-python/2.5.2/trace.py (original) +++ pypy/trunk/lib-python/modified-2.5.2/trace.py Thu Jan 22 16:03:10 2009 @@ -737,12 +737,14 @@ s = os.path.expandvars(s) # should I also call expanduser? (after all, could use $HOME) - s = s.replace("$prefix", - os.path.join(sys.prefix, "lib", - "python" + sys.version[:3])) - s = s.replace("$exec_prefix", - os.path.join(sys.exec_prefix, "lib", - "python" + sys.version[:3])) + if hasattr(sys, 'prefix'): + s = s.replace("$prefix", + os.path.join(sys.prefix, "lib", + "python" + sys.version[:3])) + s = s.replace("$exec_prefix", + os.path.join(sys.exec_prefix, "lib", + "python" + sys.version[:3])) + s = os.path.normpath(s) ignore_dirs.append(s) continue From arigo at codespeak.net Thu Jan 22 16:06:08 2009 From: arigo at codespeak.net (arigo at codespeak.net) Date: Thu, 22 Jan 2009 16:06:08 +0100 (CET) Subject: [pypy-svn] r61241 - pypy/trunk/lib-python/modified-2.5.2/test Message-ID: <20090122150608.05B001684F2@codespeak.net> Author: arigo Date: Thu Jan 22 16:06:08 2009 New Revision: 61241 Added: pypy/trunk/lib-python/modified-2.5.2/test/regrtest.py - copied, changed from r61240, pypy/trunk/lib-python/2.5.2/test/regrtest.py Log: Fix for the 'trace' mode of regrtest.py Copied: pypy/trunk/lib-python/modified-2.5.2/test/regrtest.py (from r61240, pypy/trunk/lib-python/2.5.2/test/regrtest.py) ============================================================================== --- pypy/trunk/lib-python/2.5.2/test/regrtest.py (original) +++ pypy/trunk/lib-python/modified-2.5.2/test/regrtest.py Thu Jan 22 16:06:08 2009 @@ -348,8 +348,11 @@ random.shuffle(tests) if trace: import trace - tracer = trace.Trace(ignoredirs=[sys.prefix, sys.exec_prefix], - trace=False, count=True) + if hasattr(sys, 'prefix'): + ignoredirs = [sys.prefix, sys.exec_prefix] + else: + ignoredirs = [sys.pypy_prefix] # PyPy only + tracer = trace.Trace(ignoredirs=ignoredirs, trace=False, count=True) test_support.verbose = verbose # Tell tests to be moderately quiet test_support.use_resources = use_resources save_modules = sys.modules.keys() From antocuni at codespeak.net Thu Jan 22 16:07:41 2009 From: antocuni at codespeak.net (antocuni at codespeak.net) Date: Thu, 22 Jan 2009 16:07:41 +0100 (CET) Subject: [pypy-svn] r61242 - in pypy/trunk: lib-python pypy/module/_codecs pypy/module/_codecs/test Message-ID: <20090122150741.B9B6E1684F5@codespeak.net> Author: antocuni Date: Thu Jan 22 16:07:41 2009 New Revision: 61242 Modified: pypy/trunk/lib-python/failure_list.txt pypy/trunk/pypy/module/_codecs/app_codecs.py pypy/trunk/pypy/module/_codecs/test/test_codecs.py Log: fix the 'start' attribute of this kind of UnicodeDecodeError. This bad behaviour triggered a failure in lib-python/test_codecs Modified: pypy/trunk/lib-python/failure_list.txt ============================================================================== --- pypy/trunk/lib-python/failure_list.txt (original) +++ pypy/trunk/lib-python/failure_list.txt Thu Jan 22 16:07:41 2009 @@ -3,8 +3,8 @@ test_builtin this is our issue383 test_cProfile ! we still need to fix module/cProfile to respect builtin calls test_code obscure differences in code objects produced by compiler -test_codecs ! unknown -test_coding ! hah. fix buildbot :-/ +test_codecs ! unknown # SHOULD BE FIXED NOW +test_coding ! hah. fix buildbot :-/ # SHOULD BE FIXED NOW test_compiler ! unknown test_ctypes ! implementation details but also some real crashes test_decimal missing decimal.ROUND_05UP Modified: pypy/trunk/pypy/module/_codecs/app_codecs.py ============================================================================== --- pypy/trunk/pypy/module/_codecs/app_codecs.py (original) +++ pypy/trunk/pypy/module/_codecs/app_codecs.py Thu Jan 22 16:07:41 2009 @@ -373,7 +373,6 @@ def PyUnicode_DecodeUTF7(s, size, errors): from _codecs import lookup_error - starts = s errmsg = "" inShift = 0 bitsleft = 0 @@ -464,10 +463,9 @@ i += 1 if (inShift) : - #XXX This aint right endinpos = size msg = "unterminated shift sequence" - out, i = unicode_call_errorhandler(errors, 'utf-7', msg, s, i-1, i) + out, i = unicode_call_errorhandler(errors, 'utf-7', msg, s, startinpos, i) p += out return p Modified: pypy/trunk/pypy/module/_codecs/test/test_codecs.py ============================================================================== --- pypy/trunk/pypy/module/_codecs/test/test_codecs.py (original) +++ pypy/trunk/pypy/module/_codecs/test/test_codecs.py Thu Jan 22 16:07:41 2009 @@ -499,6 +499,13 @@ def test_charmap_decode(self): assert 'foo'.decode('charmap') == 'foo' + def test_utf7_start_end_in_exception(self): + try: + '+IC'.decode('utf-7') + except UnicodeDecodeError, exc: + assert exc.start == 0 + assert exc.end == 3 + class TestDirect: def test_charmap_encode(self): from pypy.module._codecs.app_codecs import charmap_encode From arigo at codespeak.net Thu Jan 22 16:07:52 2009 From: arigo at codespeak.net (arigo at codespeak.net) Date: Thu, 22 Jan 2009 16:07:52 +0100 (CET) Subject: [pypy-svn] r61243 - pypy/trunk/lib-python/modified-2.5.2/test Message-ID: <20090122150752.BB2031684F7@codespeak.net> Author: arigo Date: Thu Jan 22 16:07:52 2009 New Revision: 61243 Added: pypy/trunk/lib-python/modified-2.5.2/test/test_doctest.py - copied, changed from r61240, pypy/trunk/lib-python/2.5.2/test/test_doctest.py Log: More PyPy-ification. Copied: pypy/trunk/lib-python/modified-2.5.2/test/test_doctest.py (from r61240, pypy/trunk/lib-python/2.5.2/test/test_doctest.py) ============================================================================== --- pypy/trunk/lib-python/2.5.2/test/test_doctest.py (original) +++ pypy/trunk/lib-python/modified-2.5.2/test/test_doctest.py Thu Jan 22 16:07:52 2009 @@ -2422,8 +2422,11 @@ import trace, sys, re, StringIO def test_coverage(coverdir): - tracer = trace.Trace(ignoredirs=[sys.prefix, sys.exec_prefix,], - trace=0, count=1) + if hasattr(sys, 'prefix'): + ignoredirs = [sys.prefix, sys.exec_prefix] + else: + ignoredirs = [sys.pypy_prefix] # PyPy only + tracer = trace.Trace(ignoredirs=ignoredirs, trace=0, count=1) tracer.run('reload(doctest); test_main()') r = tracer.results() print 'Writing coverage results...' From arigo at codespeak.net Thu Jan 22 16:08:59 2009 From: arigo at codespeak.net (arigo at codespeak.net) Date: Thu, 22 Jan 2009 16:08:59 +0100 (CET) Subject: [pypy-svn] r61244 - pypy/trunk/lib-python/modified-2.5.2/test Message-ID: <20090122150859.C4D811684F9@codespeak.net> Author: arigo Date: Thu Jan 22 16:08:59 2009 New Revision: 61244 Modified: pypy/trunk/lib-python/modified-2.5.2/test/test_sys.py Log: More PyPy-ification. Modified: pypy/trunk/lib-python/modified-2.5.2/test/test_sys.py ============================================================================== --- pypy/trunk/lib-python/modified-2.5.2/test/test_sys.py (original) +++ pypy/trunk/lib-python/modified-2.5.2/test/test_sys.py Thu Jan 22 16:08:59 2009 @@ -327,14 +327,17 @@ self.assert_(sys.byteorder in ("little", "big")) self.assert_(isinstance(sys.builtin_module_names, tuple)) self.assert_(isinstance(sys.copyright, basestring)) - self.assert_(isinstance(sys.exec_prefix, basestring)) self.assert_(isinstance(sys.executable, basestring)) self.assert_(isinstance(sys.hexversion, int)) self.assert_(isinstance(sys.maxint, int)) if test.test_support.have_unicode: self.assert_(isinstance(sys.maxunicode, int)) self.assert_(isinstance(sys.platform, basestring)) - self.assert_(isinstance(sys.prefix, basestring)) + if hasattr(sys, 'prefix'): + self.assert_(isinstance(sys.prefix, basestring)) + self.assert_(isinstance(sys.exec_prefix, basestring)) + else: + self.assert_(isinstance(sys.pypy_prefix, basestring)) # PyPy only self.assert_(isinstance(sys.version, basestring)) vi = sys.version_info self.assert_(isinstance(vi, tuple)) From cfbolz at codespeak.net Thu Jan 22 16:31:09 2009 From: cfbolz at codespeak.net (cfbolz at codespeak.net) Date: Thu, 22 Jan 2009 16:31:09 +0100 (CET) Subject: [pypy-svn] r61245 - pypy/trunk/pypy/interpreter/pyparser Message-ID: <20090122153109.8A18416842D@codespeak.net> Author: cfbolz Date: Thu Jan 22 16:31:07 2009 New Revision: 61245 Modified: pypy/trunk/pypy/interpreter/pyparser/pythonlexer.py Log: try to be a tiny bit less insane. Armin will write the tests :-) Modified: pypy/trunk/pypy/interpreter/pyparser/pythonlexer.py ============================================================================== --- pypy/trunk/pypy/interpreter/pyparser/pythonlexer.py (original) +++ pypy/trunk/pypy/interpreter/pyparser/pythonlexer.py Thu Jan 22 16:31:07 2009 @@ -169,6 +169,10 @@ tok = Token(parser, parser.tokens['DEDENT'], '') token_list.append((tok, line, lnum, pos)) last_comment = '' + if column != indents[-1]: + raise TokenError("unindent does not match any outer indentation level", + line, (lnum, 0), token_list) + else: # continued statement if not line: raise TokenError("EOF in multi-line statement", line, From arigo at codespeak.net Thu Jan 22 16:31:59 2009 From: arigo at codespeak.net (arigo at codespeak.net) Date: Thu, 22 Jan 2009 16:31:59 +0100 (CET) Subject: [pypy-svn] r61246 - pypy/trunk/pypy/interpreter/test Message-ID: <20090122153159.97852168432@codespeak.net> Author: arigo Date: Thu Jan 22 16:31:59 2009 New Revision: 61246 Modified: pypy/trunk/pypy/interpreter/test/test_compiler.py Log: Test for Carl Friderich :-) Modified: pypy/trunk/pypy/interpreter/test/test_compiler.py ============================================================================== --- pypy/trunk/pypy/interpreter/test/test_compiler.py (original) +++ pypy/trunk/pypy/interpreter/test/test_compiler.py Thu Jan 22 16:31:59 2009 @@ -54,6 +54,11 @@ space.raises_w(space.w_SyntaxError, self.compiler.compile_command, ')', '?', mode, 0) + def test_indentation_error(self): + space = self.space + space.raises_w(space.w_SyntaxError, self.compiler.compile_command, + 'if 1:\n x\n y\n', '?', 'exec', 0) + def test_getcodeflags(self): code = self.compiler.compile('from __future__ import division\n', '', 'exec', 0) From arigo at codespeak.net Thu Jan 22 16:36:41 2009 From: arigo at codespeak.net (arigo at codespeak.net) Date: Thu, 22 Jan 2009 16:36:41 +0100 (CET) Subject: [pypy-svn] r61247 - pypy/trunk/lib-python/modified-2.5.2/test Message-ID: <20090122153641.AE5591684F3@codespeak.net> Author: arigo Date: Thu Jan 22 16:36:41 2009 New Revision: 61247 Modified: pypy/trunk/lib-python/modified-2.5.2/test/test_traceback.py Log: Forgot a f.close(). The idea was good though :-/ Modified: pypy/trunk/lib-python/modified-2.5.2/test/test_traceback.py ============================================================================== --- pypy/trunk/lib-python/modified-2.5.2/test/test_traceback.py (original) +++ pypy/trunk/lib-python/modified-2.5.2/test/test_traceback.py Thu Jan 22 16:36:41 2009 @@ -55,6 +55,7 @@ print >> f, """ def test(): raise ValueError""" + f.close() if 'test_bug737473' in sys.modules: del sys.modules['test_bug737473'] From arigo at codespeak.net Thu Jan 22 16:51:26 2009 From: arigo at codespeak.net (arigo at codespeak.net) Date: Thu, 22 Jan 2009 16:51:26 +0100 (CET) Subject: [pypy-svn] r61248 - pypy/trunk/lib-python/modified-2.5.2/test Message-ID: <20090122155126.030E11684F7@codespeak.net> Author: arigo Date: Thu Jan 22 16:51:26 2009 New Revision: 61248 Modified: pypy/trunk/lib-python/modified-2.5.2/test/test_traceback.py Log: Restore this test, which was completely deleted in some earlier revision which I could not find. There is an error, but it should probably be skipped instead of killed. Modified: pypy/trunk/lib-python/modified-2.5.2/test/test_traceback.py ============================================================================== --- pypy/trunk/lib-python/modified-2.5.2/test/test_traceback.py (original) +++ pypy/trunk/lib-python/modified-2.5.2/test/test_traceback.py Thu Jan 22 16:51:26 2009 @@ -35,6 +35,15 @@ self.assert_("^" in err[2]) # third line has caret self.assert_(err[1].find("!") == err[2].find("^")) # in the right place + def test_nocaret(self): + if is_jython: + # jython adds a caret in this case (why shouldn't it?) + return + err = self.get_exception_format(self.syntax_error_without_caret, + SyntaxError) + self.assert_(len(err) == 3) + self.assert_(err[1].strip() == "[x for x in x] = x") + def test_bad_indentation(self): err = self.get_exception_format(self.syntax_error_bad_indentation, IndentationError) From arigo at codespeak.net Thu Jan 22 16:54:45 2009 From: arigo at codespeak.net (arigo at codespeak.net) Date: Thu, 22 Jan 2009 16:54:45 +0100 (CET) Subject: [pypy-svn] r61249 - pypy/trunk/lib-python/modified-2.5.2/test Message-ID: <20090122155445.CB450168509@codespeak.net> Author: arigo Date: Thu Jan 22 16:54:45 2009 New Revision: 61249 Modified: pypy/trunk/lib-python/modified-2.5.2/test/test_traceback.py Log: Skip test_nocaret again on non-CPython implementations. Modified: pypy/trunk/lib-python/modified-2.5.2/test/test_traceback.py ============================================================================== --- pypy/trunk/lib-python/modified-2.5.2/test/test_traceback.py (original) +++ pypy/trunk/lib-python/modified-2.5.2/test/test_traceback.py Thu Jan 22 16:54:45 2009 @@ -1,7 +1,7 @@ """Test cases for traceback module""" import unittest -from test.test_support import run_unittest, is_jython +from test.test_support import run_unittest, impl_detail import traceback @@ -35,10 +35,8 @@ self.assert_("^" in err[2]) # third line has caret self.assert_(err[1].find("!") == err[2].find("^")) # in the right place + @impl_detail("other implementations may add a caret (why shouldn't they?)") def test_nocaret(self): - if is_jython: - # jython adds a caret in this case (why shouldn't it?) - return err = self.get_exception_format(self.syntax_error_without_caret, SyntaxError) self.assert_(len(err) == 3) From arigo at codespeak.net Thu Jan 22 16:56:22 2009 From: arigo at codespeak.net (arigo at codespeak.net) Date: Thu, 22 Jan 2009 16:56:22 +0100 (CET) Subject: [pypy-svn] r61250 - pypy/trunk/lib-python/modified-2.5.2/test Message-ID: <20090122155622.623C416850A@codespeak.net> Author: arigo Date: Thu Jan 22 16:56:21 2009 New Revision: 61250 Modified: pypy/trunk/lib-python/modified-2.5.2/test/test_traceback.py Log: Skip this too: sys.exc_traceback.__members__ is implementation-specific. Modified: pypy/trunk/lib-python/modified-2.5.2/test/test_traceback.py ============================================================================== --- pypy/trunk/lib-python/modified-2.5.2/test/test_traceback.py (original) +++ pypy/trunk/lib-python/modified-2.5.2/test/test_traceback.py Thu Jan 22 16:56:21 2009 @@ -99,6 +99,7 @@ os.unlink(os.path.join(testdir, f)) os.rmdir(testdir) + @impl_detail("sys.exc_traceback.__members__ is implementation-specific") def test_members(self): # Covers Python/structmember.c::listmembers() try: From arigo at codespeak.net Thu Jan 22 17:15:34 2009 From: arigo at codespeak.net (arigo at codespeak.net) Date: Thu, 22 Jan 2009 17:15:34 +0100 (CET) Subject: [pypy-svn] r61251 - in pypy/trunk/pypy/objspace/std: . test Message-ID: <20090122161534.EAD3F1684F3@codespeak.net> Author: arigo Date: Thu Jan 22 17:15:34 2009 New Revision: 61251 Modified: pypy/trunk/pypy/objspace/std/test/test_unicodeobject.py pypy/trunk/pypy/objspace/std/unicodeobject.py Log: Kill unicode_rsplit__Unicode_None_ANY() and replace it by Yet Another copy of stringobject.py, in this case -- obviously -- str_rsplit__Unicode_None_ANY. Fixes a failing test. Modified: pypy/trunk/pypy/objspace/std/test/test_unicodeobject.py ============================================================================== --- pypy/trunk/pypy/objspace/std/test/test_unicodeobject.py (original) +++ pypy/trunk/pypy/objspace/std/test/test_unicodeobject.py Thu Jan 22 17:15:34 2009 @@ -148,6 +148,7 @@ raises(ValueError, u'abc'.rsplit, u'') raises(ValueError, u'abc'.rsplit, '') raises(ValueError, 'abc'.rsplit, u'') + assert u' a b c '.rsplit(None, 0) == [u' a b c'] def test_center(self): s=u"a b" Modified: pypy/trunk/pypy/objspace/std/unicodeobject.py ============================================================================== --- pypy/trunk/pypy/objspace/std/unicodeobject.py (original) +++ pypy/trunk/pypy/objspace/std/unicodeobject.py Thu Jan 22 17:15:34 2009 @@ -686,37 +686,39 @@ def unicode_rsplit__Unicode_None_ANY(space, w_self, w_none, w_maxsplit): - self = w_self._value maxsplit = space.int_w(w_maxsplit) - parts = [] - if len(self) == 0: - return space.newlist([]) - start = 0 - end = len(self) - inword = 0 - - while maxsplit != 0 and start < end: - index = end - for index in range(end-1, start-1, -1): - if _isspace(self[index]): - break - else: - inword = 1 + res_w = [] + value = w_self._value + i = len(value)-1 + while True: + # starting from the end, find the end of the next word + while i >= 0: + if not _isspace(value[i]): + break # found + i -= 1 else: - break - if inword == 1: - parts.append(W_UnicodeObject(self[index+1:end])) - maxsplit -= 1 - # Eat whitespace - for end in range(index, start-1, -1): - if not _isspace(self[end-1]): - break + break # end of string, finished + + # find the start of the word + # (more precisely, 'j' will be the space character before the word) + if maxsplit == 0: + j = -1 # take all the rest of the string else: - return space.newlist(parts) + j = i - 1 + while j >= 0 and not value[j].isspace(): + j -= 1 + maxsplit -= 1 # NB. if it's already < 0, it stays < 0 + + # the word is value[j+1:i+1] + j1 = j + 1 + assert j1 >= 0 + res_w.append(W_UnicodeObject(value[j1:i+1])) - parts.append(W_UnicodeObject(self[:end])) - parts.reverse() - return space.newlist(parts) + # continue to look from the character before the space before the word + i = j - 1 + + res_w.reverse() + return space.newlist(res_w) def unicode_rsplit__Unicode_Unicode_ANY(space, w_self, w_delim, w_maxsplit): self = w_self._value From arigo at codespeak.net Thu Jan 22 18:09:15 2009 From: arigo at codespeak.net (arigo at codespeak.net) Date: Thu, 22 Jan 2009 18:09:15 +0100 (CET) Subject: [pypy-svn] r61255 - in pypy/trunk/pypy: module/__builtin__ objspace/std objspace/std/test Message-ID: <20090122170915.CA5A2168501@codespeak.net> Author: arigo Date: Thu Jan 22 18:09:15 2009 New Revision: 61255 Modified: pypy/trunk/pypy/module/__builtin__/interp_classobj.py pypy/trunk/pypy/objspace/std/formatting.py pypy/trunk/pypy/objspace/std/test/test_unicodeobject.py pypy/trunk/pypy/objspace/std/unicodetype.py Log: (antocuni, arigo) Fix various minor issues with unicodes, in particular the case of __str__ returning a unicode. Modified: pypy/trunk/pypy/module/__builtin__/interp_classobj.py ============================================================================== --- pypy/trunk/pypy/module/__builtin__/interp_classobj.py (original) +++ pypy/trunk/pypy/module/__builtin__/interp_classobj.py Thu Jan 22 18:09:15 2009 @@ -423,7 +423,7 @@ def descr_unicode(self, space): w_meth = self.getattr(space, space.wrap('__unicode__'), False) if w_meth is None: - return self.descr_repr(space) + return self.descr_str(space) return space.call_function(w_meth) def descr_len(self, space): Modified: pypy/trunk/pypy/objspace/std/formatting.py ============================================================================== --- pypy/trunk/pypy/objspace/std/formatting.py (original) +++ pypy/trunk/pypy/objspace/std/formatting.py Thu Jan 22 18:09:15 2009 @@ -385,6 +385,19 @@ if padnumber == '<': # spaces on the right result.append_multiple_char(const(' '), padding) + def string_formatting(self, w_value): + space = self.space + w_impl = space.lookup(w_value, '__str__') + if w_impl is None: + raise OperationError(space.w_TypeError, + space.wrap("operand does not support " + "unary str")) + w_result = space.get_and_call_function(w_impl, w_value) + if space.is_true(space.isinstance(w_result, + space.w_unicode)): + raise NeedUnicodeFormattingError + return space.str_w(w_result) + def fmt_s(self, w_value): space = self.space got_unicode = space.is_true(space.isinstance(w_value, @@ -392,7 +405,7 @@ if not do_unicode: if got_unicode: raise NeedUnicodeFormattingError - s = space.str_w(space.str(w_value)) + s = self.string_formatting(w_value) else: if not got_unicode: w_value = space.call_function(space.w_unicode, w_value) Modified: pypy/trunk/pypy/objspace/std/test/test_unicodeobject.py ============================================================================== --- pypy/trunk/pypy/objspace/std/test/test_unicodeobject.py (original) +++ pypy/trunk/pypy/objspace/std/test/test_unicodeobject.py Thu Jan 22 18:09:15 2009 @@ -677,17 +677,39 @@ u = unicode(buf, 'utf-8', 'strict') assert u == u'character buffers are decoded to unicode' - def test_formatting_unicode__str__(self): - skip('fixme!') + def test_unicode_conversion_with__str__(self): + # new-style classes + class A(object): + def __str__(self): + return u'\u1234' + s = unicode(A()) + assert type(s) is unicode + assert s == u'\u1234' + # with old-style classes, it's different, but it should work as well class A: def __str__(self): return u'\u1234' + s = unicode(A()) + assert type(s) is unicode + assert s == u'\u1234' - s = '%s' % A() + def test_formatting_unicode__str__(self): + class A: + def __init__(self, num): + self.num = num + def __str__(self): + return unichr(self.num) + + s = '%s' % A(111) # this is ASCII + assert type(s) is unicode + assert s == chr(111) + + s = '%s' % A(0x1234) # this is not ASCII assert type(s) is unicode assert s == u'\u1234' def test_formatting_unicode__str__2(self): + skip("this is completely insane") class A: def __str__(self): return u'baz' @@ -701,6 +723,9 @@ a = A() b = B() + s = '%s %s' % (a, b) + assert s == u'baz bar' + s = '%s %s' % (b, a) assert s == u'foo baz' Modified: pypy/trunk/pypy/objspace/std/unicodetype.py ============================================================================== --- pypy/trunk/pypy/objspace/std/unicodetype.py (original) +++ pypy/trunk/pypy/objspace/std/unicodetype.py Thu Jan 22 18:09:15 2009 @@ -216,6 +216,10 @@ w_res = w_obj else: w_unicode_method = space.lookup(w_obj, "__unicode__") + # obscure workaround: for the next two lines see + # test_unicode_conversion_with__str__ + if w_unicode_method is None: + w_unicode_method = space.lookup(w_obj, "__str__") if w_unicode_method is not None: w_res = space.get_and_call_function(w_unicode_method, w_obj) else: From arigo at codespeak.net Thu Jan 22 18:29:22 2009 From: arigo at codespeak.net (arigo at codespeak.net) Date: Thu, 22 Jan 2009 18:29:22 +0100 (CET) Subject: [pypy-svn] r61256 - pypy/trunk/pypy/objspace/std Message-ID: <20090122172922.CB55B168452@codespeak.net> Author: arigo Date: Thu Jan 22 18:29:21 2009 New Revision: 61256 Modified: pypy/trunk/pypy/objspace/std/unicodeobject.py Log: Fix annotation. Modified: pypy/trunk/pypy/objspace/std/unicodeobject.py ============================================================================== --- pypy/trunk/pypy/objspace/std/unicodeobject.py (original) +++ pypy/trunk/pypy/objspace/std/unicodeobject.py Thu Jan 22 18:29:21 2009 @@ -705,7 +705,7 @@ j = -1 # take all the rest of the string else: j = i - 1 - while j >= 0 and not value[j].isspace(): + while j >= 0 and not _isspace(value[j]): j -= 1 maxsplit -= 1 # NB. if it's already < 0, it stays < 0 From getxsick at codespeak.net Thu Jan 22 18:32:49 2009 From: getxsick at codespeak.net (getxsick at codespeak.net) Date: Thu, 22 Jan 2009 18:32:49 +0100 (CET) Subject: [pypy-svn] r61257 - pypy/extradoc/talk/wroclaw2009 Message-ID: <20090122173249.92F4B1684DF@codespeak.net> Author: getxsick Date: Thu Jan 22 18:32:48 2009 New Revision: 61257 Modified: pypy/extradoc/talk/wroclaw2009/author.latex pypy/extradoc/talk/wroclaw2009/talk.txt Log: added polish characters Modified: pypy/extradoc/talk/wroclaw2009/author.latex ============================================================================== --- pypy/extradoc/talk/wroclaw2009/author.latex (original) +++ pypy/extradoc/talk/wroclaw2009/author.latex Thu Jan 22 18:32:48 2009 @@ -1,8 +1,8 @@ \definecolor{rrblitbackground}{rgb}{0.0, 0.0, 0.0} \title[PyPy status talk]{PyPy status talk} -\author[M. Fijalkowski]{Maciej Fijalkowski\\ +\author[M. Fijalkowski]{Maciej Fija?kowski\\ Merlinux GmbH} -\institute[Politechnika Wroclawska]{Politechnika Wroclawska} +\institute[Politechnika Wroc?awska]{Politechnika Wroc?awska} \date{January 22 2009} Modified: pypy/extradoc/talk/wroclaw2009/talk.txt ============================================================================== --- pypy/extradoc/talk/wroclaw2009/talk.txt (original) +++ pypy/extradoc/talk/wroclaw2009/talk.txt Thu Jan 22 18:32:48 2009 @@ -235,7 +235,7 @@ * 1.1 release this spring -* sprint in Wroclaw 7-14 February +* sprint in Wroc?aw 7-14 February Q&A === From fijal at codespeak.net Fri Jan 23 13:51:42 2009 From: fijal at codespeak.net (fijal at codespeak.net) Date: Fri, 23 Jan 2009 13:51:42 +0100 (CET) Subject: [pypy-svn] r61259 - in pypy/trunk/pypy/module/bz2: . test Message-ID: <20090123125142.C50F11684ED@codespeak.net> Author: fijal Date: Fri Jan 23 13:51:40 2009 New Revision: 61259 Modified: pypy/trunk/pypy/module/bz2/interp_bz2.py pypy/trunk/pypy/module/bz2/test/test_bz2_file.py Log: A test and a questionable fix (this fixes only one thing, not the whole bunch of other possibilities), more to come Modified: pypy/trunk/pypy/module/bz2/interp_bz2.py ============================================================================== --- pypy/trunk/pypy/module/bz2/interp_bz2.py (original) +++ pypy/trunk/pypy/module/bz2/interp_bz2.py Fri Jan 23 13:51:40 2009 @@ -326,6 +326,9 @@ def readall(self): w_result = self.decompressor.decompress(self.stream.readall()) + if self.decompressor.running: + raise OperationError(self.space.w_EOFError, + self.space.wrap("compressed file ended before the logical end-of-the-stream was detected")) result = self.space.str_w(w_result) self.readlength += len(result) result = self.buffer + result @@ -645,7 +648,7 @@ break if bzerror != BZ_OK: _catch_bz2_error(self.space, bzerror) - + if rffi.getintfield(self.bzs, 'c_avail_in') == 0: break elif rffi.getintfield(self.bzs, 'c_avail_out') == 0: Modified: pypy/trunk/pypy/module/bz2/test/test_bz2_file.py ============================================================================== --- pypy/trunk/pypy/module/bz2/test/test_bz2_file.py (original) +++ pypy/trunk/pypy/module/bz2/test/test_bz2_file.py Fri Jan 23 13:51:40 2009 @@ -13,9 +13,13 @@ def create_temp_file(crlf=False): f = py.test.ensuretemp("bz2").join("foo") - data = (DATA, DATA_CRLF)[crlf] f.write(data) + + def create_broken_temp_file(): + f = py.test.ensuretemp("bz2").join("foo") + data = DATA[:100] + f.write(data) def decompress(data): import popen2 @@ -34,6 +38,7 @@ mod.DATA_CRLF = DATA_CRLF mod.create_temp_file = create_temp_file mod.decompress = decompress + mod.create_broken_temp_file = create_broken_temp_file class AppTestBZ2File: #(CheckAllocation): # XXX for unknown reasons, we cannot do allocation checks, as sth is @@ -47,6 +52,7 @@ cls.w_temppath = space.wrap(str(py.test.ensuretemp("bz2").join("foo"))) cls.w_create_temp_file = space.wrap(create_temp_file) cls.w_decompress = space.wrap(decompress) + cls.w_create_broken_temp_file = space.wrap(create_broken_temp_file) def test_attributes(self): from bz2 import BZ2File @@ -234,6 +240,12 @@ assert text_read == self.TEXT bz2f.close() + def test_read_broken_file(self): + from bz2 import BZ2File + self.create_broken_temp_file() + bz2f = BZ2File(self.temppath) + raises(EOFError, bz2f.read) + def test_read_chunk10(self): from bz2 import BZ2File self.create_temp_file() From fijal at codespeak.net Fri Jan 23 13:54:16 2009 From: fijal at codespeak.net (fijal at codespeak.net) Date: Fri, 23 Jan 2009 13:54:16 +0100 (CET) Subject: [pypy-svn] r61260 - pypy/trunk/pypy/module/bz2/test Message-ID: <20090123125416.E19101683E7@codespeak.net> Author: fijal Date: Fri Jan 23 13:54:16 2009 New Revision: 61260 Modified: pypy/trunk/pypy/module/bz2/test/test_bz2_compdecomp.py pypy/trunk/pypy/module/bz2/test/test_bz2_file.py Log: One more test + reenable a skipped test which works Modified: pypy/trunk/pypy/module/bz2/test/test_bz2_compdecomp.py ============================================================================== --- pypy/trunk/pypy/module/bz2/test/test_bz2_compdecomp.py (original) +++ pypy/trunk/pypy/module/bz2/test/test_bz2_compdecomp.py Fri Jan 23 13:54:16 2009 @@ -156,7 +156,6 @@ assert decompressed_data == self.TEXT def test_subsequent_read(self): - skip("Buggy") from bz2 import BZ2Decompressor bz2d = BZ2Decompressor() decompressed_data = bz2d.decompress(self.BUGGY_DATA) Modified: pypy/trunk/pypy/module/bz2/test/test_bz2_file.py ============================================================================== --- pypy/trunk/pypy/module/bz2/test/test_bz2_file.py (original) +++ pypy/trunk/pypy/module/bz2/test/test_bz2_file.py Fri Jan 23 13:54:16 2009 @@ -246,6 +246,19 @@ bz2f = BZ2File(self.temppath) raises(EOFError, bz2f.read) + def test_subsequent_read_broken_file(self): + from bz2 import BZ2File + counter = 0 + self.create_broken_temp_file() + bz2f = BZ2File(self.temppath) + try: + bz2f.read(10) + counter += 1 + if counter > 100: + raise Exception("should generate EOFError earlier") + except EOFError: + pass + def test_read_chunk10(self): from bz2 import BZ2File self.create_temp_file() From afa at codespeak.net Fri Jan 23 15:27:15 2009 From: afa at codespeak.net (afa at codespeak.net) Date: Fri, 23 Jan 2009 15:27:15 +0100 (CET) Subject: [pypy-svn] r61261 - pypy/trunk/pypy/lib Message-ID: <20090123142715.2676516844E@codespeak.net> Author: afa Date: Fri Jan 23 15:27:12 2009 New Revision: 61261 Modified: pypy/trunk/pypy/lib/msvcrt.py Log: Ouch: Correctly pass the handle to ctypes. This module used to work with a completely different C runtime... Modified: pypy/trunk/pypy/lib/msvcrt.py ============================================================================== --- pypy/trunk/pypy/lib/msvcrt.py (original) +++ pypy/trunk/pypy/lib/msvcrt.py Fri Jan 23 15:27:12 2009 @@ -9,7 +9,7 @@ import _rawffi import ctypes -_c = ctypes.CDLL('msvcrt', _rawffi.get_libc()) +_c = ctypes.CDLL('msvcrt', handle=_rawffi.get_libc()) open_osfhandle = _c._open_osfhandle open_osfhandle.argtypes = [ctypes.c_int, ctypes.c_int] From afa at codespeak.net Fri Jan 23 15:33:42 2009 From: afa at codespeak.net (afa at codespeak.net) Date: Fri, 23 Jan 2009 15:33:42 +0100 (CET) Subject: [pypy-svn] r61262 - pypy/trunk/pypy/lib Message-ID: <20090123143342.C5DCD16844E@codespeak.net> Author: afa Date: Fri Jan 23 15:33:42 2009 New Revision: 61262 Modified: pypy/trunk/pypy/lib/ctypes_support.py pypy/trunk/pypy/lib/msvcrt.py Log: Kill another LoadLibrary which does not use the correct C runtime. This one was used by the _locale module at least Modified: pypy/trunk/pypy/lib/ctypes_support.py ============================================================================== --- pypy/trunk/pypy/lib/ctypes_support.py (original) +++ pypy/trunk/pypy/lib/ctypes_support.py Fri Jan 23 15:33:42 2009 @@ -9,16 +9,12 @@ # __________ the standard C library __________ +import _rawffi + if sys.platform == 'win32': - # trying to guess the correct libc... only a few tests fail if there - # is a mismatch between the one used by python2x.dll and the one - # loaded here - if sys.version_info < (2, 4): - standard_c_lib = ctypes.cdll.LoadLibrary('msvcrt.dll') - else: - standard_c_lib = ctypes.cdll.LoadLibrary('msvcr71.dll') + standard_c_lib = ctypes.CDLL('msvcrt', handle=_rawffi.get_libc()) else: - standard_c_lib = ctypes.cdll.LoadLibrary(ctypes.util.find_library('c')) + standard_c_lib = ctypes.CDLL(ctypes.util.find_library('c')) if sys.platform == 'win32': standard_c_lib._errno.restype = ctypes.POINTER(ctypes.c_int) Modified: pypy/trunk/pypy/lib/msvcrt.py ============================================================================== --- pypy/trunk/pypy/lib/msvcrt.py (original) +++ pypy/trunk/pypy/lib/msvcrt.py Fri Jan 23 15:33:42 2009 @@ -6,10 +6,8 @@ # XXX incomplete: implemented only functions needed by subprocess.py -import _rawffi import ctypes - -_c = ctypes.CDLL('msvcrt', handle=_rawffi.get_libc()) +from ctypes_support import standard_c_lib as _c open_osfhandle = _c._open_osfhandle open_osfhandle.argtypes = [ctypes.c_int, ctypes.c_int] From antocuni at codespeak.net Fri Jan 23 16:10:00 2009 From: antocuni at codespeak.net (antocuni at codespeak.net) Date: Fri, 23 Jan 2009 16:10:00 +0100 (CET) Subject: [pypy-svn] r61263 - in pypy/trunk/pypy/rlib: . test Message-ID: <20090123151000.62AC71684F2@codespeak.net> Author: antocuni Date: Fri Jan 23 16:09:59 2009 New Revision: 61263 Modified: pypy/trunk/pypy/rlib/rbigint.py pypy/trunk/pypy/rlib/test/test_rbigint.py Log: add a uintmask() operation to rbigint Modified: pypy/trunk/pypy/rlib/rbigint.py ============================================================================== --- pypy/trunk/pypy/rlib/rbigint.py (original) +++ pypy/trunk/pypy/rlib/rbigint.py Fri Jan 23 16:09:59 2009 @@ -200,6 +200,9 @@ raise ValueError("cannot convert negative integer to unsigned int") return _AsULonglong_ignore_sign(self) + def uintmask(self): + return _AsUInt_mask(self) + def ulonglongmask(self): """Return r_ulonglong(self), truncating.""" return _AsULonglong_mask(self) @@ -1592,16 +1595,21 @@ i -= 1 return x -def _AsULonglong_mask(v): - x = r_ulonglong(0) - i = len(v.digits) - 1 - while i >= 0: - prev = x - x = (x << SHIFT) + v.digits[i] - i -= 1 - if v.sign < 0: - x = -x - return x +def make_unsigned_mask_conversion(T): + def _As_unsigned_mask(v): + x = T(0) + i = len(v.digits) - 1 + while i >= 0: + prev = x + x = (x << SHIFT) + v.digits[i] + i -= 1 + if v.sign < 0: + x = -x + return x + return _As_unsigned_mask + +_AsULonglong_mask = make_unsigned_mask_conversion(r_ulonglong) +_AsUInt_mask = make_unsigned_mask_conversion(r_uint) def _hash(v): # This is designed so that Python ints and longs with the Modified: pypy/trunk/pypy/rlib/test/test_rbigint.py ============================================================================== --- pypy/trunk/pypy/rlib/test/test_rbigint.py (original) +++ pypy/trunk/pypy/rlib/test/test_rbigint.py Fri Jan 23 16:09:59 2009 @@ -419,6 +419,14 @@ py.test.raises(OverflowError, f3.tolonglong) py.test.raises(OverflowError, f4.tolonglong) + def test_uintmask(self): + assert rbigint.fromint(-1).uintmask() == r_uint(-1) + assert rbigint.fromint(0).uintmask() == r_uint(0) + assert (rbigint.fromint(sys.maxint).uintmask() == + r_uint(sys.maxint)) + assert (rbigint.fromlong(sys.maxint+1).uintmask() == + r_uint(-sys.maxint-1)) + def test_ulonglongmask(self): assert rbigint.fromlong(-1).ulonglongmask() == r_ulonglong(-1) assert rbigint.fromlong(0).ulonglongmask() == r_ulonglong(0) From antocuni at codespeak.net Fri Jan 23 16:10:57 2009 From: antocuni at codespeak.net (antocuni at codespeak.net) Date: Fri, 23 Jan 2009 16:10:57 +0100 (CET) Subject: [pypy-svn] r61264 - in pypy/trunk/pypy/module/zlib: . test Message-ID: <20090123151057.0D8311684F2@codespeak.net> Author: antocuni Date: Fri Jan 23 16:10:56 2009 New Revision: 61264 Modified: pypy/trunk/pypy/module/zlib/interp_zlib.py pypy/trunk/pypy/module/zlib/test/test_zlib.py Log: (antocuni, arigo around) try to handle correctly negative and/or long values passed to crc32 Modified: pypy/trunk/pypy/module/zlib/interp_zlib.py ============================================================================== --- pypy/trunk/pypy/module/zlib/interp_zlib.py (original) +++ pypy/trunk/pypy/module/zlib/interp_zlib.py Fri Jan 23 16:10:56 2009 @@ -20,14 +20,25 @@ return intmask((x ^ SIGN_EXTEND2) - SIGN_EXTEND2) -def crc32(space, string, start = rzlib.CRC32_DEFAULT_START): +def crc32(space, string, w_start = rzlib.CRC32_DEFAULT_START): """ crc32(string[, start]) -- Compute a CRC-32 checksum of string. An optional starting value can be specified. The returned checksum is an integer. """ - checksum = rzlib.crc32(string, start) + if space.is_true(space.isinstance(w_start, space.w_long)): + num = space.bigint_w(w_start) + ustart = num.uintmask() + elif space.is_true(space.isinstance(w_start, space.w_int)): + start = space.int_w(w_start) + ustart = r_uint(start) + else: + raise OperationError(space.w_TypeError, + space.wrap("crc32() argument 2 must " + "be integer, not str")) + + checksum = rzlib.crc32(string, ustart) # This is, perhaps, a little stupid. zlib returns the checksum unsigned. # CPython exposes it as a signed value, though. -exarkun @@ -37,7 +48,7 @@ checksum = unsigned_to_signed_32bit(checksum) return space.wrap(checksum) -crc32.unwrap_spec = [ObjSpace, 'bufferstr', r_uint] +crc32.unwrap_spec = [ObjSpace, 'bufferstr', W_Root] def adler32(space, string, start = rzlib.ADLER32_DEFAULT_START): Modified: pypy/trunk/pypy/module/zlib/test/test_zlib.py ============================================================================== --- pypy/trunk/pypy/module/zlib/test/test_zlib.py (original) +++ pypy/trunk/pypy/module/zlib/test/test_zlib.py Fri Jan 23 16:10:56 2009 @@ -67,6 +67,18 @@ helloworldcrc = self.zlib.crc32(world, hellocrc) assert helloworldcrc == self.zlib.crc32(hello + world) + def test_crc32_negative_start(self): + v = self.zlib.crc32('', -1) + assert v == -1 + + def test_crc32_negative_long_start(self): + v = self.zlib.crc32('', -1L) + assert v == -1 + + def test_crc32_long_start(self): + import sys + v = self.zlib.crc32('', sys.maxint*2) + assert v == -2 def test_adler32(self): """ From fijall at gmail.com Fri Jan 23 16:57:54 2009 From: fijall at gmail.com (Maciej Fijalkowski) Date: Fri, 23 Jan 2009 16:57:54 +0100 Subject: [pypy-svn] r61262 - pypy/trunk/pypy/lib In-Reply-To: <20090123143342.C5DCD16844E@codespeak.net> References: <20090123143342.C5DCD16844E@codespeak.net> Message-ID: <693bc9ab0901230757p19573208h4b44f5156041a50f@mail.gmail.com> I would really love to have _locale written in rpython. it's just causing too much trouble On Fri, Jan 23, 2009 at 3:33 PM, wrote: > Author: afa > Date: Fri Jan 23 15:33:42 2009 > New Revision: 61262 > > Modified: > pypy/trunk/pypy/lib/ctypes_support.py > pypy/trunk/pypy/lib/msvcrt.py > Log: > Kill another LoadLibrary which does not use the correct C runtime. > This one was used by the _locale module at least > From fijal at codespeak.net Fri Jan 23 17:04:01 2009 From: fijal at codespeak.net (fijal at codespeak.net) Date: Fri, 23 Jan 2009 17:04:01 +0100 (CET) Subject: [pypy-svn] r61270 - in pypy/trunk/pypy/module/bz2: . test Message-ID: <20090123160401.4636D168504@codespeak.net> Author: fijal Date: Fri Jan 23 17:04:00 2009 New Revision: 61270 Modified: pypy/trunk/pypy/module/bz2/interp_bz2.py pypy/trunk/pypy/module/bz2/test/test_bz2_file.py Log: a test and a fix Modified: pypy/trunk/pypy/module/bz2/interp_bz2.py ============================================================================== --- pypy/trunk/pypy/module/bz2/interp_bz2.py (original) +++ pypy/trunk/pypy/module/bz2/interp_bz2.py Fri Jan 23 17:04:00 2009 @@ -547,17 +547,18 @@ self.bzs.c_next_out = out_buf rffi.setintfield(self.bzs, 'c_avail_out', out_bufsize) - if temp: - return self.space.wrap("".join(temp)) - + if rffi.getintfield(self.bzs, 'c_avail_out'): size = _bzs_total_out(self.bzs) - total_out res = "".join([out_buf[i] for i in range(size)]) + else: + total_out = _bzs_total_out(self.bzs) + res = "".join([out_buf[i] for i in range(total_out)]) + if not temp: return self.space.wrap(res) - - total_out = _bzs_total_out(self.bzs) - res = "".join([out_buf[i] for i in range(total_out)]) - return self.space.wrap(res) + else: + temp.append(res) + return self.space.wrap("".join(temp)) finally: lltype.free(out_buf, flavor='raw') flush.unwrap_spec = ['self'] Modified: pypy/trunk/pypy/module/bz2/test/test_bz2_file.py ============================================================================== --- pypy/trunk/pypy/module/bz2/test/test_bz2_file.py (original) +++ pypy/trunk/pypy/module/bz2/test/test_bz2_file.py Fri Jan 23 17:04:00 2009 @@ -2,6 +2,7 @@ from pypy.conftest import gettestobjspace from pypy.module.bz2.test.support import CheckAllocation import os +import random if os.name == "nt": from py.test import skip @@ -39,6 +40,8 @@ mod.create_temp_file = create_temp_file mod.decompress = decompress mod.create_broken_temp_file = create_broken_temp_file + s = 'abcdefghijklmnop' + mod.RANDOM_DATA = ''.join([s[int(random.random() * len(s))] for i in range(30000)]) class AppTestBZ2File: #(CheckAllocation): # XXX for unknown reasons, we cannot do allocation checks, as sth is @@ -53,6 +56,7 @@ cls.w_create_temp_file = space.wrap(create_temp_file) cls.w_decompress = space.wrap(decompress) cls.w_create_broken_temp_file = space.wrap(create_broken_temp_file) + cls.w_random_data = space.wrap(RANDOM_DATA) def test_attributes(self): from bz2 import BZ2File @@ -401,6 +405,16 @@ raises(IOError, bz2f.write, "abc") raises(IOError, bz2f.writelines, ["abc"]) bz2f.close() + + def test_write_bigger_file(self): + from bz2 import BZ2File + import random + bz2f = BZ2File(self.temppath, 'w') + bz2f.write(self.random_data) + bz2f.close() + bz2f = BZ2File(self.temppath, 'r') + assert bz2f.read() == self.random_data + # has_cmdline_bunzip2 = sys.platform not in ("win32", "os2emx", "riscos") # From afa at codespeak.net Fri Jan 23 17:05:16 2009 From: afa at codespeak.net (afa at codespeak.net) Date: Fri, 23 Jan 2009 17:05:16 +0100 (CET) Subject: [pypy-svn] r61271 - pypy/trunk/lib-python/modified-2.5.2 Message-ID: <20090123160516.9214A168504@codespeak.net> Author: afa Date: Fri Jan 23 17:05:15 2009 New Revision: 61271 Added: pypy/trunk/lib-python/modified-2.5.2/subprocess.py - copied, changed from r61203, pypy/trunk/lib-python/2.5.2/subprocess.py Log: CPython relies on reference counting to close some file and pipe handles. pypy cannot, and must explicitely close them. This should make test_subprocess go to the end, even if some tests fail. Copied: pypy/trunk/lib-python/modified-2.5.2/subprocess.py (from r61203, pypy/trunk/lib-python/2.5.2/subprocess.py) ============================================================================== --- pypy/trunk/lib-python/2.5.2/subprocess.py (original) +++ pypy/trunk/lib-python/modified-2.5.2/subprocess.py Fri Jan 23 17:05:15 2009 @@ -740,9 +740,13 @@ def _make_inheritable(self, handle): """Return a duplicate of handle, which is inheritable""" - return DuplicateHandle(GetCurrentProcess(), handle, + dupl = DuplicateHandle(GetCurrentProcess(), handle, GetCurrentProcess(), 0, 1, DUPLICATE_SAME_ACCESS) + # If the initial handle was obtained with CreatePipe, close it. + if not isinstance(handle, int): + handle.Close() + return dupl def _find_w9xpopen(self): From fijal at codespeak.net Fri Jan 23 17:07:13 2009 From: fijal at codespeak.net (fijal at codespeak.net) Date: Fri, 23 Jan 2009 17:07:13 +0100 (CET) Subject: [pypy-svn] r61272 - pypy/trunk/lib-python Message-ID: <20090123160713.E4FF916850A@codespeak.net> Author: fijal Date: Fri Jan 23 17:07:13 2009 New Revision: 61272 Modified: pypy/trunk/lib-python/conftest.py Log: unskip test_subprocess Modified: pypy/trunk/lib-python/conftest.py ============================================================================== --- pypy/trunk/lib-python/conftest.py (original) +++ pypy/trunk/lib-python/conftest.py Fri Jan 23 17:07:13 2009 @@ -382,7 +382,7 @@ RegrTest('test_struct.py', usemodules='struct'), RegrTest('test_structmembers.py', skip="CPython specific"), RegrTest('test_structseq.py'), - RegrTest('test_subprocess.py', usemodules='signal', skip=(sys.platform=='win32')), + RegrTest('test_subprocess.py', usemodules='signal'), RegrTest('test_sunaudiodev.py', skip=True), RegrTest('test_sundry.py'), RegrTest('test_symtable.py', skip="implementation detail"), From fijal at codespeak.net Fri Jan 23 17:41:37 2009 From: fijal at codespeak.net (fijal at codespeak.net) Date: Fri, 23 Jan 2009 17:41:37 +0100 (CET) Subject: [pypy-svn] r61273 - pypy/trunk/lib-python Message-ID: <20090123164137.05D04168511@codespeak.net> Author: fijal Date: Fri Jan 23 17:41:36 2009 New Revision: 61273 Modified: pypy/trunk/lib-python/conftest.py Log: we don't need two occurences of test_ast heree Modified: pypy/trunk/lib-python/conftest.py ============================================================================== --- pypy/trunk/lib-python/conftest.py (original) +++ pypy/trunk/lib-python/conftest.py Fri Jan 23 17:41:36 2009 @@ -448,7 +448,6 @@ RegrTest('test_zipimport.py', usemodules='zlib zipimport'), RegrTest('test_zlib.py', usemodules='zlib'), - RegrTest('test_ast.py'), RegrTest('test_bigaddrspace.py'), RegrTest('test_bigmem.py'), RegrTest('test_cProfile.py'), From fijal at codespeak.net Fri Jan 23 17:59:26 2009 From: fijal at codespeak.net (fijal at codespeak.net) Date: Fri, 23 Jan 2009 17:59:26 +0100 (CET) Subject: [pypy-svn] r61275 - pypy/trunk/lib-python/modified-2.5.2 Message-ID: <20090123165926.321561684F3@codespeak.net> Author: fijal Date: Fri Jan 23 17:59:25 2009 New Revision: 61275 Added: pypy/trunk/lib-python/modified-2.5.2/gzip.py - copied, changed from r61272, pypy/trunk/lib-python/2.5.2/gzip.py Log: actually at least flush file when called close(). Apparently we cannot really close file here as tarfile depends on it not being closed Copied: pypy/trunk/lib-python/modified-2.5.2/gzip.py (from r61272, pypy/trunk/lib-python/2.5.2/gzip.py) ============================================================================== --- pypy/trunk/lib-python/2.5.2/gzip.py (original) +++ pypy/trunk/lib-python/modified-2.5.2/gzip.py Fri Jan 23 17:59:25 2009 @@ -324,8 +324,10 @@ write32u(self.fileobj, LOWU32(self.crc)) # self.size may exceed 2GB, or even 4GB write32u(self.fileobj, LOWU32(self.size)) + self.fileobj.flush() self.fileobj = None elif self.mode == READ: + self.fileobj.flush() self.fileobj = None if self.myfileobj: self.myfileobj.close() From fijal at codespeak.net Fri Jan 23 18:00:21 2009 From: fijal at codespeak.net (fijal at codespeak.net) Date: Fri, 23 Jan 2009 18:00:21 +0100 (CET) Subject: [pypy-svn] r61276 - pypy/trunk/lib-python/modified-2.5.2/test Message-ID: <20090123170021.C6A1616851A@codespeak.net> Author: fijal Date: Fri Jan 23 18:00:21 2009 New Revision: 61276 Added: pypy/trunk/lib-python/modified-2.5.2/test/test_float.py - copied, changed from r61272, pypy/trunk/lib-python/2.5.2/test/test_float.py Log: Try to provide something that does not use __getformat__ if not necessary Copied: pypy/trunk/lib-python/modified-2.5.2/test/test_float.py (from r61272, pypy/trunk/lib-python/2.5.2/test/test_float.py) ============================================================================== --- pypy/trunk/lib-python/2.5.2/test/test_float.py (original) +++ pypy/trunk/lib-python/modified-2.5.2/test/test_float.py Fri Jan 23 18:00:21 2009 @@ -83,41 +83,46 @@ # is accident (today). class IEEEFormatTestCase(unittest.TestCase): - if float.__getformat__("double").startswith("IEEE"): - def test_double_specials_do_unpack(self): - for fmt, data in [('>d', BE_DOUBLE_INF), - ('>d', BE_DOUBLE_NAN), - ('f', BE_FLOAT_INF), - ('>f', BE_FLOAT_NAN), - ('d', BE_DOUBLE_INF), + ('>d', BE_DOUBLE_NAN), + ('f', BE_FLOAT_INF), + ('>f', BE_FLOAT_NAN), + (' Author: fijal Date: Fri Jan 23 18:57:49 2009 New Revision: 61277 Modified: pypy/build/bot2/pypybuildbot/master.py Log: add a nightly build for win32 Modified: pypy/build/bot2/pypybuildbot/master.py ============================================================================== --- pypy/build/bot2/pypybuildbot/master.py (original) +++ pypy/build/bot2/pypybuildbot/master.py Fri Jan 23 18:57:49 2009 @@ -49,7 +49,7 @@ 'change_source': [], 'schedulers': [ - Nightly("nightly", [LINUX32, CPYLINUX32, APPLVLLINUX32], + Nightly("nightly", [LINUX32, CPYLINUX32, APPLVLLINUX32, CPYWIN32], hour=4, minute=45), ], 'status': [status], From fijal at codespeak.net Fri Jan 23 19:37:30 2009 From: fijal at codespeak.net (fijal at codespeak.net) Date: Fri, 23 Jan 2009 19:37:30 +0100 (CET) Subject: [pypy-svn] r61279 - pypy/trunk/pypy/module/_codecs Message-ID: <20090123183730.055CB168464@codespeak.net> Author: fijal Date: Fri Jan 23 19:37:29 2009 New Revision: 61279 Modified: pypy/trunk/pypy/module/_codecs/app_codecs.py Log: I suppose this is the default Modified: pypy/trunk/pypy/module/_codecs/app_codecs.py ============================================================================== --- pypy/trunk/pypy/module/_codecs/app_codecs.py (original) +++ pypy/trunk/pypy/module/_codecs/app_codecs.py Fri Jan 23 19:37:29 2009 @@ -85,7 +85,7 @@ return res, len(data) -def charmap_encode(obj, errors='strict', mapping='latin-1'): +def charmap_encode(obj, errors='strict', mapping=None): """None """ res = PyUnicode_EncodeCharmap(obj, mapping, errors) @@ -207,7 +207,7 @@ res = ''.join(res) return res, len(data) -def charmap_decode( data, errors='strict', mapping='latin-1'): +def charmap_decode( data, errors='strict', mapping=None): """None """ res = PyUnicode_DecodeCharmap(data, mapping, errors) @@ -826,7 +826,7 @@ ## * 3=ignore, 4=xmlcharrefreplace */ # /* Default to Latin-1 */ - if mapping == 'latin-1': + if mapping == None: import _codecs return _codecs.latin_1_encode(p, errors)[0] size = len(p) @@ -854,7 +854,7 @@ size = len(s) ## /* Default to Latin-1 */ - if (mapping == 'latin-1'): + if mapping is None: import _codecs return _codecs.latin_1_decode(s, errors)[0] From fijal at codespeak.net Fri Jan 23 19:43:15 2009 From: fijal at codespeak.net (fijal at codespeak.net) Date: Fri, 23 Jan 2009 19:43:15 +0100 (CET) Subject: [pypy-svn] r61280 - pypy/trunk/pypy/module/_codecs Message-ID: <20090123184315.E944A168483@codespeak.net> Author: fijal Date: Fri Jan 23 19:43:15 2009 New Revision: 61280 Modified: pypy/trunk/pypy/module/_codecs/__init__.py pypy/trunk/pypy/module/_codecs/app_codecs.py Log: don't even pretend that we have mbcs encoding!!! Modified: pypy/trunk/pypy/module/_codecs/__init__.py ============================================================================== --- pypy/trunk/pypy/module/_codecs/__init__.py (original) +++ pypy/trunk/pypy/module/_codecs/__init__.py Fri Jan 23 19:43:15 2009 @@ -8,8 +8,6 @@ 'charmap_encode' : 'app_codecs.charmap_encode', 'escape_decode' : 'app_codecs.escape_decode', 'escape_encode' : 'app_codecs.escape_encode', - 'mbcs_decode' : 'app_codecs.mbcs_decode', - 'mbcs_encode' : 'app_codecs.mbcs_encode', 'raw_unicode_escape_decode' : 'app_codecs.raw_unicode_escape_decode', 'raw_unicode_escape_encode' : 'app_codecs.raw_unicode_escape_encode', 'unicode_escape_decode' : 'app_codecs.unicode_escape_decode', Modified: pypy/trunk/pypy/module/_codecs/app_codecs.py ============================================================================== --- pypy/trunk/pypy/module/_codecs/app_codecs.py (original) +++ pypy/trunk/pypy/module/_codecs/app_codecs.py Fri Jan 23 19:43:15 2009 @@ -43,12 +43,6 @@ import sys -# XXX MBCS codec might involve ctypes ? -def mbcs_decode(): - """None - """ - pass - def escape_encode( obj, errors='strict'): """None """ @@ -220,18 +214,7 @@ """ res = PyUnicode_EncodeUTF7(obj, len(obj), 0, 0, errors) res = ''.join(res) - return res, len(res) - -def mbcs_encode( obj, errors='strict'): - """None - """ - pass -## return (PyUnicode_EncodeMBCS( -## (obj), -## len(obj), -## errors), -## len(obj)) - + return res, len(res) def raw_unicode_escape_encode( obj, errors='strict'): """None From fijal at codespeak.net Fri Jan 23 20:23:38 2009 From: fijal at codespeak.net (fijal at codespeak.net) Date: Fri, 23 Jan 2009 20:23:38 +0100 (CET) Subject: [pypy-svn] r61281 - in pypy/trunk/pypy/module/_codecs: . test Message-ID: <20090123192338.E629F1684C7@codespeak.net> Author: fijal Date: Fri Jan 23 20:23:36 2009 New Revision: 61281 Modified: pypy/trunk/pypy/module/_codecs/interp_codecs.py pypy/trunk/pypy/module/_codecs/test/test_codecs.py Log: a test and a fix Modified: pypy/trunk/pypy/module/_codecs/interp_codecs.py ============================================================================== --- pypy/trunk/pypy/module/_codecs/interp_codecs.py (original) +++ pypy/trunk/pypy/module/_codecs/interp_codecs.py Fri Jan 23 20:23:36 2009 @@ -210,7 +210,7 @@ state = space.fromcache(CodecState) func = getattr(runicode, rname) result = func(uni, len(uni), errors, state.encode_error_handler) - return space.newtuple([space.wrap(result), space.wrap(len(result))]) + return space.newtuple([space.wrap(result), space.wrap(len(uni))]) wrap_encoder.unwrap_spec = [ObjSpace, unicode, str] globals()[name] = wrap_encoder Modified: pypy/trunk/pypy/module/_codecs/test/test_codecs.py ============================================================================== --- pypy/trunk/pypy/module/_codecs/test/test_codecs.py (original) +++ pypy/trunk/pypy/module/_codecs/test/test_codecs.py Fri Jan 23 20:23:36 2009 @@ -506,6 +506,12 @@ assert exc.start == 0 assert exc.end == 3 + def test_utf_16_encode_decode(self): + import codecs + x = u'123abc' + assert codecs.getencoder('utf-16')(x) == ('\xff\xfe1\x002\x003\x00a\x00b\x00c\x00', 6) + assert codecs.getdecoder('utf-16')('\xff\xfe1\x002\x003\x00a\x00b\x00c\x00') == (x, 14) + class TestDirect: def test_charmap_encode(self): from pypy.module._codecs.app_codecs import charmap_encode From fijal at codespeak.net Fri Jan 23 20:32:08 2009 From: fijal at codespeak.net (fijal at codespeak.net) Date: Fri, 23 Jan 2009 20:32:08 +0100 (CET) Subject: [pypy-svn] r61282 - in pypy/trunk/pypy/module/_codecs: . test Message-ID: <20090123193208.A350216844B@codespeak.net> Author: fijal Date: Fri Jan 23 20:32:06 2009 New Revision: 61282 Modified: pypy/trunk/pypy/module/_codecs/app_codecs.py pypy/trunk/pypy/module/_codecs/test/test_codecs.py Log: a test and a fix Modified: pypy/trunk/pypy/module/_codecs/app_codecs.py ============================================================================== --- pypy/trunk/pypy/module/_codecs/app_codecs.py (original) +++ pypy/trunk/pypy/module/_codecs/app_codecs.py Fri Jan 23 20:32:06 2009 @@ -69,7 +69,7 @@ """ res = unicodeescape_string(obj, len(obj), 0) res = ''.join(res) - return res, len(res) + return res, len(obj) def unicode_escape_decode( data, errors='strict'): """None Modified: pypy/trunk/pypy/module/_codecs/test/test_codecs.py ============================================================================== --- pypy/trunk/pypy/module/_codecs/test/test_codecs.py (original) +++ pypy/trunk/pypy/module/_codecs/test/test_codecs.py Fri Jan 23 20:32:06 2009 @@ -1,5 +1,8 @@ import autopath from pypy.conftest import gettestobjspace +from pypy.module._codecs.app_codecs import unicode_escape_encode,\ + charmap_encode, charmap_decode, unicode_escape_decode + class AppTestCodecs: def setup_class(cls): @@ -514,11 +517,14 @@ class TestDirect: def test_charmap_encode(self): - from pypy.module._codecs.app_codecs import charmap_encode assert charmap_encode(u'xxx') == ('xxx', 3) assert charmap_encode(u'xxx', 'strict', {ord('x'): 'XX'}) == ('XXXXXX', 6) def test_charmap_decode(self): - from pypy.module._codecs.app_codecs import charmap_decode assert charmap_decode('xxx') == ('xxx', 3) assert charmap_decode('xxx', 'strict', {ord('x'): u'XX'}) == ('XXXXXX', 3) + + def test_unicode_escape(self): + assert unicode_escape_encode(u'abc') == ('\\x61\\x62\\x63', 3) + assert unicode_escape_decode('abc') == (u'abc', 3) + assert unicode_escape_decode('\\x61\\x62\\x63') == (u'abc', 12) From fijal at codespeak.net Fri Jan 23 20:43:52 2009 From: fijal at codespeak.net (fijal at codespeak.net) Date: Fri, 23 Jan 2009 20:43:52 +0100 (CET) Subject: [pypy-svn] r61283 - pypy/trunk/pypy/interpreter/test Message-ID: <20090123194352.A406F1684F1@codespeak.net> Author: fijal Date: Fri Jan 23 20:43:52 2009 New Revision: 61283 Modified: pypy/trunk/pypy/interpreter/test/test_zpy.py Log: according to docstring, this test goes away Modified: pypy/trunk/pypy/interpreter/test/test_zpy.py ============================================================================== --- pypy/trunk/pypy/interpreter/test/test_zpy.py (original) +++ pypy/trunk/pypy/interpreter/test/test_zpy.py Fri Jan 23 20:43:52 2009 @@ -13,14 +13,6 @@ (sys.executable, pypypath) ) assert output.splitlines()[-1] == pypypath -def test_prefix(): - """Make sure py.py sys.prefix and exec_prefix are the same as C Python's""" - cmd = "import sys;print sys.prefix;print sys.exec_prefix" - output = py.process.cmdexec( '''"%s" "%s" -c "%s" ''' % - (sys.executable, pypypath, cmd) ) - assert output.splitlines()[-2] == sys.prefix - assert output.splitlines()[-1] == sys.exec_prefix - def test_special_names(): """Test the __name__ and __file__ special global names""" cmd = "print __name__; print '__file__' in globals()" From fijal at codespeak.net Fri Jan 23 21:39:48 2009 From: fijal at codespeak.net (fijal at codespeak.net) Date: Fri, 23 Jan 2009 21:39:48 +0100 (CET) Subject: [pypy-svn] r61284 - in pypy/trunk/pypy/module/_codecs: . test Message-ID: <20090123203948.85CA01684BD@codespeak.net> Author: fijal Date: Fri Jan 23 21:39:46 2009 New Revision: 61284 Modified: pypy/trunk/pypy/module/_codecs/app_codecs.py pypy/trunk/pypy/module/_codecs/test/test_codecs.py Log: *cough* Modified: pypy/trunk/pypy/module/_codecs/app_codecs.py ============================================================================== --- pypy/trunk/pypy/module/_codecs/app_codecs.py (original) +++ pypy/trunk/pypy/module/_codecs/app_codecs.py Fri Jan 23 21:39:46 2009 @@ -564,7 +564,7 @@ pos -= 1 #/* Map 16-bit characters to '\uxxxx' */ - if (ord(ch) >= 256): + elif (ord(ch) >= 256): p += '\\' p += 'u' p += '%04x' % ord(ch) @@ -583,7 +583,7 @@ p += 'r' #/* Map non-printable US ASCII to '\xhh' */ - elif (ch < ' ' or ch >= 0x7F) : + elif (ch < ' ' or ord(ch) >= 0x7F) : p += '\\' p += 'x' p += '%02x' % ord(ch) Modified: pypy/trunk/pypy/module/_codecs/test/test_codecs.py ============================================================================== --- pypy/trunk/pypy/module/_codecs/test/test_codecs.py (original) +++ pypy/trunk/pypy/module/_codecs/test/test_codecs.py Fri Jan 23 21:39:46 2009 @@ -525,6 +525,6 @@ assert charmap_decode('xxx', 'strict', {ord('x'): u'XX'}) == ('XXXXXX', 3) def test_unicode_escape(self): - assert unicode_escape_encode(u'abc') == ('\\x61\\x62\\x63', 3) - assert unicode_escape_decode('abc') == (u'abc', 3) + assert unicode_escape_encode(u'abc') == (u'abc'.encode('unicode_escape'), 3) + assert unicode_escape_decode('abc') == (u'abc'.decode('unicode_escape'), 3) assert unicode_escape_decode('\\x61\\x62\\x63') == (u'abc', 12) From fijal at codespeak.net Fri Jan 23 21:43:36 2009 From: fijal at codespeak.net (fijal at codespeak.net) Date: Fri, 23 Jan 2009 21:43:36 +0100 (CET) Subject: [pypy-svn] r61285 - pypy/trunk/lib-python/modified-2.5.2/test Message-ID: <20090123204336.EF9C616844B@codespeak.net> Author: fijal Date: Fri Jan 23 21:43:36 2009 New Revision: 61285 Added: pypy/trunk/lib-python/modified-2.5.2/test/test_doctest.txt - copied unchanged from r61282, pypy/trunk/lib-python/2.5.2/test/test_doctest.txt pypy/trunk/lib-python/modified-2.5.2/test/test_doctest2.txt - copied unchanged from r61282, pypy/trunk/lib-python/2.5.2/test/test_doctest2.txt pypy/trunk/lib-python/modified-2.5.2/test/test_doctest3.txt - copied unchanged from r61282, pypy/trunk/lib-python/2.5.2/test/test_doctest3.txt pypy/trunk/lib-python/modified-2.5.2/test/test_doctest4.txt - copied unchanged from r61282, pypy/trunk/lib-python/2.5.2/test/test_doctest4.txt Log: copy doctests here From fijal at codespeak.net Fri Jan 23 21:46:02 2009 From: fijal at codespeak.net (fijal at codespeak.net) Date: Fri, 23 Jan 2009 21:46:02 +0100 (CET) Subject: [pypy-svn] r61286 - pypy/trunk/lib-python Message-ID: <20090123204602.B2F721684C5@codespeak.net> Author: fijal Date: Fri Jan 23 21:46:02 2009 New Revision: 61286 Modified: pypy/trunk/lib-python/failure_list.txt Log: update, test_codecs should pass by now Modified: pypy/trunk/lib-python/failure_list.txt ============================================================================== --- pypy/trunk/lib-python/failure_list.txt (original) +++ pypy/trunk/lib-python/failure_list.txt Fri Jan 23 21:46:02 2009 @@ -2,16 +2,12 @@ ------------------------------------------------------------------------------------------- test_builtin this is our issue383 test_cProfile ! we still need to fix module/cProfile to respect builtin calls -test_code obscure differences in code objects produced by compiler -test_codecs ! unknown # SHOULD BE FIXED NOW -test_coding ! hah. fix buildbot :-/ # SHOULD BE FIXED NOW test_compiler ! unknown test_ctypes ! implementation details but also some real crashes -test_decimal missing decimal.ROUND_05UP test_descrtut implementation detail only test_dis probably not worth the pain of whacking at the compiler test_distutils this is our issue367 -test_doctest ! unknown +test_doctest ! obscure differencies test_email_codecs test skipped test_enumerate same as test_iterlen test_file some more exceptions should be raised From cami at codespeak.net Fri Jan 23 23:11:16 2009 From: cami at codespeak.net (cami at codespeak.net) Date: Fri, 23 Jan 2009 23:11:16 +0100 (CET) Subject: [pypy-svn] r61287 - pypy/trunk/pypy/lang/gameboy/profiling Message-ID: <20090123221116.6FD85168429@codespeak.net> Author: cami Date: Fri Jan 23 23:11:14 2009 New Revision: 61287 Modified: pypy/trunk/pypy/lang/gameboy/profiling/profiling_cpu.py Log: removed old package Modified: pypy/trunk/pypy/lang/gameboy/profiling/profiling_cpu.py ============================================================================== --- pypy/trunk/pypy/lang/gameboy/profiling/profiling_cpu.py (original) +++ pypy/trunk/pypy/lang/gameboy/profiling/profiling_cpu.py Fri Jan 23 23:11:14 2009 @@ -1,7 +1,6 @@ from __future__ import generators from pypy.lang.gameboy.cpu import CPU -from pypy.lang.gameboy.debug import debug class ProfilingCPU(CPU): From fijal at codespeak.net Sat Jan 24 19:14:51 2009 From: fijal at codespeak.net (fijal at codespeak.net) Date: Sat, 24 Jan 2009 19:14:51 +0100 (CET) Subject: [pypy-svn] r61310 - in pypy/trunk/lib-python/modified-2.5.2: . test Message-ID: <20090124181451.0759A16853D@codespeak.net> Author: fijal Date: Sat Jan 24 19:14:49 2009 New Revision: 61310 Added: pypy/trunk/lib-python/modified-2.5.2/pyclbr.py - copied unchanged from r61282, pypy/trunk/lib-python/2.5.2/pyclbr.py pypy/trunk/lib-python/modified-2.5.2/test/pyclbr_input.py - copied unchanged from r61282, pypy/trunk/lib-python/2.5.2/test/pyclbr_input.py pypy/trunk/lib-python/modified-2.5.2/test/test_pyclbr.py - copied, changed from r61282, pypy/trunk/lib-python/2.5.2/test/test_pyclbr.py Log: pyclbr is stupid. It gets completely confused by 2.5.2/modified-2.5.2. I disable one check (pdb, which is 2.5.2) and move all this stuff here (because directory test is here), because I don't feel like teaching it this (and who uses this anyway) Copied: pypy/trunk/lib-python/modified-2.5.2/test/test_pyclbr.py (from r61282, pypy/trunk/lib-python/2.5.2/test/test_pyclbr.py) ============================================================================== --- pypy/trunk/lib-python/2.5.2/test/test_pyclbr.py (original) +++ pypy/trunk/lib-python/modified-2.5.2/test/test_pyclbr.py Sat Jan 24 19:14:49 2009 @@ -172,7 +172,7 @@ cm('aifc', ignore=('openfp',)) # set with = in module cm('Cookie') cm('sre_parse', ignore=('dump',)) # from sre_constants import * - cm('pdb') + #cm('pdb') cm('pydoc') # Tests for modules inside packages From fijal at codespeak.net Sat Jan 24 20:15:29 2009 From: fijal at codespeak.net (fijal at codespeak.net) Date: Sat, 24 Jan 2009 20:15:29 +0100 (CET) Subject: [pypy-svn] r61313 - in pypy/trunk/pypy/module/recparser: . test Message-ID: <20090124191529.BA2AC168509@codespeak.net> Author: fijal Date: Sat Jan 24 20:15:29 2009 New Revision: 61313 Modified: pypy/trunk/pypy/module/recparser/__init__.py pypy/trunk/pypy/module/recparser/pyparser.py pypy/trunk/pypy/module/recparser/test/test_parser.py Log: provide compilest (needed by test_parser) Modified: pypy/trunk/pypy/module/recparser/__init__.py ============================================================================== --- pypy/trunk/pypy/module/recparser/__init__.py (original) +++ pypy/trunk/pypy/module/recparser/__init__.py Sat Jan 24 20:15:29 2009 @@ -43,7 +43,7 @@ ## #'sequence2ast' : 'pyparser.sequence2ast', ## #'tuple2ast' : 'pyparser.tuple2ast', ## #'_pickler' : 'pyparser._pickler', -## #'compilest' : 'pyparser.compilest', + 'compilest' : 'pyparser.compilest', # PyPy extension 'source2ast' : "pyparser.source2ast", Modified: pypy/trunk/pypy/module/recparser/pyparser.py ============================================================================== --- pypy/trunk/pypy/module/recparser/pyparser.py (original) +++ pypy/trunk/pypy/module/recparser/pyparser.py Sat Jan 24 20:15:29 2009 @@ -108,17 +108,18 @@ """ return self.node.name == symbol.file_input - def descr_compile(self, w_filename = ""): + def descr_compile(self, space, filename = ""): """STType.compile() """ # We use the compiler module for that space = self.space w_tup = self.descr_totuple(line_info=True) - w_compileAST = mycompile(space, w_tup, w_filename) + w_compileAST = mycompile(space, w_tup, space.wrap(filename)) if self.isexpr(): return exprcompile(space, w_compileAST) else: return modcompile(space, w_compileAST) + descr_compile.unwrap_spec = ['self', ObjSpace, str] ASTType = STType @@ -353,3 +354,9 @@ ) Token.typedef = TypeDef("Token", GrammarElement.typedef ) + +def compilest(space, w_st): + "Compiles an ST object into a code object." + w_st = space.interp_w(STType, w_st) + return w_st.descr_compile(space) +compilest.unwrap_spec = [ObjSpace, W_Root] Modified: pypy/trunk/pypy/module/recparser/test/test_parser.py ============================================================================== --- pypy/trunk/pypy/module/recparser/test/test_parser.py (original) +++ pypy/trunk/pypy/module/recparser/test/test_parser.py Sat Jan 24 20:15:29 2009 @@ -30,6 +30,13 @@ """.strip() parser.suite(src) + def test_compilest(self): + import parser + code = parser.compilest(parser.suite('x = 2 + 3')) + d = {} + exec code in d + assert d['x'] == 5 + class AppTestRecparserErrors: def setup_class(cls): cls.space = space From fijal at codespeak.net Sat Jan 24 21:08:58 2009 From: fijal at codespeak.net (fijal at codespeak.net) Date: Sat, 24 Jan 2009 21:08:58 +0100 (CET) Subject: [pypy-svn] r61316 - pypy/trunk/lib-python/modified-2.5.2/test Message-ID: <20090124200858.54A4316854D@codespeak.net> Author: fijal Date: Sat Jan 24 21:08:55 2009 New Revision: 61316 Added: pypy/trunk/lib-python/modified-2.5.2/test/test_site.py - copied, changed from r61282, pypy/trunk/lib-python/2.5.2/test/test_site.py Log: change time to pdb. rationale behind this is that pyrepl imports time which makes this test fail. we should probably try harder and find some unused module (at all) Copied: pypy/trunk/lib-python/modified-2.5.2/test/test_site.py (from r61282, pypy/trunk/lib-python/2.5.2/test/test_site.py) ============================================================================== --- pypy/trunk/lib-python/2.5.2/test/test_site.py (original) +++ pypy/trunk/lib-python/modified-2.5.2/test/test_site.py Sat Jan 24 21:08:55 2009 @@ -94,7 +94,7 @@ class PthFile(object): """Helper class for handling testing of .pth files""" - def __init__(self, filename_base=TESTFN, imported="time", + def __init__(self, filename_base=TESTFN, imported="pdb", good_dirname="__testdir__", bad_dirname="__bad"): """Initialize instance variables""" self.filename = filename_base + ".pth" From fijal at codespeak.net Sat Jan 24 21:10:48 2009 From: fijal at codespeak.net (fijal at codespeak.net) Date: Sat, 24 Jan 2009 21:10:48 +0100 (CET) Subject: [pypy-svn] r61317 - pypy/trunk/lib-python/modified-2.5.2 Message-ID: <20090124201048.2FAB1168551@codespeak.net> Author: fijal Date: Sat Jan 24 21:10:44 2009 New Revision: 61317 Modified: pypy/trunk/lib-python/modified-2.5.2/site.py Log: add a copyright (why not?) Modified: pypy/trunk/lib-python/modified-2.5.2/site.py ============================================================================== --- pypy/trunk/lib-python/modified-2.5.2/site.py (original) +++ pypy/trunk/lib-python/modified-2.5.2/site.py Sat Jan 24 21:10:44 2009 @@ -62,7 +62,6 @@ import os import __builtin__ - def makepath(*paths): dir = os.path.abspath(os.path.join(*paths)) return dir, os.path.normcase(dir) @@ -309,6 +308,7 @@ def setcopyright(): # XXX this is the PyPy-specific version. Should be unified with the above. + __builtin__.copyright = _Printer("copyright", sys.copyright) __builtin__.credits = _Printer( "credits", "PyPy is maintained by the PyPy developers: http://codespeak.net/pypy") From fijal at codespeak.net Sat Jan 24 21:11:10 2009 From: fijal at codespeak.net (fijal at codespeak.net) Date: Sat, 24 Jan 2009 21:11:10 +0100 (CET) Subject: [pypy-svn] r61318 - pypy/trunk/pypy/module/sys Message-ID: <20090124201110.D5E29168551@codespeak.net> Author: fijal Date: Sat Jan 24 21:11:10 2009 New Revision: 61318 Modified: pypy/trunk/pypy/module/sys/app.py Log: adapt Modified: pypy/trunk/pypy/module/sys/app.py ============================================================================== --- pypy/trunk/pypy/module/sys/app.py (original) +++ pypy/trunk/pypy/module/sys/app.py Sat Jan 24 21:11:10 2009 @@ -43,7 +43,7 @@ return None copyright_str = """ -Copyright 2003-2008 PyPy development team. +Copyright 2003-2009 PyPy development team. All rights reserved. For further information see http://www.codespeak.net/pypy. From fijal at codespeak.net Sun Jan 25 11:11:49 2009 From: fijal at codespeak.net (fijal at codespeak.net) Date: Sun, 25 Jan 2009 11:11:49 +0100 (CET) Subject: [pypy-svn] r61322 - in pypy/trunk/pypy/interpreter: . astcompiler/test pyparser test Message-ID: <20090125101149.6C636168512@codespeak.net> Author: fijal Date: Sun Jan 25 11:11:47 2009 New Revision: 61322 Modified: pypy/trunk/pypy/interpreter/astcompiler/test/test_compiler.py pypy/trunk/pypy/interpreter/pycompiler.py pypy/trunk/pypy/interpreter/pyparser/error.py pypy/trunk/pypy/interpreter/pyparser/grammar.py pypy/trunk/pypy/interpreter/pyparser/pythonparse.py pypy/trunk/pypy/interpreter/test/test_compiler.py Log: a go at IndentationError. not fixing now everything yet Modified: pypy/trunk/pypy/interpreter/astcompiler/test/test_compiler.py ============================================================================== --- pypy/trunk/pypy/interpreter/astcompiler/test/test_compiler.py (original) +++ pypy/trunk/pypy/interpreter/astcompiler/test/test_compiler.py Sun Jan 25 11:11:47 2009 @@ -630,3 +630,27 @@ """) decl = str(decl) + '\n' yield self.simple_test, decl, 'r', None + + def test_indentation_error(self): + source = py.code.Source(""" + x + y + """) + try: + self.simple_test(source, None, None) + except IndentationError, e: + assert e.msg == 'unexpected indent' + else: + raise Exception("DID NOT RAISE") + + def test_no_indent(self): + source = py.code.Source(""" + def f(): + xxx + """) + try: + self.simple_test(source, None, None) + except IndentationError, e: + assert e.msg == 'expected an indented block' + else: + raise Exception("DID NOT RAISE") Modified: pypy/trunk/pypy/interpreter/pycompiler.py ============================================================================== --- pypy/trunk/pypy/interpreter/pycompiler.py (original) +++ pypy/trunk/pypy/interpreter/pycompiler.py Sun Jan 25 11:11:47 2009 @@ -227,7 +227,7 @@ self.compiler_flags = self.futureFlags.allowed_flags def compile(self, source, filename, mode, flags): - from pypy.interpreter.pyparser.error import SyntaxError + from pypy.interpreter.pyparser.error import SyntaxError, IndentationError from pypy.interpreter import astcompiler from pypy.interpreter.astcompiler.pycodegen import ModuleCodeGenerator from pypy.interpreter.astcompiler.pycodegen import InteractiveCodeGenerator @@ -252,10 +252,12 @@ self.parser.parse_source(source, mode, builder, flags) ast_tree = builder.rule_stack[-1] encoding = builder.source_encoding + except IndentationError, e: + raise OperationError(space.w_IndentationError, + e.wrap_info(space, filename)) except SyntaxError, e: raise OperationError(space.w_SyntaxError, e.wrap_info(space, filename)) - ast_tree = opt.optimize_ast_tree(space, ast_tree) if not space.is_w(self.w_compile_hook, space.w_None): Modified: pypy/trunk/pypy/interpreter/pyparser/error.py ============================================================================== --- pypy/trunk/pypy/interpreter/pyparser/error.py (original) +++ pypy/trunk/pypy/interpreter/pyparser/error.py Sun Jan 25 11:11:47 2009 @@ -23,6 +23,8 @@ self.offset, self.text) +class IndentationError(SyntaxError): + pass class ASTError(Exception): def __init__(self, msg, ast_node ): Modified: pypy/trunk/pypy/interpreter/pyparser/grammar.py ============================================================================== --- pypy/trunk/pypy/interpreter/pyparser/grammar.py (original) +++ pypy/trunk/pypy/interpreter/pyparser/grammar.py Sun Jan 25 11:11:47 2009 @@ -188,7 +188,6 @@ emptytoken_in_first_set = False _match_cache = None args = [] - symbols = {} # dirty trick to provide a symbols mapping while printing (and not putting it in every object) _attrs_ = ['parser', 'codename', 'args', Modified: pypy/trunk/pypy/interpreter/pyparser/pythonparse.py ============================================================================== --- pypy/trunk/pypy/interpreter/pyparser/pythonparse.py (original) +++ pypy/trunk/pypy/interpreter/pyparser/pythonparse.py Sun Jan 25 11:11:47 2009 @@ -6,7 +6,7 @@ """ from pypy.interpreter import gateway from pypy.interpreter.error import OperationError -from pypy.interpreter.pyparser.error import SyntaxError +from pypy.interpreter.pyparser.error import SyntaxError, IndentationError from pypy.interpreter.pyparser.pythonlexer import Source, match_encoding_declaration from pypy.interpreter.astcompiler.consts import CO_FUTURE_WITH_STATEMENT import pypy.interpreter.pyparser.pytoken as pytoken @@ -140,8 +140,11 @@ if not target.match(src, builder): tok, line, lnum, pos = src.most_recent_token() + if tok.codename == self.tokens['INDENT']: + raise IndentationError("unexpected indent", lnum, pos, line) + if tok.codename == self.tokens['DEDENT']: + raise IndentationError("unexpected dedent", lnum, pos, line) raise SyntaxError("invalid syntax", lnum, pos, line) - # return None return builder def update_rules_references(self): Modified: pypy/trunk/pypy/interpreter/test/test_compiler.py ============================================================================== --- pypy/trunk/pypy/interpreter/test/test_compiler.py (original) +++ pypy/trunk/pypy/interpreter/test/test_compiler.py Sun Jan 25 11:11:47 2009 @@ -750,4 +750,16 @@ output = s.getvalue() assert 'BINARY_ADD' not in output +class AppTestExceptions: + def test_indentation_error(self): + source = """if 1: + x + y + """ + try: + exec source + except IndentationError: + pass + else: + raise Exception("DID NOT RAISE") From fijal at codespeak.net Sun Jan 25 12:25:46 2009 From: fijal at codespeak.net (fijal at codespeak.net) Date: Sun, 25 Jan 2009 12:25:46 +0100 (CET) Subject: [pypy-svn] r61323 - in pypy/trunk/pypy/interpreter: . test Message-ID: <20090125112546.DF51E16856F@codespeak.net> Author: fijal Date: Sun Jan 25 12:25:44 2009 New Revision: 61323 Modified: pypy/trunk/pypy/interpreter/baseobjspace.py pypy/trunk/pypy/interpreter/executioncontext.py pypy/trunk/pypy/interpreter/test/test_executioncontext.py Log: A test and a fix for: a) a potential segfault (None being passed to applevel) b) for events Modified: pypy/trunk/pypy/interpreter/baseobjspace.py ============================================================================== --- pypy/trunk/pypy/interpreter/baseobjspace.py (original) +++ pypy/trunk/pypy/interpreter/baseobjspace.py Sun Jan 25 12:25:44 2009 @@ -756,7 +756,7 @@ except OperationError, e: ec.c_exception_trace(frame, e.w_value) raise - ec.c_return_trace(frame, w_res) + ec.c_return_trace(frame, w_func) return w_res def call_method(self, w_obj, methname, *arg_w): Modified: pypy/trunk/pypy/interpreter/executioncontext.py ============================================================================== --- pypy/trunk/pypy/interpreter/executioncontext.py (original) +++ pypy/trunk/pypy/interpreter/executioncontext.py Sun Jan 25 12:25:44 2009 @@ -42,7 +42,7 @@ def leave(self, frame): if self.profilefunc: - self._trace(frame, 'leaveframe', None) + self._trace(frame, 'leaveframe', self.space.w_None) if not frame.hide(): self.framestack.pop() Modified: pypy/trunk/pypy/interpreter/test/test_executioncontext.py ============================================================================== --- pypy/trunk/pypy/interpreter/test/test_executioncontext.py (original) +++ pypy/trunk/pypy/interpreter/test/test_executioncontext.py Sun Jan 25 12:25:44 2009 @@ -181,7 +181,7 @@ import sys l = [] def profile(frame, event, arg): - l.append(event) + l.append((event, arg)) def bar(): sys.setprofile(profile) @@ -192,4 +192,5 @@ return l """) events = space.unwrap(w_events) - assert events == ['c_call', 'c_return', 'return', 'c_call'] + assert [i[0] for i in events] == ['c_call', 'c_return', 'return', 'c_call'] + assert events[0][1] == events[1][1] From fijal at codespeak.net Sun Jan 25 12:55:07 2009 From: fijal at codespeak.net (fijal at codespeak.net) Date: Sun, 25 Jan 2009 12:55:07 +0100 (CET) Subject: [pypy-svn] r61324 - in pypy/trunk/pypy/module/_lsprof: . test Message-ID: <20090125115507.793DA168567@codespeak.net> Author: fijal Date: Sun Jan 25 12:55:05 2009 New Revision: 61324 Modified: pypy/trunk/pypy/module/_lsprof/interp_lsprof.py pypy/trunk/pypy/module/_lsprof/test/test_cprofile.py Log: a progress with cProfile, there are still some glitches, but it mostly work. we need to decide if this is it or we want to make it a bit more compatible Modified: pypy/trunk/pypy/module/_lsprof/interp_lsprof.py ============================================================================== --- pypy/trunk/pypy/module/_lsprof/interp_lsprof.py (original) +++ pypy/trunk/pypy/module/_lsprof/interp_lsprof.py Sun Jan 25 12:55:05 2009 @@ -4,6 +4,7 @@ from pypy.interpreter.typedef import (TypeDef, GetSetProperty, interp_attrproperty) from pypy.interpreter.gateway import interp2app, NoneNotWrapped +from pypy.interpreter.function import Method, Function import time, sys class W_StatsEntry(Wrappable): @@ -30,9 +31,12 @@ self.tt, self.it, calls_repr)) repr.unwrap_spec = ['self', ObjSpace] + def get_code(space, self): + return self.frame + W_StatsEntry.typedef = TypeDef( 'StatsEntry', - code = interp_attrproperty('frame', W_StatsEntry), + code = GetSetProperty(W_StatsEntry.get_code), callcount = interp_attrproperty('callcount', W_StatsEntry), reccallcount = interp_attrproperty('reccallcount', W_StatsEntry), inlinetime = interp_attrproperty('it', W_StatsEntry), @@ -55,9 +59,12 @@ frame_repr, self.callcount, self.reccallcount, self.tt, self.it)) repr.unwrap_spec = ['self', ObjSpace] + def get_code(space, self): + return self.frame + W_StatsSubEntry.typedef = TypeDef( 'SubStatsEntry', - code = interp_attrproperty('frame', W_StatsSubEntry), + code = GetSetProperty(W_StatsSubEntry.get_code), callcount = interp_attrproperty('callcount', W_StatsSubEntry), reccallcount = interp_attrproperty('reccallcount', W_StatsSubEntry), inlinetime = interp_attrproperty('it', W_StatsSubEntry), @@ -65,9 +72,9 @@ __repr__ = interp2app(W_StatsSubEntry.repr), ) -def stats(space, data, factor): +def stats(space, values, factor): l_w = [] - for v in data.values(): + for v in values: if v.callcount != 0: l_w.append(v.stats(space, factor)) return space.newlist(l_w) @@ -151,15 +158,33 @@ subentry.recursivecallcount += 1 subentry.it += it subentry.callcount += 1 + +def create_spec(space, w_arg): + if isinstance(w_arg, Method): + return "{method '%s' of '%s' object}" % (w_arg.w_function.name, w_arg.w_class.name) + elif isinstance(w_arg, Function): + return '{%s function}' % (w_arg.name,) + else: + return '{!!!unknown!!!}' def lsprof_call(space, w_self, frame, event, w_arg): assert isinstance(w_self, W_Profiler) if event == 'call': - w_self._enter_call(frame.getcode()) + code = frame.getcode() + w_self._enter_call(code) elif event == 'return': - w_self._enter_return(frame.getcode()) + code = frame.getcode() + w_self._enter_return(code) + elif event == 'c_call': + if w_self.builtins: + key = create_spec(space, w_arg) + w_self._enter_builtin_call(key) + elif event == 'c_return': + if w_self.builtins: + key = create_spec(space, w_arg) + w_self._enter_builtin_return(key) else: - # we don't support builtin calls here, let's ignore them + # ignore or raise an exception??? pass class W_Profiler(Wrappable): @@ -169,10 +194,8 @@ self.current_context = None self.w_callable = w_callable self.time_unit = time_unit - # XXX _lsprof uses rotatingtree. We use plain dict here, - # not sure how big difference is, but we should probably - # implement rotating tree self.data = {} + self.builtin_data = {} self.space = space def timer(self): @@ -189,7 +212,7 @@ enable.unwrap_spec = ['self', ObjSpace, bool, bool] def _enter_call(self, f_code): - # we have superb gc, no point in freelist :) + # we have a superb gc, no point in freelist :) try: entry = self.data[f_code] except KeyError: @@ -208,6 +231,25 @@ pass self.current_context = context.previous + def _enter_builtin_call(self, key): + try: + entry = self.builtin_data[key] + except KeyError: + entry = ProfilerEntry(self.space.wrap(key)) + self.builtin_data[key] = entry + self.current_context = ProfilerContext(self, entry) + + def _enter_builtin_return(self, key): + context = self.current_context + if context is None: + return + try: + entry = self.builtin_data[key] + context._stop(self, entry) + except KeyError: + pass + self.current_context = context.previous + def _flush_unmatched(self): context = self.current_context while context: @@ -230,7 +272,8 @@ factor = self.time_unit else: factor = 1.0 / sys.maxint - return stats(space, self.data, factor) + return stats(space, self.data.values() + self.builtin_data.values(), + factor) getstats.unwrap_spec = ['self', ObjSpace] def descr_new_profile(space, w_type, w_callable=NoneNotWrapped, time_unit=0.0, Modified: pypy/trunk/pypy/module/_lsprof/test/test_cprofile.py ============================================================================== --- pypy/trunk/pypy/module/_lsprof/test/test_cprofile.py (original) +++ pypy/trunk/pypy/module/_lsprof/test/test_cprofile.py Sun Jan 25 12:55:05 2009 @@ -9,11 +9,11 @@ cls.space = space cls.w_file = space.wrap(__file__) - def test_direct(self): + def xtest_direct(self): import _lsprof def getticks(): return len(ticks) - prof = _lsprof.Profiler(getticks, 0.25, True, False) + prof = _lsprof.Profiler(getticks, 0.25, True, True) ticks = [] def bar(m): ticks.append(1) @@ -28,27 +28,29 @@ bar(n+1) ticks.append(1) spam(n+2) - prof.enable() + prof.enable(builtins=True) foo(0) prof.disable() assert len(ticks) == 16 stats = prof.getstats() entries = {} for entry in stats: - assert hasattr(entry.code, 'co_name') - entries[entry.code.co_name] = entry + if not hasattr(entry.code, 'co_name'): + print entry.code + else: + entries[entry.code.co_name] = entry efoo = entries['foo'] assert efoo.callcount == 2 assert efoo.reccallcount == 1 assert efoo.inlinetime == 1.0 assert efoo.totaltime == 4.0 - assert len(efoo.calls) == 2 + assert len(efoo.calls) == 6 ebar = entries['bar'] assert ebar.callcount == 6 assert ebar.reccallcount == 3 assert ebar.inlinetime == 3.0 assert ebar.totaltime == 3.5 - assert len(ebar.calls) == 1 + assert len(ebar.calls) == 13 espam = entries['spam'] assert espam.callcount == 2 assert espam.reccallcount == 0 @@ -56,7 +58,8 @@ assert espam.totaltime == 1.0 assert len(espam.calls) == 1 - foo2bar, foo2spam = efoo.calls + foo2spam = efoo.calls[-2] + foo2bar = efoo.calls[0] if foo2bar.code.co_name == 'spam': foo2bar, foo2spam = foo2spam, foo2bar assert foo2bar.code.co_name == 'bar' @@ -70,14 +73,14 @@ assert foo2spam.inlinetime == 0.0 assert foo2spam.totaltime == 1.0 - bar2foo, = ebar.calls + bar2foo = ebar.calls[-3] assert bar2foo.code.co_name == 'foo' assert bar2foo.callcount == 1 assert bar2foo.reccallcount == 0 assert bar2foo.inlinetime == 0.5 assert bar2foo.totaltime == 2.0 - spam2bar, = espam.calls + spam2bar = espam.calls[0] assert spam2bar.code.co_name == 'bar' assert spam2bar.callcount == 2 assert spam2bar.reccallcount == 0 @@ -113,7 +116,6 @@ res, prof = do_profiling(Profile) assert res[0] == 1000 - skip("XXX FIX ME") for i, method in enumerate(methodnames): got = res[i + 1] expected = self.expected_output[method] @@ -138,12 +140,13 @@ expected_output = {} expected_output['print_stats'] = """\ - 126 function calls (106 primitive calls) in 1.000 CPU seconds + 128 function calls (108 primitive calls) in 1.000 CPU seconds Ordered by: standard name ncalls tottime percall cumtime percall filename:lineno(function) 1 0.000 0.000 1.000 1.000 :1() + 1 0.000 0.000 0.000 0.000 ?:1() 28 0.028 0.001 0.028 0.001 profilee.py:110(__getattr__) 1 0.270 0.270 1.000 1.000 profilee.py:25(testfunc) 23/3 0.150 0.007 0.170 0.057 profilee.py:35(factorial) From pedronis at codespeak.net Sun Jan 25 13:21:14 2009 From: pedronis at codespeak.net (pedronis at codespeak.net) Date: Sun, 25 Jan 2009 13:21:14 +0100 (CET) Subject: [pypy-svn] r61325 - pypy/trunk/pypy/tool Message-ID: <20090125122114.B71EE16856D@codespeak.net> Author: pedronis Date: Sun Jan 25 13:21:12 2009 New Revision: 61325 Added: pypy/trunk/pypy/tool/watchdog_nt.py Log: nt variant of watchdog that we had lying around Added: pypy/trunk/pypy/tool/watchdog_nt.py ============================================================================== --- (empty file) +++ pypy/trunk/pypy/tool/watchdog_nt.py Sun Jan 25 13:21:12 2009 @@ -0,0 +1,34 @@ +import sys, os +import threading +import win32api, pywintypes + +PROCESS_TERMINATE = 0x1 + +timeout = float(sys.argv[1]) +timedout = False + +def childkill(pid): + global timedout + timedout = True + sys.stderr.write("="*26 + "timedout" + "="*26 + "\n") + try: + win32api.TerminateProcess(pid, 1) + except pywintypes.error: + pass + +pid = os.spawnv(os.P_NOWAIT, sys.argv[2], sys.argv[2:]) + +t = threading.Timer(timeout, childkill, (pid,)) +t.start() +while True: + try: + pid, status = os.waitpid(pid, 0) + except KeyboardInterrupt: + continue + else: + t.cancel() + break + +#print 'status ', status >> 8 +sys.exit(status >> 8) + From pedronis at codespeak.net Sun Jan 25 13:24:31 2009 From: pedronis at codespeak.net (pedronis at codespeak.net) Date: Sun, 25 Jan 2009 13:24:31 +0100 (CET) Subject: [pypy-svn] r61326 - pypy/trunk/lib-python Message-ID: <20090125122431.2450516847F@codespeak.net> Author: pedronis Date: Sun Jan 25 13:24:30 2009 New Revision: 61326 Modified: pypy/trunk/lib-python/conftest.py Log: support for timing out lib-python tests on windows too Modified: pypy/trunk/lib-python/conftest.py ============================================================================== --- pypy/trunk/lib-python/conftest.py (original) +++ pypy/trunk/lib-python/conftest.py Sun Jan 25 13:24:30 2009 @@ -44,7 +44,9 @@ megapystone = float(timeout[:-2]) t, stone = pystone.Proc0(10000) pystonetime = t/stone - seconds = megapystone * 1000000 * pystonetime + seconds = megapystone * 1000000 * pystonetime + import pdb; pdb.set_trace() + return seconds return float(timeout) @@ -116,6 +118,8 @@ ''' % locals()) testmap = [ + RegrTest('test_experiment.py'), # yyy + RegrTest('test___all__.py', core=True), RegrTest('test___future__.py', core=True), RegrTest('test__locale.py'), @@ -552,7 +556,11 @@ python = sys.executable pypy_script = pypydir.join('bin', 'py.py') alarm_script = pypydir.join('tool', 'alarm.py') - watchdog_script = pypydir.join('tool', 'watchdog.py') + if sys.platform == 'win32': + watchdog_name = 'watchdog_nt.py' + else: + watchdog_name = 'watchdog.py' + watchdog_script = pypydir.join('tool', watchdog_name) regr_script = pypydir.join('tool', 'pytest', 'run-script', 'regrverbose.py') @@ -583,15 +591,17 @@ cmd = "%s %s %s %s" %( execpath, regrrun, regrrun_verbosity, fspath.purebasename) - if sys.platform != 'win32': - cmd = "%s %s %s %s" %( - python, watchdog_script, TIMEOUT, - cmd) + + # add watchdog for timing out + cmd = "%s %s %s %s" %( + python, watchdog_script, TIMEOUT, + cmd) else: cmd = "%s %s %d %s %s %s %s %s" %( python, alarm_script, TIMEOUT, pypy_script, sopt, regrrun, regrrun_verbosity, fspath.purebasename) + print cmd return cmd def runtest(self): From pedronis at codespeak.net Sun Jan 25 13:25:02 2009 From: pedronis at codespeak.net (pedronis at codespeak.net) Date: Sun, 25 Jan 2009 13:25:02 +0100 (CET) Subject: [pypy-svn] r61327 - pypy/build/bot2 Message-ID: <20090125122502.80A461684A8@codespeak.net> Author: pedronis Date: Sun Jan 25 13:25:01 2009 New Revision: 61327 Modified: pypy/build/bot2/TODO Log: that was working on linux, added support for windows too Modified: pypy/build/bot2/TODO ============================================================================== --- pypy/build/bot2/TODO (original) +++ pypy/build/bot2/TODO Sun Jan 25 13:25:01 2009 @@ -1,7 +1,5 @@ Issues (in descending priority order) ---------------------------------------- -- it seems there is no timeout detection anymore for the lib-python tests (?) ! - - (fijal) There is a bunch of exceptions that should be reported as skipped on view. TestSkipped, ResourceDenied comes to mind. Not sure what else From pedronis at codespeak.net Sun Jan 25 13:26:48 2009 From: pedronis at codespeak.net (pedronis at codespeak.net) Date: Sun, 25 Jan 2009 13:26:48 +0100 (CET) Subject: [pypy-svn] r61328 - pypy/trunk/lib-python Message-ID: <20090125122648.607A4168553@codespeak.net> Author: pedronis Date: Sun Jan 25 13:26:47 2009 New Revision: 61328 Modified: pypy/trunk/lib-python/conftest.py Log: oops, this debuggin stuff was not meant for being checked-in Modified: pypy/trunk/lib-python/conftest.py ============================================================================== --- pypy/trunk/lib-python/conftest.py (original) +++ pypy/trunk/lib-python/conftest.py Sun Jan 25 13:26:47 2009 @@ -45,8 +45,6 @@ t, stone = pystone.Proc0(10000) pystonetime = t/stone seconds = megapystone * 1000000 * pystonetime - import pdb; pdb.set_trace() - return seconds return float(timeout) @@ -118,8 +116,6 @@ ''' % locals()) testmap = [ - RegrTest('test_experiment.py'), # yyy - RegrTest('test___all__.py', core=True), RegrTest('test___future__.py', core=True), RegrTest('test__locale.py'), From pedronis at codespeak.net Sun Jan 25 13:27:31 2009 From: pedronis at codespeak.net (pedronis at codespeak.net) Date: Sun, 25 Jan 2009 13:27:31 +0100 (CET) Subject: [pypy-svn] r61329 - pypy/trunk/lib-python Message-ID: <20090125122731.7E2CE168553@codespeak.net> Author: pedronis Date: Sun Jan 25 13:27:28 2009 New Revision: 61329 Modified: pypy/trunk/lib-python/conftest.py Log: nor this print Modified: pypy/trunk/lib-python/conftest.py ============================================================================== --- pypy/trunk/lib-python/conftest.py (original) +++ pypy/trunk/lib-python/conftest.py Sun Jan 25 13:27:28 2009 @@ -597,7 +597,6 @@ python, alarm_script, TIMEOUT, pypy_script, sopt, regrrun, regrrun_verbosity, fspath.purebasename) - print cmd return cmd def runtest(self): From pedronis at codespeak.net Sun Jan 25 13:43:11 2009 From: pedronis at codespeak.net (pedronis at codespeak.net) Date: Sun, 25 Jan 2009 13:43:11 +0100 (CET) Subject: [pypy-svn] r61330 - in pypy/trunk: lib-python pypy/tool/pytest/run-script Message-ID: <20090125124311.AA4D9168573@codespeak.net> Author: pedronis Date: Sun Jan 25 13:43:11 2009 New Revision: 61330 Modified: pypy/trunk/lib-python/conftest.py pypy/trunk/pypy/tool/pytest/run-script/regrverbose.py Log: slightly messy but in-style support to acknowledge top-level TestSkipped(and subclasses) skips Modified: pypy/trunk/lib-python/conftest.py ============================================================================== --- pypy/trunk/lib-python/conftest.py (original) +++ pypy/trunk/lib-python/conftest.py Sun Jan 25 13:43:11 2009 @@ -614,7 +614,10 @@ else: msg = regrtest.skip py.test.skip(msg) - exit_status, test_stdout, test_stderr = self.getresult(regrtest) + (skipped, exit_status, test_stdout, + test_stderr) = self.getresult(regrtest) + if skipped: + py.test.skip(test_stderr.splitlines()[-1]) if exit_status: raise self.ExternalFailure(test_stdout, test_stderr) @@ -645,9 +648,12 @@ def getresult(self, regrtest): cmd = self.getinvocation(regrtest) exit_status, test_stdout, test_stderr = self.getstatusouterr(cmd) + skipped = False timedout = test_stderr.rfind(26*"=" + "timedout" + 26*"=") != -1 if not timedout: timedout = test_stderr.rfind("KeyboardInterrupt") != -1 + if test_stderr.rfind(26*"=" + "skipped" + 26*"=") != -1: + skipped = True outcome = 'OK' expectedpath = regrtest.getoutputpath() if not exit_status: @@ -668,7 +674,7 @@ else: outcome = "ERR" - return exit_status, test_stdout, test_stderr + return skipped, exit_status, test_stdout, test_stderr def _keywords(self): lst = list(py.test.collect.Item._keywords(self)) Modified: pypy/trunk/pypy/tool/pytest/run-script/regrverbose.py ============================================================================== --- pypy/trunk/pypy/tool/pytest/run-script/regrverbose.py (original) +++ pypy/trunk/pypy/tool/pytest/run-script/regrverbose.py Sun Jan 25 13:43:11 2009 @@ -5,9 +5,13 @@ sys.argv[:] = sys.argv[2:] modname = sys.argv[0] -impname = 'test.' + modname -mod = __import__(impname, globals(), locals(), [modname]) -indirect_test = getattr(mod, 'test_main', None) -if indirect_test is not None: - indirect_test() +impname = 'test.' + modname +try: + mod = __import__(impname, globals(), locals(), [modname]) + indirect_test = getattr(mod, 'test_main', None) + if indirect_test is not None: + indirect_test() +except test_support.TestSkipped: + sys.stderr.write("="*26 + "skipped" + "="*26 + "\n") + raise # else the test already ran during import From pedronis at codespeak.net Sun Jan 25 13:45:04 2009 From: pedronis at codespeak.net (pedronis at codespeak.net) Date: Sun, 25 Jan 2009 13:45:04 +0100 (CET) Subject: [pypy-svn] r61331 - pypy/build/bot2 Message-ID: <20090125124504.2D643168575@codespeak.net> Author: pedronis Date: Sun Jan 25 13:45:03 2009 New Revision: 61331 Modified: pypy/build/bot2/TODO Log: done for top-level ones, unittest itself doesn't recognize skips as such, the test affacted right now is test_compile I suppose it needs to be edited more to result passing Modified: pypy/build/bot2/TODO ============================================================================== --- pypy/build/bot2/TODO (original) +++ pypy/build/bot2/TODO Sun Jan 25 13:45:03 2009 @@ -1,9 +1,5 @@ Issues (in descending priority order) ---------------------------------------- -- (fijal) There is a bunch of exceptions that should be reported as skipped on view. - - TestSkipped, ResourceDenied comes to mind. Not sure what else - - slave for own test need pexect (seems not to be there on wyvern's python?) - move most buildbots to be over python 2.5 or 2.6 (LIKELY) From fijal at codespeak.net Sun Jan 25 14:23:45 2009 From: fijal at codespeak.net (fijal at codespeak.net) Date: Sun, 25 Jan 2009 14:23:45 +0100 (CET) Subject: [pypy-svn] r61332 - pypy/trunk/pypy/module/_lsprof Message-ID: <20090125132345.4EE4716857B@codespeak.net> Author: fijal Date: Sun Jan 25 14:23:42 2009 New Revision: 61332 Modified: pypy/trunk/pypy/module/_lsprof/interp_lsprof.py Log: fix translation Modified: pypy/trunk/pypy/module/_lsprof/interp_lsprof.py ============================================================================== --- pypy/trunk/pypy/module/_lsprof/interp_lsprof.py (original) +++ pypy/trunk/pypy/module/_lsprof/interp_lsprof.py Sun Jan 25 14:23:42 2009 @@ -161,7 +161,9 @@ def create_spec(space, w_arg): if isinstance(w_arg, Method): - return "{method '%s' of '%s' object}" % (w_arg.w_function.name, w_arg.w_class.name) + w_function = w_arg.w_function + assert isinstance(w_function, Function) + return "{method '%s' of '%s' object}" % (w_function.name, space.str_w(space.str(w_arg.w_class))) elif isinstance(w_arg, Function): return '{%s function}' % (w_arg.name,) else: From pedronis at codespeak.net Sun Jan 25 22:30:32 2009 From: pedronis at codespeak.net (pedronis at codespeak.net) Date: Sun, 25 Jan 2009 22:30:32 +0100 (CET) Subject: [pypy-svn] r61335 - in pypy/build/bot2/pypybuildbot: . test Message-ID: <20090125213032.E0694168533@codespeak.net> Author: pedronis Date: Sun Jan 25 22:30:29 2009 New Revision: 61335 Modified: pypy/build/bot2/pypybuildbot/summary.py pypy/build/bot2/pypybuildbot/test/test_summary.py Log: - solve an aligment problem when versions displayed have different numbers of digits - show the test run dates Modified: pypy/build/bot2/pypybuildbot/summary.py ============================================================================== --- pypy/build/bot2/pypybuildbot/summary.py (original) +++ pypy/build/bot2/pypybuildbot/summary.py Sun Jan 25 22:30:29 2009 @@ -136,7 +136,8 @@ step.getResults()[0] in (FAILURE, EXCEPTION)): failure = ' '.join(step.getText()) - run_info = {'URL': run_url, 'elapsed': pytest_elapsed or None} + run_info = {'URL': run_url, 'elapsed': pytest_elapsed or None, + 'times': build.getTimes()} outcome_set = RevisionOutcomeSet(rev, key, run_info) someresult = False if pytest_logs: @@ -272,18 +273,37 @@ def make_run_anchors_for(self, outcome_set): anchors = [] infos = sorted(outcome_set.get_run_infos().items()) + minend = None + maxend = None for cachekey, (run, info) in infos: builder = cachekey[0] anchors.append(' ') timing = "" if self.fixed_builder and info['elapsed'] is not None: timing = " in %s" % show_elapsed(info['elapsed']) + if info['times'][1] is not None: + day = time.localtime(info['times'][1])[:3] + if minend is None: + minend = day + else: + minend = min(minend, day) + if maxend is None: + maxend = day + else: + maxend = max(maxend, day) text = "%s [%d, %d F, %d s%s]" % (builder, run.numpassed, len(run.failed), len(run.skipped), timing) anchors.append(html.a(text, href=host_agnostic(info['URL']))) + if maxend is not None: + mintxt = time.strftime("%d %b", minend+(0,)*6) + maxtxt = time.strftime("%d %b", maxend+(0,)*6) + if maxend == minend: + anchors.append(' (%s)' % maxtxt) + else: + anchors.append(' (%s..%s)' % (mintxt, maxtxt)) return anchors def start_cat_branch(self, cat_branch): @@ -326,16 +346,18 @@ # rev return outcome_set.revision - def _label_anchor(self, outcome_set): + def _label_anchor(self, outcome_set, revsize): rev = outcome_set.revision if self.fixed_builder: pick = "builder=%s&builds=%d" % self._builder_num(outcome_set) else: pick = "recentrev=%d" % rev category, branch = self.cur_cat_branch - rev_anchor = html.a(str(rev), href="/summary?category=%s&branch=%s&%s" % + revtxt = str(rev) + rev_anchor = html.a(revtxt, href="/summary?category=%s&branch=%s&%s" % (category, branch, pick)) - return rev_anchor + rightalign = ' '*(revsize-len(revtxt)) + return [rev_anchor, rightalign] def add_section(self, outcome_sets): if not outcome_sets: @@ -344,15 +366,19 @@ for outcome_set in outcome_sets) by_label = sorted((self._label(outcome_set), outcome_set) for outcome_set in outcome_sets) + revs = [outcome_set.revision for outcome_set in outcome_sets] + lines = [] - align = 2*len(labels)-1+len(str(labels[-1])) + revsize = len(str(max(revs))) + + align = 2*len(labels)-1+revsize def bars(): return ' |'*len(lines) for label, outcome_set in by_label: count_failures = len(outcome_set.failed) count_skipped = len(outcome_set.skipped) - line = [bars(), ' ', self._label_anchor(outcome_set)] + line = [bars(), ' '] + self._label_anchor(outcome_set, revsize) line.append((align-len(line[0]))*" ") line.append(self.make_run_anchors_for(outcome_set)) line.append('\n') Modified: pypy/build/bot2/pypybuildbot/test/test_summary.py ============================================================================== --- pypy/build/bot2/pypybuildbot/test/test_summary.py (original) +++ pypy/build/bot2/pypybuildbot/test/test_summary.py Sun Jan 25 22:30:29 2009 @@ -636,4 +636,35 @@ assert "{foo}" in out assert "{bar}" in out - + def test_two_builds_different_rev_digits(self): + builder = status_builder.BuilderStatus('builder0') + add_builds(builder, [(999, "F TEST1\n. b"), + (1000, "F TEST1\n. b")]) + + s = summary.Summary() + req = FakeRequest([builder]) + out = s.body(req) + p999 = out.find('999') + p999builder0 = out.find('builder0', p999) + p1000 = out.find('1000') + p1000builder0 = out.find('builder0', p1000) + assert p999builder0-p999 == p1000builder0-p1000+1 + + def test_build_times(self): + builder1 = status_builder.BuilderStatus('builder1') + builder2 = status_builder.BuilderStatus('builder2') + + add_builds(builder1, [(60000, "F TEST1\n")]) + add_builds(builder2, [(60000, "F TEST2\n")]) + + builder1.getBuild(0).finished = 1228258800 # 3 Dec 2008 + builder2.getBuild(0).finished = 1228431600 # 5 Dec 2008 + + s = summary.Summary() + req = FakeRequest([builder1, builder2]) + out = s.body(req) + + assert '(03 Dec..05 Dec)' in out + + + From pedronis at codespeak.net Sun Jan 25 22:45:23 2009 From: pedronis at codespeak.net (pedronis at codespeak.net) Date: Sun, 25 Jan 2009 22:45:23 +0100 (CET) Subject: [pypy-svn] r61336 - pypy/build/bot2/pypybuildbot Message-ID: <20090125214523.A282916857A@codespeak.net> Author: pedronis Date: Sun Jan 25 22:45:23 2009 New Revision: 61336 Modified: pypy/build/bot2/pypybuildbot/summary.py Log: this should work in 2.4 hopefully Modified: pypy/build/bot2/pypybuildbot/summary.py ============================================================================== --- pypy/build/bot2/pypybuildbot/summary.py (original) +++ pypy/build/bot2/pypybuildbot/summary.py Sun Jan 25 22:45:23 2009 @@ -1,4 +1,4 @@ -import time, urlparse, urllib +import time, datetime, urlparse, urllib import py html = py.xml.html @@ -298,8 +298,8 @@ timing) anchors.append(html.a(text, href=host_agnostic(info['URL']))) if maxend is not None: - mintxt = time.strftime("%d %b", minend+(0,)*6) - maxtxt = time.strftime("%d %b", maxend+(0,)*6) + mintxt = datetime.date(*minend).strftime("%d %b") + maxtxt = datetime.date(*maxend).strftime("%d %b") if maxend == minend: anchors.append(' (%s)' % maxtxt) else: From afa at codespeak.net Sun Jan 25 22:58:58 2009 From: afa at codespeak.net (afa at codespeak.net) Date: Sun, 25 Jan 2009 22:58:58 +0100 (CET) Subject: [pypy-svn] r61337 - pypy/trunk/pypy/lib Message-ID: <20090125215858.7356F16857A@codespeak.net> Author: afa Date: Sun Jan 25 22:58:57 2009 New Revision: 61337 Modified: pypy/trunk/pypy/lib/resource.py Log: "import resource" should raise ImportError on Windows. CPython does not even compile this module. Modified: pypy/trunk/pypy/lib/resource.py ============================================================================== --- pypy/trunk/pypy/lib/resource.py (original) +++ pypy/trunk/pypy/lib/resource.py Sun Jan 25 22:58:57 2009 @@ -1,3 +1,7 @@ +import sys +if sys.platform == 'win32': + raise ImportError('resource module not available for win32') + from ctypes_support import standard_c_lib as libc from ctypes_support import get_errno from ctypes import Structure, c_int, c_long, byref From afa at codespeak.net Sun Jan 25 23:08:41 2009 From: afa at codespeak.net (afa at codespeak.net) Date: Sun, 25 Jan 2009 23:08:41 +0100 (CET) Subject: [pypy-svn] r61338 - pypy/trunk/pypy/module/posix Message-ID: <20090125220841.958F61684D0@codespeak.net> Author: afa Date: Sun Jan 25 23:08:41 2009 New Revision: 61338 Modified: pypy/trunk/pypy/module/posix/app_posix.py Log: (Mostly an indentation change:) This implementation of popen is specific to posix. Modified: pypy/trunk/pypy/module/posix/app_posix.py ============================================================================== --- pypy/trunk/pypy/module/posix/app_posix.py (original) +++ pypy/trunk/pypy/module/posix/app_posix.py Sun Jan 25 23:08:41 2009 @@ -71,70 +71,71 @@ return f -# __________ only if we have os.fork() __________ +# Implement popen() for platforms which have os.fork() +if osname == 'posix': -class popenfile(file): - _childpid = None + class popenfile(file): + _childpid = None - def close(self): - import os - file.close(self) - pid = self._childpid - if pid is not None: - self._childpid = None - return os.waitpid(pid, 0)[1] - return 0 - __del__ = close # as in CPython, __del__ may call os.waitpid() - -def popen(command, mode='r', bufsize=-1): - """popen(command [, mode='r' [, bufsize]]) -> pipe - - Open a pipe to/from a command returning a file object.""" - - from popen2 import MAXFD - import os, gc - - def try_close(fd): - try: - os.close(fd) - except OSError: - pass - - if not mode.startswith('r') and not mode.startswith('w'): - raise ValueError("invalid mode %r" % (mode,)) - read_end, write_end = os.pipe() - try: - gc.disable_finalizers() + def close(self): + import os + file.close(self) + pid = self._childpid + if pid is not None: + self._childpid = None + return os.waitpid(pid, 0)[1] + return 0 + __del__ = close # as in CPython, __del__ may call os.waitpid() + + def popen(command, mode='r', bufsize=-1): + """popen(command [, mode='r' [, bufsize]]) -> pipe + + Open a pipe to/from a command returning a file object.""" + + from popen2 import MAXFD + import os, gc + + def try_close(fd): + try: + os.close(fd) + except OSError: + pass + + if not mode.startswith('r') and not mode.startswith('w'): + raise ValueError("invalid mode %r" % (mode,)) + read_end, write_end = os.pipe() try: - childpid = os.fork() - if childpid == 0: - # in the child - try: - if mode.startswith('r'): - os.dup2(write_end, 1) - os.close(read_end) - else: - os.dup2(read_end, 0) - os.close(write_end) - os.closerange(3, MAXFD) - cmd = ['/bin/sh', '-c', command] - os.execvp(cmd[0], cmd) - finally: - os._exit(1) - finally: - gc.enable_finalizers() - - if mode.startswith('r'): - os.close(write_end) - fd = read_end - else: - os.close(read_end) - fd = write_end - g = popenfile.fdopen(fd, mode, bufsize) - g._childpid = childpid - return g - - except Exception, e: - try_close(write_end) - try_close(read_end) - raise Exception, e # bare 'raise' does not work here :-( + gc.disable_finalizers() + try: + childpid = os.fork() + if childpid == 0: + # in the child + try: + if mode.startswith('r'): + os.dup2(write_end, 1) + os.close(read_end) + else: + os.dup2(read_end, 0) + os.close(write_end) + os.closerange(3, MAXFD) + cmd = ['/bin/sh', '-c', command] + os.execvp(cmd[0], cmd) + finally: + os._exit(1) + finally: + gc.enable_finalizers() + + if mode.startswith('r'): + os.close(write_end) + fd = read_end + else: + os.close(read_end) + fd = write_end + g = popenfile.fdopen(fd, mode, bufsize) + g._childpid = childpid + return g + + except Exception, e: + try_close(write_end) + try_close(read_end) + raise Exception, e # bare 'raise' does not work here :-( From afa at codespeak.net Sun Jan 25 23:56:36 2009 From: afa at codespeak.net (afa at codespeak.net) Date: Sun, 25 Jan 2009 23:56:36 +0100 (CET) Subject: [pypy-svn] r61339 - pypy/trunk/pypy/lib Message-ID: <20090125225636.3DD3016850C@codespeak.net> Author: afa Date: Sun Jan 25 23:56:34 2009 New Revision: 61339 Modified: pypy/trunk/pypy/lib/_subprocess.py Log: Missing constant in the win32 version of the _subprocess module. Should fix some tests in test_subprocess Modified: pypy/trunk/pypy/lib/_subprocess.py ============================================================================== --- pypy/trunk/pypy/lib/_subprocess.py (original) +++ pypy/trunk/pypy/lib/_subprocess.py Sun Jan 25 23:56:34 2009 @@ -155,6 +155,7 @@ raise WindowsError("Error") return _handle(pi.hProcess), _handle(pi.hThread), pi.dwProcessID, pi.dwThreadID +STARTF_USESHOWWINDOW = 0x001 STARTF_USESTDHANDLES = 0x100 def WaitForSingleObject(handle, milliseconds): From afa at codespeak.net Mon Jan 26 00:14:29 2009 From: afa at codespeak.net (afa at codespeak.net) Date: Mon, 26 Jan 2009 00:14:29 +0100 (CET) Subject: [pypy-svn] r61341 - pypy/trunk/pypy/lib Message-ID: <20090125231429.CD6041684D4@codespeak.net> Author: afa Date: Mon Jan 26 00:14:29 2009 New Revision: 61341 Modified: pypy/trunk/pypy/lib/_subprocess.py Log: More constants/functions missing from _subprocess Modified: pypy/trunk/pypy/lib/_subprocess.py ============================================================================== --- pypy/trunk/pypy/lib/_subprocess.py (original) +++ pypy/trunk/pypy/lib/_subprocess.py Mon Jan 26 00:14:29 2009 @@ -24,6 +24,10 @@ _GetCurrentProcess.argtypes = [] _GetCurrentProcess.restype = ctypes.c_int +GetVersion = _kernel32.GetVersion +GetVersion.argtypes = [] +GetVersion.restype = ctypes.c_int + _DuplicateHandle = _kernel32.DuplicateHandle _DuplicateHandle.argtypes = [ctypes.c_int, ctypes.c_int, ctypes.c_int, ctypes.POINTER(ctypes.c_int), @@ -157,6 +161,8 @@ return _handle(pi.hProcess), _handle(pi.hThread), pi.dwProcessID, pi.dwThreadID STARTF_USESHOWWINDOW = 0x001 STARTF_USESTDHANDLES = 0x100 +SW_HIDE = 0 +CREATE_NEW_CONSOLE = 0x010 def WaitForSingleObject(handle, milliseconds): res = _WaitForSingleObject(handle.handle, milliseconds) From afa at codespeak.net Mon Jan 26 01:02:32 2009 From: afa at codespeak.net (afa at codespeak.net) Date: Mon, 26 Jan 2009 01:02:32 +0100 (CET) Subject: [pypy-svn] r61342 - pypy/trunk/pypy/module/posix Message-ID: <20090126000232.61AD51684EB@codespeak.net> Author: afa Date: Mon Jan 26 01:02:29 2009 New Revision: 61342 Modified: pypy/trunk/pypy/module/posix/app_posix.py Log: Intermediate check-in of an implementation of os.popen() using subprocess. Based on the py3k's one. Not yet exposed, because it blocks (it seems to always return stdin?) I will test and fix on another machine. Modified: pypy/trunk/pypy/module/posix/app_posix.py ============================================================================== --- pypy/trunk/pypy/module/posix/app_posix.py (original) +++ pypy/trunk/pypy/module/posix/app_posix.py Mon Jan 26 01:02:29 2009 @@ -139,3 +139,41 @@ try_close(write_end) try_close(read_end) raise Exception, e # bare 'raise' does not work here :-( + +else: + # Supply os.popen() based on subprocess + def popen(cmd, mode="r", buffering=None): + if not isinstance(cmd, str): + raise TypeError("invalid cmd type (%s, expected string)" % + (type(cmd),)) + if mode not in ("r", "w"): + raise ValueError("invalid mode %r" % (mode,)) + if buffering is None: + buffering = 0 + import subprocess + if mode == "r": + proc = subprocess.Popen(cmd, + shell=True, + stdout=subprocess.PIPE, + bufsize=buffering) + return _wrap_close(proc.stdout, proc) + else: + proc = subprocess.Popen(cmd, + shell=True, + stdin=subprocess.PIPE, + bufsize=buffering) + return _wrap_close(proc.stdin, proc) + + # A proxy for a file whose close waits for the process + class _wrap_close(object): + def __init__(self, stream, proc): + self._stream = stream + self._proc = proc + def close(self): + self._stream.close() + return self._proc.wait() + __del__ = close + def __getattr__(self, name): + return getattr(self._stream, name) + def __iter__(self): + return iter(self._stream) From hpk at codespeak.net Mon Jan 26 09:17:13 2009 From: hpk at codespeak.net (hpk at codespeak.net) Date: Mon, 26 Jan 2009 09:17:13 +0100 (CET) Subject: [pypy-svn] r61344 - pypy/extradoc/talk/openbossa2009 Message-ID: <20090126081713.05FA8168520@codespeak.net> Author: hpk Date: Mon Jan 26 09:17:12 2009 New Revision: 61344 Added: pypy/extradoc/talk/openbossa2009/ pypy/extradoc/talk/openbossa2009/holger-bio.txt (contents, props changed) pypy/extradoc/talk/openbossa2009/pypy-talk-abstract.txt (contents, props changed) Log: my bio and abstract that i want to send to the openbossa people in brazil. Added: pypy/extradoc/talk/openbossa2009/holger-bio.txt ============================================================================== --- (empty file) +++ pypy/extradoc/talk/openbossa2009/holger-bio.txt Mon Jan 26 09:17:12 2009 @@ -0,0 +1,10 @@ + +Holger started with game and general computer hacking ages +ago, went through university, some consulting and bank +contracting until finally arriving at working in free software +environments fulltime. He founded merlinux in 2004, which +contracts Python specialists. Holger Krekel is a co-founder of +the PyPy project, both a new Python implemenation and a +framework for implementing dynamic languages. Holger also +authors a well known python testing framework and is interested +in new paradigms for deploying programs in networks. Added: pypy/extradoc/talk/openbossa2009/pypy-talk-abstract.txt ============================================================================== --- (empty file) +++ pypy/extradoc/talk/openbossa2009/pypy-talk-abstract.txt Mon Jan 26 09:17:12 2009 @@ -0,0 +1,12 @@ + +PyPy: status and mobile perspectives +----------------------------------------- + +This talk will discuss the new PyPy Python implementation with +respect to RAM usage, startup time and speed. Numbers are +taken from the recent port to the Maemo platform. We'll +assess compliancy and features of the imminent 1.1 release, +and about its unique sandboxing and OS-virtualization features. +Eventually we present and discuss next steps for making it a +replacement for CPython and for extending Python usage on +mobile phones in general. From afa at codespeak.net Mon Jan 26 09:32:49 2009 From: afa at codespeak.net (afa at codespeak.net) Date: Mon, 26 Jan 2009 09:32:49 +0100 (CET) Subject: [pypy-svn] r61345 - pypy/trunk/pypy/translator/platform Message-ID: <20090126083249.B5C5B1684EB@codespeak.net> Author: afa Date: Mon Jan 26 09:32:46 2009 New Revision: 61345 Modified: pypy/trunk/pypy/translator/platform/windows.py Log: In debug builds, increase stack size to 8Mb Modified: pypy/trunk/pypy/translator/platform/windows.py ============================================================================== --- pypy/trunk/pypy/translator/platform/windows.py (original) +++ pypy/trunk/pypy/translator/platform/windows.py Mon Jan 26 09:32:46 2009 @@ -77,7 +77,7 @@ environ = None def __init__(self, cc=None): - self.cc = 'cl.exe' + Platform.__init__(self, 'cl.exe') if msvc_compiler_environ: self.c_environ = os.environ.copy() self.c_environ.update(msvc_compiler_environ) @@ -96,7 +96,7 @@ self.link_flags = ['/debug'] # Increase stack size, for the linker and the stack check code. - stack_size = 1 << 22 # 4 Mb + stack_size = 8 << 20 # 8 Mb self.link_flags.append('/STACK:%d' % stack_size) # The following symbol is used in c/src/stack.h self.cflags.append('/DMAX_STACK_SIZE=%d' % (stack_size - 1024)) From afa at codespeak.net Mon Jan 26 11:38:55 2009 From: afa at codespeak.net (afa at codespeak.net) Date: Mon, 26 Jan 2009 11:38:55 +0100 (CET) Subject: [pypy-svn] r61350 - in pypy/trunk/pypy/module/posix: . test Message-ID: <20090126103855.908B51684D4@codespeak.net> Author: afa Date: Mon Jan 26 11:38:55 2009 New Revision: 61350 Modified: pypy/trunk/pypy/module/posix/__init__.py pypy/trunk/pypy/module/posix/app_posix.py pypy/trunk/pypy/module/posix/test/test_posix2.py Log: win32: os.popen now works from a translated pypy-c.exe. App-level tests don't work though, probably another msvcrt confusion. Modified: pypy/trunk/pypy/module/posix/__init__.py ============================================================================== --- pypy/trunk/pypy/module/posix/__init__.py (original) +++ pypy/trunk/pypy/module/posix/__init__.py Mon Jan 26 11:38:55 2009 @@ -18,6 +18,7 @@ 'stat_result': 'app_posix.stat_result', 'fdopen' : 'app_posix.fdopen', 'tmpfile' : 'app_posix.tmpfile', + 'popen' : 'app_posix.popen', } interpleveldefs = { @@ -72,7 +73,6 @@ interpleveldefs['readlink'] = 'interp_posix.readlink' if hasattr(os, 'fork'): interpleveldefs['fork'] = 'interp_posix.fork' - appleveldefs['popen'] = 'app_posix.popen' if hasattr(os, 'waitpid'): interpleveldefs['waitpid'] = 'interp_posix.waitpid' if hasattr(os, 'execv'): Modified: pypy/trunk/pypy/module/posix/app_posix.py ============================================================================== --- pypy/trunk/pypy/module/posix/app_posix.py (original) +++ pypy/trunk/pypy/module/posix/app_posix.py Mon Jan 26 11:38:55 2009 @@ -142,26 +142,30 @@ else: # Supply os.popen() based on subprocess - def popen(cmd, mode="r", buffering=None): + def popen(cmd, mode="r", bufsize=-1): + """popen(command [, mode='r' [, bufsize]]) -> pipe + + Open a pipe to/from a command returning a file object.""" + if not isinstance(cmd, str): raise TypeError("invalid cmd type (%s, expected string)" % (type(cmd),)) - if mode not in ("r", "w"): + + if not mode.startswith('r') and not mode.startswith('w'): raise ValueError("invalid mode %r" % (mode,)) - if buffering is None: - buffering = 0 + import subprocess - if mode == "r": + if mode.startswith('r'): proc = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE, - bufsize=buffering) + bufsize=bufsize) return _wrap_close(proc.stdout, proc) else: proc = subprocess.Popen(cmd, shell=True, stdin=subprocess.PIPE, - bufsize=buffering) + bufsize=bufsize) return _wrap_close(proc.stdin, proc) # A proxy for a file whose close waits for the process Modified: pypy/trunk/pypy/module/posix/test/test_posix2.py ============================================================================== --- pypy/trunk/pypy/module/posix/test/test_posix2.py (original) +++ pypy/trunk/pypy/module/posix/test/test_posix2.py Mon Jan 26 11:38:55 2009 @@ -8,8 +8,12 @@ import sys import signal -def setup_module(mod): - mod.space = gettestobjspace(usemodules=['posix']) +def setup_module(mod): + if os.name != 'nt': + mod.space = gettestobjspace(usemodules=['posix']) + else: + # On windows, os.popen uses the subprocess module + mod.space = gettestobjspace(usemodules=['posix', '_rawffi', 'thread']) mod.path = udir.join('posixtestfile.txt') mod.path.write("this is a test") mod.path2 = udir.join('test_posix2-') From afa at codespeak.net Mon Jan 26 13:49:50 2009 From: afa at codespeak.net (afa at codespeak.net) Date: Mon, 26 Jan 2009 13:49:50 +0100 (CET) Subject: [pypy-svn] r61352 - pypy/trunk/pypy/module/rctime/test Message-ID: <20090126124950.58F011684D1@codespeak.net> Author: afa Date: Mon Jan 26 13:49:48 2009 New Revision: 61352 Modified: pypy/trunk/pypy/module/rctime/test/test_rctime.py Log: Our implementation of time.sleep on win32 is smarter that CPython's and accepts huge values. Stop testing for a limitation that does not exist. Modified: pypy/trunk/pypy/module/rctime/test/test_rctime.py ============================================================================== --- pypy/trunk/pypy/module/rctime/test/test_rctime.py (original) +++ pypy/trunk/pypy/module/rctime/test/test_rctime.py Mon Jan 26 13:49:48 2009 @@ -21,8 +21,6 @@ import os raises(TypeError, rctime.sleep, "foo") rctime.sleep(1.2345) - if os.name == "nt": - raises(OverflowError, rctime.sleep, sys.maxint) def test_clock(self): import time as rctime From afa at codespeak.net Mon Jan 26 14:41:27 2009 From: afa at codespeak.net (afa at codespeak.net) Date: Mon, 26 Jan 2009 14:41:27 +0100 (CET) Subject: [pypy-svn] r61353 - pypy/trunk/pypy/module/rctime Message-ID: <20090126134127.5D069168485@codespeak.net> Author: afa Date: Mon Jan 26 14:41:25 2009 New Revision: 61353 Modified: pypy/trunk/pypy/module/rctime/interp_time.py Log: Adapt the rctime module to recten MSVC compilers, which use a 64bit time_t by default; the functions are also named differently. Of course the C headers contain #defines to hide this change, but ctypes can't use them of course. Most tests in module/rctime now pass Modified: pypy/trunk/pypy/module/rctime/interp_time.py ============================================================================== --- pypy/trunk/pypy/module/rctime/interp_time.py (original) +++ pypy/trunk/pypy/module/rctime/interp_time.py Mon Jan 26 14:41:25 2009 @@ -51,6 +51,12 @@ cConfig.tm.__name__ = "_tm" def external(name, args, result): + if _WIN and rffi.sizeof(rffi.TIME_T) == 8: + # Recent Microsoft compilers use 64bit time_t and + # the corresponding functions are named differently + if (rffi.TIME_T in args or rffi.TIME_TP in args + or result in (rffi.TIME_T, rffi.TIME_TP)): + name = '_' + name + '64' return rffi.llexternal(name, args, result, compilation_info=CConfig._compilation_info_, calling_conv=calling_conv, From fijal at codespeak.net Mon Jan 26 15:15:22 2009 From: fijal at codespeak.net (fijal at codespeak.net) Date: Mon, 26 Jan 2009 15:15:22 +0100 (CET) Subject: [pypy-svn] r61354 - in pypy/trunk/pypy/module/recparser: . test Message-ID: <20090126141522.CB8781684DE@codespeak.net> Author: fijal Date: Mon Jan 26 15:15:22 2009 New Revision: 61354 Modified: pypy/trunk/pypy/module/recparser/pyparser.py pypy/trunk/pypy/module/recparser/test/test_parser.py Log: another pile of hacks - always generate code and just throw it away (don't cache) for the reason of catching syntax errors. the rationale behind it is that we don't care about module's performance and we do want it to be compliant Modified: pypy/trunk/pypy/module/recparser/pyparser.py ============================================================================== --- pypy/trunk/pypy/module/recparser/pyparser.py (original) +++ pypy/trunk/pypy/module/recparser/pyparser.py Mon Jan 26 15:15:22 2009 @@ -8,7 +8,7 @@ from pypy.interpreter.typedef import interp_attrproperty, GetSetProperty from pypy.interpreter.pycode import PyCode from pypy.interpreter.pyparser.syntaxtree import TokenNode, SyntaxNode, AbstractSyntaxVisitor -from pypy.interpreter.pyparser.error import SyntaxError +from pypy.interpreter.pyparser.error import SyntaxError, IndentationError from pypy.interpreter.pyparser import grammar, symbol, pytoken from pypy.interpreter.pyparser.future import getFutures from pypy.interpreter.argument import Arguments @@ -172,7 +172,15 @@ builder.space = space try: parser.parse_source(source, mode, builder, flags) - return builder.stack[-1] + st = builder.stack[-1] + # we compile it to bytecode anyway. + # the side effect of this is that we grab exceptions + # on our way. + STType(space, st).descr_compile(space) + return st + except IndentationError, e: + raise OperationError(space.w_IndentationError, + e.wrap_info(space, '')) except SyntaxError, e: raise OperationError(space.w_SyntaxError, e.wrap_info(space, '')) Modified: pypy/trunk/pypy/module/recparser/test/test_parser.py ============================================================================== --- pypy/trunk/pypy/module/recparser/test/test_parser.py (original) +++ pypy/trunk/pypy/module/recparser/test/test_parser.py Mon Jan 26 15:15:22 2009 @@ -53,3 +53,11 @@ import parser raises(SyntaxError, parser.source2ast, "\xDE\xDA") + def test_later_error(self): + import parser + x = """if: + def f(x): + x + y + """ + raises(SyntaxError, parser.suite, x) From antocuni at codespeak.net Mon Jan 26 16:15:00 2009 From: antocuni at codespeak.net (antocuni at codespeak.net) Date: Mon, 26 Jan 2009 16:15:00 +0100 (CET) Subject: [pypy-svn] r61355 - in pypy/trunk/pypy/objspace/std: . test Message-ID: <20090126151500.A961E169DB4@codespeak.net> Author: antocuni Date: Mon Jan 26 16:14:58 2009 New Revision: 61355 Modified: pypy/trunk/pypy/objspace/std/stringobject.py pypy/trunk/pypy/objspace/std/test/test_unicodeobject.py pypy/trunk/pypy/objspace/std/unicodeobject.py Log: start sharing at least some code between unicodeobject and stringobject. One more unicode.rsplit test passes Modified: pypy/trunk/pypy/objspace/std/stringobject.py ============================================================================== --- pypy/trunk/pypy/objspace/std/stringobject.py (original) +++ pypy/trunk/pypy/objspace/std/stringobject.py Mon Jan 26 16:14:58 2009 @@ -317,27 +317,35 @@ res_w.reverse() return space.newlist(res_w) -def str_rsplit__String_String_ANY(space, w_self, w_by, w_maxsplit=-1): - maxsplit = space.int_w(w_maxsplit) - res_w = [] - value = w_self._value - end = len(value) - by = w_by._value - bylen = len(by) - if bylen == 0: - raise OperationError(space.w_ValueError, space.wrap("empty separator")) - - while maxsplit != 0: - next = value.rfind(by, 0, end) - if next < 0: - break - res_w.append(sliced(space, value, next+bylen, end, w_self)) - end = next - maxsplit -= 1 # NB. if it's already < 0, it stays < 0 +def make_rsplit_with_delim(funcname, sliced): + from pypy.tool.sourcetools import func_with_new_name - res_w.append(sliced(space, value, 0, end, w_self)) - res_w.reverse() - return space.newlist(res_w) + def fn(space, w_self, w_by, w_maxsplit=-1): + maxsplit = space.int_w(w_maxsplit) + res_w = [] + value = w_self._value + end = len(value) + by = w_by._value + bylen = len(by) + if bylen == 0: + raise OperationError(space.w_ValueError, space.wrap("empty separator")) + + while maxsplit != 0: + next = value.rfind(by, 0, end) + if next < 0: + break + res_w.append(sliced(space, value, next+bylen, end, w_self)) + end = next + maxsplit -= 1 # NB. if it's already < 0, it stays < 0 + + res_w.append(sliced(space, value, 0, end, w_self)) + res_w.reverse() + return space.newlist(res_w) + + return func_with_new_name(fn, funcname) + +str_rsplit__String_String_ANY = make_rsplit_with_delim('str_rsplit__String_String_ANY', + sliced) def str_join__String_ANY(space, w_self, w_list): list_w = space.unpackiterable(w_list) Modified: pypy/trunk/pypy/objspace/std/test/test_unicodeobject.py ============================================================================== --- pypy/trunk/pypy/objspace/std/test/test_unicodeobject.py (original) +++ pypy/trunk/pypy/objspace/std/test/test_unicodeobject.py Mon Jan 26 16:14:58 2009 @@ -149,6 +149,7 @@ raises(ValueError, u'abc'.rsplit, '') raises(ValueError, 'abc'.rsplit, u'') assert u' a b c '.rsplit(None, 0) == [u' a b c'] + assert u''.rsplit('aaa') == [u''] def test_center(self): s=u"a b" Modified: pypy/trunk/pypy/objspace/std/unicodeobject.py ============================================================================== --- pypy/trunk/pypy/objspace/std/unicodeobject.py (original) +++ pypy/trunk/pypy/objspace/std/unicodeobject.py Mon Jan 26 16:14:58 2009 @@ -1,6 +1,6 @@ from pypy.objspace.std.objspace import * from pypy.interpreter import gateway -from pypy.objspace.std.stringobject import W_StringObject +from pypy.objspace.std.stringobject import W_StringObject, make_rsplit_with_delim from pypy.objspace.std.ropeobject import W_RopeObject from pypy.objspace.std.noneobject import W_NoneObject from pypy.objspace.std.sliceobject import W_SliceObject, normalize_simple_slice @@ -720,29 +720,15 @@ res_w.reverse() return space.newlist(res_w) -def unicode_rsplit__Unicode_Unicode_ANY(space, w_self, w_delim, w_maxsplit): - self = w_self._value - delim = w_delim._value - maxsplit = space.int_w(w_maxsplit) - delim_len = len(delim) - if delim_len == 0: - raise OperationError(space.w_ValueError, - space.wrap('empty separator')) - parts = [] - if len(self) == 0: - return space.newlist([]) - start = 0 - end = len(self) - while maxsplit != 0: - index = self.rfind(delim, 0, end) - if index < 0: - break - parts.append(W_UnicodeObject(self[index+delim_len:end])) - end = index - maxsplit -= 1 - parts.append(W_UnicodeObject(self[:end])) - parts.reverse() - return space.newlist(parts) +def sliced(space, s, start, stop, orig_obj): + assert start >= 0 + assert stop >= 0 + if start == 0 and stop == len(s) and space.is_w(space.type(orig_obj), space.w_unicode): + return orig_obj + return space.wrap( s[start:stop]) + +unicode_rsplit__Unicode_Unicode_ANY = make_rsplit_with_delim('unicode_rsplit__Unicode_Unicode_ANY', + sliced) def _split_into_chars(self, maxsplit): if maxsplit == 0: From antocuni at codespeak.net Mon Jan 26 16:52:29 2009 From: antocuni at codespeak.net (antocuni at codespeak.net) Date: Mon, 26 Jan 2009 16:52:29 +0100 (CET) Subject: [pypy-svn] r61358 - in pypy/trunk/pypy/objspace/std: . test Message-ID: <20090126155229.5E0C8169E0D@codespeak.net> Author: antocuni Date: Mon Jan 26 16:52:28 2009 New Revision: 61358 Modified: pypy/trunk/pypy/objspace/std/test/test_unicodeobject.py pypy/trunk/pypy/objspace/std/unicodetype.py Log: make sure that unicode(x) calls __unicode__ if x is an instance of subclass of unicode Modified: pypy/trunk/pypy/objspace/std/test/test_unicodeobject.py ============================================================================== --- pypy/trunk/pypy/objspace/std/test/test_unicodeobject.py (original) +++ pypy/trunk/pypy/objspace/std/test/test_unicodeobject.py Mon Jan 26 16:52:28 2009 @@ -678,6 +678,19 @@ u = unicode(buf, 'utf-8', 'strict') assert u == u'character buffers are decoded to unicode' + def test_unicode_conversion_with__unicode__(self): + class A(unicode): + def __unicode__(self): + return "foo" + class B(unicode): + pass + a = A('bar') + assert a == 'bar' + assert unicode(a) == 'foo' + b = B('bar') + assert b == 'bar' + assert unicode(b) == 'bar' + def test_unicode_conversion_with__str__(self): # new-style classes class A(object): Modified: pypy/trunk/pypy/objspace/std/unicodetype.py ============================================================================== --- pypy/trunk/pypy/objspace/std/unicodetype.py (original) +++ pypy/trunk/pypy/objspace/std/unicodetype.py Mon Jan 26 16:52:28 2009 @@ -256,9 +256,9 @@ from pypy.objspace.std.unicodeobject import W_UnicodeObject from pypy.objspace.std.ropeunicodeobject import W_RopeUnicodeObject w_obj = w_string - + encoding, errors = _get_encoding_and_errors(space, w_encoding, w_errors) - if space.is_true(space.isinstance(w_obj, space.w_unicode)): + if space.is_w(space.type(w_obj), space.w_unicode): if encoding is not None or errors is not None: raise OperationError(space.w_TypeError, space.wrap('decoding Unicode is not supported')) From fijal at codespeak.net Mon Jan 26 16:54:02 2009 From: fijal at codespeak.net (fijal at codespeak.net) Date: Mon, 26 Jan 2009 16:54:02 +0100 (CET) Subject: [pypy-svn] r61360 - in pypy/trunk/pypy/module/_lsprof: . test Message-ID: <20090126155402.5388C168051@codespeak.net> Author: fijal Date: Mon Jan 26 16:54:01 2009 New Revision: 61360 Modified: pypy/trunk/pypy/module/_lsprof/interp_lsprof.py pypy/trunk/pypy/module/_lsprof/test/test_cprofile.py Log: a bit of trickery for default values of enable etc. fix one test Modified: pypy/trunk/pypy/module/_lsprof/interp_lsprof.py ============================================================================== --- pypy/trunk/pypy/module/_lsprof/interp_lsprof.py (original) +++ pypy/trunk/pypy/module/_lsprof/interp_lsprof.py Mon Jan 26 16:54:01 2009 @@ -206,12 +206,15 @@ return space.float_w(space.call_function(self.w_callable)) return time.time() - def enable(self, space, subcalls=True, builtins=True): - self.subcalls = subcalls - self.builtins = builtins + def enable(self, space, w_subcalls=NoneNotWrapped, + w_builtins=NoneNotWrapped): + if w_subcalls is not None: + self.subcalls = space.bool_w(w_subcalls) + if w_builtins is not None: + self.builtins = space.bool_w(w_builtins) # set profiler hook space.getexecutioncontext().setllprofile(lsprof_call, space.wrap(self)) - enable.unwrap_spec = ['self', ObjSpace, bool, bool] + enable.unwrap_spec = ['self', ObjSpace, W_Root, W_Root] def _enter_call(self, f_code): # we have a superb gc, no point in freelist :) Modified: pypy/trunk/pypy/module/_lsprof/test/test_cprofile.py ============================================================================== --- pypy/trunk/pypy/module/_lsprof/test/test_cprofile.py (original) +++ pypy/trunk/pypy/module/_lsprof/test/test_cprofile.py Mon Jan 26 16:54:01 2009 @@ -9,11 +9,11 @@ cls.space = space cls.w_file = space.wrap(__file__) - def xtest_direct(self): + def test_direct(self): import _lsprof def getticks(): return len(ticks) - prof = _lsprof.Profiler(getticks, 0.25, True, True) + prof = _lsprof.Profiler(getticks, 0.25, True, False) ticks = [] def bar(m): ticks.append(1) @@ -28,7 +28,7 @@ bar(n+1) ticks.append(1) spam(n+2) - prof.enable(builtins=True) + prof.enable() foo(0) prof.disable() assert len(ticks) == 16 @@ -44,13 +44,13 @@ assert efoo.reccallcount == 1 assert efoo.inlinetime == 1.0 assert efoo.totaltime == 4.0 - assert len(efoo.calls) == 6 + assert len(efoo.calls) == 2 ebar = entries['bar'] assert ebar.callcount == 6 assert ebar.reccallcount == 3 assert ebar.inlinetime == 3.0 assert ebar.totaltime == 3.5 - assert len(ebar.calls) == 13 + assert len(ebar.calls) == 1 espam = entries['spam'] assert espam.callcount == 2 assert espam.reccallcount == 0 @@ -58,8 +58,7 @@ assert espam.totaltime == 1.0 assert len(espam.calls) == 1 - foo2spam = efoo.calls[-2] - foo2bar = efoo.calls[0] + foo2spam, foo2bar = efoo.calls if foo2bar.code.co_name == 'spam': foo2bar, foo2spam = foo2spam, foo2bar assert foo2bar.code.co_name == 'bar' @@ -73,14 +72,14 @@ assert foo2spam.inlinetime == 0.0 assert foo2spam.totaltime == 1.0 - bar2foo = ebar.calls[-3] + bar2foo, = ebar.calls assert bar2foo.code.co_name == 'foo' assert bar2foo.callcount == 1 assert bar2foo.reccallcount == 0 assert bar2foo.inlinetime == 0.5 assert bar2foo.totaltime == 2.0 - spam2bar = espam.calls[0] + spam2bar, = espam.calls assert spam2bar.code.co_name == 'bar' assert spam2bar.callcount == 2 assert spam2bar.reccallcount == 0 From afa at codespeak.net Mon Jan 26 18:07:08 2009 From: afa at codespeak.net (afa at codespeak.net) Date: Mon, 26 Jan 2009 18:07:08 +0100 (CET) Subject: [pypy-svn] r61366 - in pypy/trunk/pypy: module/zipimport module/zipimport/test rlib Message-ID: <20090126170708.22DB5168576@codespeak.net> Author: afa Date: Mon Jan 26 18:07:07 2009 New Revision: 61366 Modified: pypy/trunk/pypy/module/zipimport/interp_zipimport.py pypy/trunk/pypy/module/zipimport/test/test_undocumented.py pypy/trunk/pypy/rlib/rzipfile.py Log: Necessary changes in zipimport for windows: - the zip file is not kept opened. Like CPython, we cache the directory info, and reopen it every time - ensure that the underlying file is always closed. - open the file in binary mode. - zip files use / as separator, not os.path.sep Modified: pypy/trunk/pypy/module/zipimport/interp_zipimport.py ============================================================================== --- pypy/trunk/pypy/module/zipimport/interp_zipimport.py (original) +++ pypy/trunk/pypy/module/zipimport/interp_zipimport.py Mon Jan 26 18:07:07 2009 @@ -16,9 +16,9 @@ # separators, we need to pretend that we had the os.sep. ENUMERATE_EXTS = unrolling_iterable( - [(True, True, os.path.sep + '__init__.pyc'), - (True, True, os.path.sep + '__init__.pyo'), - (False, True, os.path.sep + '__init__.py'), + [(True, True, ZIPSEP + '__init__.pyc'), + (True, True, ZIPSEP + '__init__.pyo'), + (False, True, ZIPSEP + '__init__.py'), (True, False, '.pyc'), (True, False, '.pyo'), (False, False, '.py')]) @@ -43,13 +43,10 @@ except KeyError: raise OperationError(space.w_KeyError, space.wrap(name)) assert isinstance(w_zipimporter, W_ZipImporter) - dir = w_zipimporter.dir - keys = [k.filename for k in dir.filelist] w = space.wrap values = {} w_d = space.newdict() - for key in keys: - info = dir.NameToInfo[key] + for key, info in w_zipimporter.dir.iteritems(): w_values = space.newdict() space.setitem(w_d, w(key), space.newtuple([ w(info.filename), w(info.compress_type), w(info.compress_size), @@ -118,9 +115,10 @@ zip_cache = W_ZipCache() class W_ZipImporter(Wrappable): - def __init__(self, space, name, dir, prefix): + def __init__(self, space, name, filename, dir, prefix): self.space = space self.name = name + self.filename = filename self.dir = dir self.prefix = prefix self.w_ZipImportError = space.getattr( @@ -131,8 +129,8 @@ return space.wrap(self.prefix) def _find_relative_path(self, filename): - if filename.startswith(self.dir.filename): - filename = filename[len(self.dir.filename):] + if filename.startswith(self.filename): + filename = filename[len(self.filename):] if filename.startswith(os.sep): filename = filename[1:] if ZIPSEP != os.path.sep: @@ -152,10 +150,9 @@ def _parse_mtime(self, space, filename): w = space.wrap try: - info = self.dir.getinfo(filename) + info = self.dir[filename] t = info.date_time - except (BadZipfile, KeyError): - # in either case, this is a fallback + except KeyError: return 0 else: w_mktime = space.getattr(space.getbuiltinmodule('time'), @@ -203,7 +200,7 @@ filename = filename.replace(os.path.sep, ZIPSEP) w = space.wrap try: - self.dir.getinfo(filename) + self.dir[filename] return True except KeyError: return False @@ -216,7 +213,7 @@ find_module.unwrap_spec = ['self', ObjSpace, str, W_Root] def mangle(self, name): - return name.replace('.', os.path.sep) + return name.replace('.', ZIPSEP) def load_module(self, space, fullname): w = space.wrap @@ -230,7 +227,11 @@ for compiled, is_package, ext in ENUMERATE_EXTS: fname = filename + ext try: - buf = self.dir.read(fname) + zip_file = RZipFile(self.filename, 'r') + try: + buf = zip_file.read(fname) + finally: + zip_file.close() except (KeyError, OSError): pass else: @@ -259,7 +260,12 @@ filename = self._find_relative_path(filename) w = space.wrap try: - return w(self.dir.read(filename)) + zip_file = RZipFile(self.filename, 'r') + try: + data = zip_file.read(filename) + finally: + zip_file.close() + return w(data) except (KeyError, OSError): raise OperationError(space.w_IOError, space.wrap("Error reading file")) get_data.unwrap_spec = ['self', ObjSpace, str] @@ -307,7 +313,7 @@ def getarchive(space, self): space = self.space - return space.wrap(self.dir.filename) + return space.wrap(self.filename) def descr_new_zipimporter(space, w_type, name): w = space.wrap @@ -341,14 +347,16 @@ except KeyError: zip_cache.cache[filename] = None try: - dir = RZipFile(filename, 'r') + zip_file = RZipFile(filename, 'r') except (BadZipfile, OSError): raise OperationError(w_ZipImportError, space.wrap( "%s seems not to be a zipfile" % (filename,))) + zip_file.close() prefix = name[len(filename):] if prefix.startswith(os.sep): prefix = prefix[1:] - w_result = space.wrap(W_ZipImporter(space, name, dir, prefix)) + w_result = space.wrap(W_ZipImporter(space, name, filename, + zip_file.NameToInfo, prefix)) zip_cache.set(filename, w_result) return w_result Modified: pypy/trunk/pypy/module/zipimport/test/test_undocumented.py ============================================================================== --- pypy/trunk/pypy/module/zipimport/test/test_undocumented.py (original) +++ pypy/trunk/pypy/module/zipimport/test/test_undocumented.py Mon Jan 26 18:07:07 2009 @@ -87,13 +87,11 @@ test_file = open(TESTFN, 'w') try: test_file.write("# Test file for zipimport.") - try: - raises(zipimport.ZipImportError, - zipimport.zipimporter, TESTFN) - finally: - os.unlink(TESTFN) + raises(zipimport.ZipImportError, + zipimport.zipimporter, TESTFN) finally: test_file.close() + os.unlink(TESTFN) def test_root(self): import zipimport, os @@ -139,7 +137,8 @@ importer = zipimport.zipimporter(os.path.join(zip_path, '_pkg')) assert zip_path in zipimport._zip_directory_cache file_set = set(zipimport._zip_directory_cache[zip_path].iterkeys()) - compare_set = set(path + '.py' for path in self.created_paths) + compare_set = set(path.replace(os.path.sep, '/') + '.py' + for path in self.created_paths) assert file_set == compare_set finally: self.cleanup_zipfile(self.created_paths) Modified: pypy/trunk/pypy/rlib/rzipfile.py ============================================================================== --- pypy/trunk/pypy/rlib/rzipfile.py (original) +++ pypy/trunk/pypy/rlib/rzipfile.py Mon Jan 26 18:07:07 2009 @@ -147,8 +147,14 @@ self.mode = mode self.filelist = [] self.NameToInfo = {} + if 'b' not in mode: + mode += 'b' fp = open_file_as_stream(zipname, mode, 1024) - self._GetContents(fp) + try: + self._GetContents(fp) + except: + fp.close() + raise self.fp = fp def _GetContents(self, fp): @@ -241,4 +247,7 @@ if crc != zinfo.CRC: raise BadZipfile, "Bad CRC-32 for file %s" % filename return bytes + + def close(self): + self.fp.close() From afa at codespeak.net Mon Jan 26 18:22:31 2009 From: afa at codespeak.net (afa at codespeak.net) Date: Mon, 26 Jan 2009 18:22:31 +0100 (CET) Subject: [pypy-svn] r61373 - in pypy/trunk/pypy: config module/zipimport/test rlib Message-ID: <20090126172231.AAFDB168553@codespeak.net> Author: afa Date: Mon Jan 26 18:22:30 2009 New Revision: 61373 Modified: pypy/trunk/pypy/config/pypyoption.py pypy/trunk/pypy/module/zipimport/test/test_undocumented.py pypy/trunk/pypy/module/zipimport/test/test_zipimport.py pypy/trunk/pypy/rlib/rzipfile.py Log: Allow zipfile and zipimport to work without zlib: as long as files are simply stored and not deflated, a zip archive does not need this external library. Automatically disable the zlib module if zlib.h cannot be found. Now we can translate pypy on Windows without any option and without installing any external library. Modified: pypy/trunk/pypy/config/pypyoption.py ============================================================================== --- pypy/trunk/pypy/config/pypyoption.py (original) +++ pypy/trunk/pypy/config/pypyoption.py Mon Jan 26 18:22:30 2009 @@ -67,7 +67,9 @@ module_import_dependencies = { # no _rawffi if importing pypy.rlib.libffi raises ImportError # or CompilationError - "_rawffi": ["pypy.rlib.libffi"], + "_rawffi" : ["pypy.rlib.libffi"], + + "zlib" : ["pypy.rlib.rzlib"], } def get_module_validator(modname): Modified: pypy/trunk/pypy/module/zipimport/test/test_undocumented.py ============================================================================== --- pypy/trunk/pypy/module/zipimport/test/test_undocumented.py (original) +++ pypy/trunk/pypy/module/zipimport/test/test_undocumented.py Mon Jan 26 18:22:30 2009 @@ -66,7 +66,7 @@ class AppTestZipImport: def setup_class(cls): - space = gettestobjspace(usemodules=['zipimport', 'zlib', 'rctime']) + space = gettestobjspace(usemodules=['zipimport', 'rctime']) cls.space = space source = "():\n" + str(py.code.Source(temp_zipfile).indent()) + "\n return temp_zipfile" cls.w_temp_zipfile = space.appexec([], source) Modified: pypy/trunk/pypy/module/zipimport/test/test_zipimport.py ============================================================================== --- pypy/trunk/pypy/module/zipimport/test/test_zipimport.py (original) +++ pypy/trunk/pypy/module/zipimport/test/test_zipimport.py Mon Jan 26 18:22:30 2009 @@ -40,7 +40,12 @@ def get_file(): return __file__ """).compile() - space = gettestobjspace(usemodules=['zipimport', 'zlib', 'rctime']) + + if cls.compression == ZIP_DEFLATED: + space = gettestobjspace(usemodules=['zipimport', 'zlib', 'rctime']) + else: + space = gettestobjspace(usemodules=['zipimport', 'rctime']) + cls.space = space tmpdir = udir.ensure('zipimport_%s' % cls.__name__, dir=1) now = time.time() @@ -190,8 +195,8 @@ def test_package(self): import os, sys - self.writefile(self, "xxuuu"+os.sep+"__init__.py", "") - self.writefile(self, "xxuuu"+os.sep+"yy.py", "def f(x): return x") + self.writefile(self, "xxuuu/__init__.py", "") + self.writefile(self, "xxuuu/yy.py", "def f(x): return x") mod = __import__("xxuuu", globals(), locals(), ['yy']) assert mod.__path__ assert mod.yy.f(3) == 3 @@ -249,3 +254,11 @@ class AppTestZipimportDeflated(AppTestZipimport): compression = ZIP_DEFLATED + + def setup_class(cls): + try: + import pypy.rlib.rzlib + except ImportError: + py.test.skip("zlib not available, cannot test compressed zipfiles") + AppTestZipimport.setup_class(cls) + Modified: pypy/trunk/pypy/rlib/rzipfile.py ============================================================================== --- pypy/trunk/pypy/rlib/rzipfile.py (original) +++ pypy/trunk/pypy/rlib/rzipfile.py Mon Jan 26 18:22:30 2009 @@ -2,9 +2,14 @@ from zipfile import ZIP_STORED, ZIP_DEFLATED from pypy.rlib.streamio import open_file_as_stream from pypy.rlib.rstruct.runpack import runpack -import os -from pypy.rlib import rzlib from pypy.rlib.rarithmetic import r_uint, intmask +from pypy.rpython.tool.rffi_platform import CompilationError +import os + +try: + from pypy.rlib import rzlib +except (ImportError, CompilationError): + rzlib = None # XXX hack to get crc32 to work from pypy.lib.binascii import crc_32_tab @@ -229,7 +234,7 @@ self.fp.seek(filepos, 0) if zinfo.compress_type == ZIP_STORED: pass - elif zinfo.compress_type == ZIP_DEFLATED: + elif zinfo.compress_type == ZIP_DEFLATED and rzlib is not None: stream = rzlib.inflateInit(wbits=-15) try: bytes, _, _ = rzlib.decompress(stream, bytes) @@ -239,6 +244,9 @@ bytes = bytes + ex finally: rzlib.inflateEnd(stream) + elif zinfo.compress_type == ZIP_DEFLATED: + raise BadZipfile, \ + "Cannot decompress file, zlib not installed" else: raise BadZipfile, \ "Unsupported compression method %d for file %s" % \ From afa at codespeak.net Mon Jan 26 18:33:59 2009 From: afa at codespeak.net (afa at codespeak.net) Date: Mon, 26 Jan 2009 18:33:59 +0100 (CET) Subject: [pypy-svn] r61374 - pypy/trunk/pypy/module/zipimport/test Message-ID: <20090126173359.CC5C41683D4@codespeak.net> Author: afa Date: Mon Jan 26 18:33:57 2009 New Revision: 61374 Modified: pypy/trunk/pypy/module/zipimport/test/test_zipimport.py Log: This setup_class stuff looks like a classmethod, but isn't really. Use a helper function Modified: pypy/trunk/pypy/module/zipimport/test/test_zipimport.py ============================================================================== --- pypy/trunk/pypy/module/zipimport/test/test_zipimport.py (original) +++ pypy/trunk/pypy/module/zipimport/test/test_zipimport.py Mon Jan 26 18:33:57 2009 @@ -33,7 +33,7 @@ pyc = s.getvalue() + struct.pack(" Author: fijal Date: Mon Jan 26 20:48:21 2009 New Revision: 61376 Modified: pypy/trunk/pypy/module/_codecs/app_codecs.py pypy/trunk/pypy/module/_codecs/test/test_codecs.py Log: * one if which I have really no clue how should look like, tests don't care either * a fix. the funny thing is that it used to work by accident. Modified: pypy/trunk/pypy/module/_codecs/app_codecs.py ============================================================================== --- pypy/trunk/pypy/module/_codecs/app_codecs.py (original) +++ pypy/trunk/pypy/module/_codecs/app_codecs.py Mon Jan 26 20:48:21 2009 @@ -564,7 +564,7 @@ pos -= 1 #/* Map 16-bit characters to '\uxxxx' */ - elif (ord(ch) >= 256): + if (ord(ch) >= 256): p += '\\' p += 'u' p += '%04x' % ord(ch) @@ -581,6 +581,8 @@ elif (ch == '\r'): p += '\\' p += 'r' + elif ch == '\\': + p += '\\\\' #/* Map non-printable US ASCII to '\xhh' */ elif (ch < ' ' or ord(ch) >= 0x7F) : Modified: pypy/trunk/pypy/module/_codecs/test/test_codecs.py ============================================================================== --- pypy/trunk/pypy/module/_codecs/test/test_codecs.py (original) +++ pypy/trunk/pypy/module/_codecs/test/test_codecs.py Mon Jan 26 20:48:21 2009 @@ -528,3 +528,6 @@ assert unicode_escape_encode(u'abc') == (u'abc'.encode('unicode_escape'), 3) assert unicode_escape_decode('abc') == (u'abc'.decode('unicode_escape'), 3) assert unicode_escape_decode('\\x61\\x62\\x63') == (u'abc', 12) + + assert u'\\'.encode('unicode-escape') == '\\\\' + assert '\\\\'.decode('unicode-escape') == u'\\' From fijal at codespeak.net Mon Jan 26 20:56:28 2009 From: fijal at codespeak.net (fijal at codespeak.net) Date: Mon, 26 Jan 2009 20:56:28 +0100 (CET) Subject: [pypy-svn] r61377 - pypy/trunk/lib-python/modified-2.5.2/test Message-ID: <20090126195628.B02501684B6@codespeak.net> Author: fijal Date: Mon Jan 26 20:56:20 2009 New Revision: 61377 Added: pypy/trunk/lib-python/modified-2.5.2/test/test_xmlrpc.py - copied, changed from r61365, pypy/trunk/lib-python/2.5.2/test/test_xmlrpc.py Log: declare behavior of reload(sys) to restore __dict__ as implementation detail Copied: pypy/trunk/lib-python/modified-2.5.2/test/test_xmlrpc.py (from r61365, pypy/trunk/lib-python/2.5.2/test/test_xmlrpc.py) ============================================================================== --- pypy/trunk/lib-python/2.5.2/test/test_xmlrpc.py (original) +++ pypy/trunk/lib-python/modified-2.5.2/test/test_xmlrpc.py Mon Jan 26 20:56:20 2009 @@ -105,6 +105,7 @@ xmlrpclib.loads(strg)[0][0]) self.assertRaises(TypeError, xmlrpclib.dumps, (arg1,)) + @test_support.impl_detail("reload(sys) behavior") def test_default_encoding_issues(self): # SF bug #1115989: wrong decoding in '_stringify' utf8 = """ From fijal at codespeak.net Mon Jan 26 21:47:11 2009 From: fijal at codespeak.net (fijal at codespeak.net) Date: Mon, 26 Jan 2009 21:47:11 +0100 (CET) Subject: [pypy-svn] r61378 - in pypy/trunk/pypy/objspace/std: . test Message-ID: <20090126204711.87E1516857F@codespeak.net> Author: fijal Date: Mon Jan 26 21:47:09 2009 New Revision: 61378 Modified: pypy/trunk/pypy/objspace/std/test/test_unicodeobject.py pypy/trunk/pypy/objspace/std/unicodeobject.py Log: hopefully last checkin to make unicode tests pass Modified: pypy/trunk/pypy/objspace/std/test/test_unicodeobject.py ============================================================================== --- pypy/trunk/pypy/objspace/std/test/test_unicodeobject.py (original) +++ pypy/trunk/pypy/objspace/std/test/test_unicodeobject.py Mon Jan 26 21:47:09 2009 @@ -250,6 +250,9 @@ assert u'123123'.replace('123', u'') == u'' assert u'123x123'.replace(u'123', u'') == u'x' + def test_replace_buffer(self): + assert u'one!two!three'.replace(buffer('!'), buffer('@')) == u'one at two@three' + def test_replace_overflow(self): import sys if sys.maxint > 2**31-1: Modified: pypy/trunk/pypy/objspace/std/unicodeobject.py ============================================================================== --- pypy/trunk/pypy/objspace/std/unicodeobject.py (original) +++ pypy/trunk/pypy/objspace/std/unicodeobject.py Mon Jan 26 21:47:09 2009 @@ -763,23 +763,31 @@ def unicode_replace__Unicode_Unicode_Unicode_ANY(space, w_self, w_old, w_new, w_maxsplit): - if len(w_old._value): - parts = _split_with(w_self._value, w_old._value, - space.int_w(w_maxsplit)) + return _unicode_replace(space, w_self, w_old._value, w_new._value, + w_maxsplit) + +def unicode_replace__Unicode_ANY_ANY_ANY(space, w_self, w_old, w_new, + w_maxsplit): + return _unicode_replace(space, w_self, space.buffer_w(w_old).as_str(), + space.buffer_w(w_new).as_str(), w_maxsplit) + +def _unicode_replace(space, w_self, old, new, w_maxsplit): + if len(old): + parts = _split_with(w_self._value, old, space.int_w(w_maxsplit)) else: self = w_self._value maxsplit = space.int_w(w_maxsplit) parts = _split_into_chars(self, maxsplit) try: - one = ovfcheck(len(parts) * len(w_new._value)) + one = ovfcheck(len(parts) * len(new)) ovfcheck(one + len(w_self._value)) except OverflowError: raise OperationError( space.w_OverflowError, space.wrap("replace string is too long")) - return W_UnicodeObject(w_new._value.join(parts)) + return W_UnicodeObject(new.join(parts)) def unicode_encode__Unicode_ANY_ANY(space, w_unistr, From antocuni at codespeak.net Tue Jan 27 01:19:36 2009 From: antocuni at codespeak.net (antocuni at codespeak.net) Date: Tue, 27 Jan 2009 01:19:36 +0100 (CET) Subject: [pypy-svn] r61380 - in pypy/trunk/pypy/module/_lsprof: . test Message-ID: <20090127001936.E0DB5168489@codespeak.net> Author: antocuni Date: Tue Jan 27 01:19:33 2009 New Revision: 61380 Modified: pypy/trunk/pypy/module/_lsprof/interp_lsprof.py pypy/trunk/pypy/module/_lsprof/test/test_cprofile.py Log: (in-progress) try to make the output of cProfile as similar as possible to CPython. Modified: pypy/trunk/pypy/module/_lsprof/interp_lsprof.py ============================================================================== --- pypy/trunk/pypy/module/_lsprof/interp_lsprof.py (original) +++ pypy/trunk/pypy/module/_lsprof/interp_lsprof.py Tue Jan 27 01:19:33 2009 @@ -163,9 +163,14 @@ if isinstance(w_arg, Method): w_function = w_arg.w_function assert isinstance(w_function, Function) - return "{method '%s' of '%s' object}" % (w_function.name, space.str_w(space.str(w_arg.w_class))) + return "{method '%s' of '%s' objects}" % (w_function.name, w_arg.w_class.name) elif isinstance(w_arg, Function): - return '{%s function}' % (w_arg.name,) + module = space.str_w(w_arg.w_module) + if module == '__builtin__': + module = '' + else: + module += '.' + return '{%s%s function}' % (module, w_arg.name) else: return '{!!!unknown!!!}' @@ -266,8 +271,8 @@ def disable(self, space): # unset profiler hook - self._flush_unmatched() space.getexecutioncontext().setllprofile(None, None) + self._flush_unmatched() disable.unwrap_spec = ['self', ObjSpace] def getstats(self, space): Modified: pypy/trunk/pypy/module/_lsprof/test/test_cprofile.py ============================================================================== --- pypy/trunk/pypy/module/_lsprof/test/test_cprofile.py (original) +++ pypy/trunk/pypy/module/_lsprof/test/test_cprofile.py Tue Jan 27 01:19:33 2009 @@ -1,13 +1,38 @@ import py -from pypy.conftest import gettestobjspace +from pypy.conftest import gettestobjspace, option + +class PyPyOutput: + nfunc = 127 + nprim = 107 + optional_line = '\n 1 0.000 0.000 0.000 0.000 ?:1()' + hasattr = "{hasattr function}" + disable = "{method 'disable' of 'Profile' objects}" + range = "{range function}" + exc_info = "{sys.exc_info function}" + + +class CPythonOutput: + nfunc = 126 + nprim = 106 + optional_line = '' + hasattr = "{hasattr}" + disable = "{method 'disable' of '_lsprof.Profiler' objects}" + range = "{range}" + exc_info = "{sys.exc_info}" class AppTestCProfile(object): + def setup_class(cls): space = gettestobjspace(usemodules=('_lsprof',)) cls.w_expected_output = space.wrap(expected_output) cls.space = space cls.w_file = space.wrap(__file__) + if option.runappdirect: + output = CPythonOutput.__dict__ + else: + output = PyPyOutput.__dict__ + cls.w_output = space.wrap(output) def test_direct(self): import _lsprof @@ -118,6 +143,7 @@ for i, method in enumerate(methodnames): got = res[i + 1] expected = self.expected_output[method] + expected = expected % self.output if got != expected: print method, 'differs:' print '---------- GOT: ----------' @@ -139,13 +165,12 @@ expected_output = {} expected_output['print_stats'] = """\ - 128 function calls (108 primitive calls) in 1.000 CPU seconds + %(nfunc)d function calls (%(nprim)d primitive calls) in 1.000 CPU seconds Ordered by: standard name ncalls tottime percall cumtime percall filename:lineno(function) - 1 0.000 0.000 1.000 1.000 :1() - 1 0.000 0.000 0.000 0.000 ?:1() + 1 0.000 0.000 1.000 1.000 :1()%(optional_line)s 28 0.028 0.001 0.028 0.001 profilee.py:110(__getattr__) 1 0.270 0.270 1.000 1.000 profilee.py:25(testfunc) 23/3 0.150 0.007 0.170 0.057 profilee.py:35(factorial) @@ -155,11 +180,11 @@ 2 0.000 0.000 0.140 0.070 profilee.py:84(helper2_indirect) 8 0.312 0.039 0.400 0.050 profilee.py:88(helper2) 8 0.064 0.008 0.080 0.010 profilee.py:98(subhelper) - 12 0.000 0.000 0.012 0.001 {hasattr} + 12 0.000 0.000 0.012 0.001 %(hasattr)s 4 0.000 0.000 0.000 0.000 {method 'append' of 'list' objects} - 1 0.000 0.000 0.000 0.000 {method 'disable' of '_lsprof.Profiler' objects} - 8 0.000 0.000 0.000 0.000 {range} - 4 0.000 0.000 0.000 0.000 {sys.exc_info} + 1 0.000 0.000 0.000 0.000 %(disable)s + 8 0.000 0.000 0.000 0.000 %(range)s + 4 0.000 0.000 0.000 0.000 %(exc_info)s """ From antocuni at codespeak.net Tue Jan 27 09:31:58 2009 From: antocuni at codespeak.net (antocuni at codespeak.net) Date: Tue, 27 Jan 2009 09:31:58 +0100 (CET) Subject: [pypy-svn] r61381 - pypy/trunk/pypy/module/_lsprof Message-ID: <20090127083158.8007E16849F@codespeak.net> Author: antocuni Date: Tue Jan 27 09:31:54 2009 New Revision: 61381 Modified: pypy/trunk/pypy/module/_lsprof/interp_lsprof.py Log: try to fix translation Modified: pypy/trunk/pypy/module/_lsprof/interp_lsprof.py ============================================================================== --- pypy/trunk/pypy/module/_lsprof/interp_lsprof.py (original) +++ pypy/trunk/pypy/module/_lsprof/interp_lsprof.py Tue Jan 27 09:31:54 2009 @@ -162,8 +162,11 @@ def create_spec(space, w_arg): if isinstance(w_arg, Method): w_function = w_arg.w_function + w_class = w_arg.w_class + w_class_name = space.getattr(w_class, space.wrap('__name__')) + class_name = space.str_w(w_class_name) assert isinstance(w_function, Function) - return "{method '%s' of '%s' objects}" % (w_function.name, w_arg.w_class.name) + return "{method '%s' of '%s' objects}" % (w_function.name, class_name) elif isinstance(w_arg, Function): module = space.str_w(w_arg.w_module) if module == '__builtin__': From antocuni at codespeak.net Tue Jan 27 09:55:00 2009 From: antocuni at codespeak.net (antocuni at codespeak.net) Date: Tue, 27 Jan 2009 09:55:00 +0100 (CET) Subject: [pypy-svn] r61382 - pypy/trunk/pypy/objspace/std Message-ID: <20090127085500.E4734168490@codespeak.net> Author: antocuni Date: Tue Jan 27 09:55:00 2009 New Revision: 61382 Modified: pypy/trunk/pypy/objspace/std/unicodeobject.py Log: fix translation Modified: pypy/trunk/pypy/objspace/std/unicodeobject.py ============================================================================== --- pypy/trunk/pypy/objspace/std/unicodeobject.py (original) +++ pypy/trunk/pypy/objspace/std/unicodeobject.py Tue Jan 27 09:55:00 2009 @@ -768,8 +768,9 @@ def unicode_replace__Unicode_ANY_ANY_ANY(space, w_self, w_old, w_new, w_maxsplit): - return _unicode_replace(space, w_self, space.buffer_w(w_old).as_str(), - space.buffer_w(w_new).as_str(), w_maxsplit) + old = unicode(space.buffer_w(w_old).as_str()) + new = unicode(space.buffer_w(w_new).as_str()) + return _unicode_replace(space, w_self, old, new, w_maxsplit) def _unicode_replace(space, w_self, old, new, w_maxsplit): if len(old): From hpk at codespeak.net Tue Jan 27 10:36:08 2009 From: hpk at codespeak.net (hpk at codespeak.net) Date: Tue, 27 Jan 2009 10:36:08 +0100 (CET) Subject: [pypy-svn] r61383 - pypy/extradoc/talk/openbossa2009 Message-ID: <20090127093608.4B24816849F@codespeak.net> Author: hpk Date: Tue Jan 27 10:36:06 2009 New Revision: 61383 Modified: pypy/extradoc/talk/openbossa2009/holger-bio.txt Log: updating my bio Modified: pypy/extradoc/talk/openbossa2009/holger-bio.txt ============================================================================== --- pypy/extradoc/talk/openbossa2009/holger-bio.txt (original) +++ pypy/extradoc/talk/openbossa2009/holger-bio.txt Tue Jan 27 10:36:06 2009 @@ -1,10 +1,9 @@ -Holger started with game and general computer hacking ages -ago, went through university, some consulting and bank -contracting until finally arriving at working in free software -environments fulltime. He founded merlinux in 2004, which -contracts Python specialists. Holger Krekel is a co-founder of -the PyPy project, both a new Python implemenation and a -framework for implementing dynamic languages. Holger also -authors a well known python testing framework and is interested -in new paradigms for deploying programs in networks. +Holger is a co-founder of the PyPy project, both a new Python +implemenation and a framework for implementing dynamic +languages. Holger also authors a well known python testing +framework and is interested in new paradigms for deploying +networked programs ala Charles Stross' Zone VM. He founded +merlinux in 2004, which organises mostly european specialists +to earn money with open-source and Python based collaborations. + From fijall at gmail.com Tue Jan 27 11:35:08 2009 From: fijall at gmail.com (Maciej Fijalkowski) Date: Tue, 27 Jan 2009 11:35:08 +0100 Subject: [pypy-svn] r61381 - pypy/trunk/pypy/module/_lsprof In-Reply-To: <20090127083158.8007E16849F@codespeak.net> References: <20090127083158.8007E16849F@codespeak.net> Message-ID: <693bc9ab0901270235lb161afcj65396d05e2533e61@mail.gmail.com> Oops, I have this in my wc, but forgot to commit On Tue, Jan 27, 2009 at 9:31 AM, wrote: > Author: antocuni > Date: Tue Jan 27 09:31:54 2009 > New Revision: 61381 > > Modified: > pypy/trunk/pypy/module/_lsprof/interp_lsprof.py > Log: > try to fix translation > > > > Modified: pypy/trunk/pypy/module/_lsprof/interp_lsprof.py > ============================================================================== > --- pypy/trunk/pypy/module/_lsprof/interp_lsprof.py (original) > +++ pypy/trunk/pypy/module/_lsprof/interp_lsprof.py Tue Jan 27 09:31:54 2009 > @@ -162,8 +162,11 @@ > def create_spec(space, w_arg): > if isinstance(w_arg, Method): > w_function = w_arg.w_function > + w_class = w_arg.w_class > + w_class_name = space.getattr(w_class, space.wrap('__name__')) > + class_name = space.str_w(w_class_name) > assert isinstance(w_function, Function) > - return "{method '%s' of '%s' objects}" % (w_function.name, w_arg.w_class.name) > + return "{method '%s' of '%s' objects}" % (w_function.name, class_name) > elif isinstance(w_arg, Function): > module = space.str_w(w_arg.w_module) > if module == '__builtin__': > _______________________________________________ > pypy-svn mailing list > pypy-svn at codespeak.net > http://codespeak.net/mailman/listinfo/pypy-svn > From fijal at codespeak.net Tue Jan 27 12:30:26 2009 From: fijal at codespeak.net (fijal at codespeak.net) Date: Tue, 27 Jan 2009 12:30:26 +0100 (CET) Subject: [pypy-svn] r61385 - pypy/trunk/pypy/module/_lsprof Message-ID: <20090127113026.6A7E9168465@codespeak.net> Author: fijal Date: Tue Jan 27 12:30:23 2009 New Revision: 61385 Modified: pypy/trunk/pypy/module/_lsprof/interp_lsprof.py Log: be safer against broken classes that has no __name__ (or a broken one) Modified: pypy/trunk/pypy/module/_lsprof/interp_lsprof.py ============================================================================== --- pypy/trunk/pypy/module/_lsprof/interp_lsprof.py (original) +++ pypy/trunk/pypy/module/_lsprof/interp_lsprof.py Tue Jan 27 12:30:23 2009 @@ -163,8 +163,7 @@ if isinstance(w_arg, Method): w_function = w_arg.w_function w_class = w_arg.w_class - w_class_name = space.getattr(w_class, space.wrap('__name__')) - class_name = space.str_w(w_class_name) + class_name = space.str_w(space.str(w_class)) assert isinstance(w_function, Function) return "{method '%s' of '%s' objects}" % (w_function.name, class_name) elif isinstance(w_arg, Function): From fijal at codespeak.net Tue Jan 27 13:27:43 2009 From: fijal at codespeak.net (fijal at codespeak.net) Date: Tue, 27 Jan 2009 13:27:43 +0100 (CET) Subject: [pypy-svn] r61386 - pypy/trunk/pypy/module/_codecs Message-ID: <20090127122743.337291684AB@codespeak.net> Author: fijal Date: Tue Jan 27 13:27:41 2009 New Revision: 61386 Modified: pypy/trunk/pypy/module/_codecs/app_codecs.py Log: now I know this is elif (see test_cpickle) Modified: pypy/trunk/pypy/module/_codecs/app_codecs.py ============================================================================== --- pypy/trunk/pypy/module/_codecs/app_codecs.py (original) +++ pypy/trunk/pypy/module/_codecs/app_codecs.py Tue Jan 27 13:27:41 2009 @@ -564,7 +564,7 @@ pos -= 1 #/* Map 16-bit characters to '\uxxxx' */ - if (ord(ch) >= 256): + elif (ord(ch) >= 256): p += '\\' p += 'u' p += '%04x' % ord(ch) From arigo at codespeak.net Tue Jan 27 14:16:23 2009 From: arigo at codespeak.net (arigo at codespeak.net) Date: Tue, 27 Jan 2009 14:16:23 +0100 (CET) Subject: [pypy-svn] r61389 - in pypy/trunk/pypy/objspace/std: . test Message-ID: <20090127131623.EB5E516854A@codespeak.net> Author: arigo Date: Tue Jan 27 14:16:23 2009 New Revision: 61389 Modified: pypy/trunk/pypy/objspace/std/stringobject.py pypy/trunk/pypy/objspace/std/test/test_unicodeobject.py pypy/trunk/pypy/objspace/std/unicodeobject.py Log: Fix unicode_replace__Unicode_ANY_ANY_ANY: must use space.bufferstr_w() instead of space.buffer_w().as_str(). The difference is nicely documented in bufferstr_w() :-) Modified: pypy/trunk/pypy/objspace/std/stringobject.py ============================================================================== --- pypy/trunk/pypy/objspace/std/stringobject.py (original) +++ pypy/trunk/pypy/objspace/std/stringobject.py Tue Jan 27 14:16:23 2009 @@ -52,6 +52,7 @@ space.wrap(i), space.wrap(i+1), space.wrap("ordinal not in range(128)")])) + assert False, "unreachable" def unicode_w__String(space, w_self): # XXX should this use the default encoding? Modified: pypy/trunk/pypy/objspace/std/test/test_unicodeobject.py ============================================================================== --- pypy/trunk/pypy/objspace/std/test/test_unicodeobject.py (original) +++ pypy/trunk/pypy/objspace/std/test/test_unicodeobject.py Tue Jan 27 14:16:23 2009 @@ -770,3 +770,8 @@ return u'bar' assert unicode(A()) == u'bar' + + def test_replace_with_buffer(self): + assert u'abc'.replace(buffer('b'), buffer('e')) == u'aec' + assert u'abc'.replace(buffer('b'), u'e') == u'aec' + assert u'abc'.replace(u'b', buffer('e')) == u'aec' Modified: pypy/trunk/pypy/objspace/std/unicodeobject.py ============================================================================== --- pypy/trunk/pypy/objspace/std/unicodeobject.py (original) +++ pypy/trunk/pypy/objspace/std/unicodeobject.py Tue Jan 27 14:16:23 2009 @@ -230,9 +230,8 @@ if ival < 0: ival += ulen if ival < 0 or ival >= ulen: - exc = space.call_function(space.w_IndexError, - space.wrap("unicode index out of range")) - raise OperationError(space.w_IndexError, exc) + raise OperationError(space.w_IndexError, + space.wrap("unicode index out of range")) return W_UnicodeObject(uni[ival]) def getitem__Unicode_Slice(space, w_uni, w_slice): @@ -768,8 +767,8 @@ def unicode_replace__Unicode_ANY_ANY_ANY(space, w_self, w_old, w_new, w_maxsplit): - old = unicode(space.buffer_w(w_old).as_str()) - new = unicode(space.buffer_w(w_new).as_str()) + old = unicode(space.bufferstr_w(w_old)) + new = unicode(space.bufferstr_w(w_new)) return _unicode_replace(space, w_self, old, new, w_maxsplit) def _unicode_replace(space, w_self, old, new, w_maxsplit): From arigo at codespeak.net Tue Jan 27 14:41:01 2009 From: arigo at codespeak.net (arigo at codespeak.net) Date: Tue, 27 Jan 2009 14:41:01 +0100 (CET) Subject: [pypy-svn] r61390 - pypy/trunk/lib-python/modified-2.5.2/test Message-ID: <20090127134101.408AB1684DB@codespeak.net> Author: arigo Date: Tue Jan 27 14:40:58 2009 New Revision: 61390 Modified: pypy/trunk/lib-python/modified-2.5.2/test/test_doctest.py Log: Fix one of the failures by adding the comment "doctest: +ELLIPSIS". Argh argh argh. Modified: pypy/trunk/lib-python/modified-2.5.2/test/test_doctest.py ============================================================================== --- pypy/trunk/lib-python/modified-2.5.2/test/test_doctest.py (original) +++ pypy/trunk/lib-python/modified-2.5.2/test/test_doctest.py Tue Jan 27 14:40:58 2009 @@ -774,9 +774,9 @@ >>> def f(x): ... ''' ... >>> x = 12 - ... >>> print x//0 + ... >>> print x//0 # doctest: +ELLIPSIS ... Traceback (most recent call last): - ... ZeroDivisionError: integer division or modulo by zero + ... ZeroDivisionError: ... ... ''' >>> test = doctest.DocTestFinder().find(f)[0] >>> doctest.DocTestRunner(verbose=False).run(test) From antocuni at codespeak.net Tue Jan 27 16:05:12 2009 From: antocuni at codespeak.net (antocuni at codespeak.net) Date: Tue, 27 Jan 2009 16:05:12 +0100 (CET) Subject: [pypy-svn] r61392 - pypy/trunk/pypy/interpreter Message-ID: <20090127150512.01E68169DB5@codespeak.net> Author: antocuni Date: Tue Jan 27 16:05:12 2009 New Revision: 61392 Modified: pypy/trunk/pypy/interpreter/executioncontext.py Log: (antocuni, arigo) this check is non-sense Modified: pypy/trunk/pypy/interpreter/executioncontext.py ============================================================================== --- pypy/trunk/pypy/interpreter/executioncontext.py (original) +++ pypy/trunk/pypy/interpreter/executioncontext.py Tue Jan 27 16:05:12 2009 @@ -211,7 +211,7 @@ self.is_tracing = is_tracing def _trace(self, frame, event, w_arg, operr=None): - if self.is_tracing or frame.hide() or frame is None: + if self.is_tracing or frame.hide(): return space = self.space From arigo at codespeak.net Tue Jan 27 16:07:23 2009 From: arigo at codespeak.net (arigo at codespeak.net) Date: Tue, 27 Jan 2009 16:07:23 +0100 (CET) Subject: [pypy-svn] r61393 - in pypy/trunk/pypy: interpreter module/sys/test Message-ID: <20090127150723.1F99D169E11@codespeak.net> Author: arigo Date: Tue Jan 27 16:07:22 2009 New Revision: 61393 Modified: pypy/trunk/pypy/interpreter/executioncontext.py pypy/trunk/pypy/module/sys/test/test_sysmodule.py Log: (antocuni, arigo) Fix for sys.settrace() showing sometimes hidden frames too, like the implementation of execfile(). Done by passing 'frame' explicitly, instead of re-fetching it -- because executioncontext.framestack.top() is the last *visible* frame only. Modified: pypy/trunk/pypy/interpreter/executioncontext.py ============================================================================== --- pypy/trunk/pypy/interpreter/executioncontext.py (original) +++ pypy/trunk/pypy/interpreter/executioncontext.py Tue Jan 27 16:07:22 2009 @@ -157,7 +157,7 @@ ticker += 1 actionflag.set(ticker) if ticker & actionflag.interesting_bits: # fast check - actionflag.action_dispatcher(self) # slow path + actionflag.action_dispatcher(self, frame) # slow path bytecode_trace._always_inline_ = True def exception_trace(self, frame, operationerr): @@ -340,7 +340,7 @@ nonperiodic_actions = unrolling_iterable(self._nonperiodic_actions) has_bytecode_counter = self.has_bytecode_counter - def action_dispatcher(ec): + def action_dispatcher(ec, frame): # periodic actions if has_bytecode_counter: ticker = self.get() @@ -354,14 +354,14 @@ ticker -= ec.space.sys.checkinterval self.set(ticker) for action in periodic_actions: - action.perform(ec) + action.perform(ec, frame) # nonperiodic actions for action, bitmask in nonperiodic_actions: ticker = self.get() if ticker & bitmask: self.set(ticker & ~ bitmask) - action.perform(ec) + action.perform(ec, frame) action_dispatcher._dont_inline_ = True self.action_dispatcher = action_dispatcher @@ -414,7 +414,7 @@ from pypy.module.thread.gil import spacestate spacestate.set_actionflag_bit_after_thread_switch |= self.bitmask - def perform(self, executioncontext): + def perform(self, executioncontext, frame): """To be overridden.""" @@ -442,7 +442,7 @@ self.dying_objects_w.append(w_obj) self.fire() - def perform(self, executioncontext): + def perform(self, executioncontext, frame): if self.finalizers_lock_count > 0: return # Each call to perform() first grabs the self.dying_objects_w @@ -466,8 +466,7 @@ class FrameTraceAction(AsyncAction): """An action that calls the local trace functions (w_f_trace).""" - def perform(self, executioncontext): - frame = executioncontext.framestack.top() + def perform(self, executioncontext, frame): if frame.w_f_trace is None or executioncontext.is_tracing: return code = frame.pycode Modified: pypy/trunk/pypy/module/sys/test/test_sysmodule.py ============================================================================== --- pypy/trunk/pypy/module/sys/test/test_sysmodule.py (original) +++ pypy/trunk/pypy/module/sys/test/test_sysmodule.py Tue Jan 27 16:07:22 2009 @@ -328,13 +328,13 @@ assert sys.byteorder in ("little", "big") assert isinstance(sys.builtin_module_names, tuple) assert isinstance(sys.copyright, basestring) - assert isinstance(sys.exec_prefix, basestring) + #assert isinstance(sys.exec_prefix, basestring) -- not present! assert isinstance(sys.executable, basestring) assert isinstance(sys.hexversion, int) assert isinstance(sys.maxint, int) assert isinstance(sys.maxunicode, int) assert isinstance(sys.platform, basestring) - assert isinstance(sys.prefix, basestring) + #assert isinstance(sys.prefix, basestring) -- not present! assert isinstance(sys.version, basestring) assert isinstance(sys.warnoptions, list) vi = sys.version_info @@ -383,3 +383,20 @@ assert project == 'PyPy' assert svnbranch == svnbranch.strip('/') assert revision.isdigit() + + def test_trace_exec_execfile(self): + found = [] + def do_tracing(f, *args): + print f.f_code.co_filename, f.f_lineno, args + if f.f_code.co_filename == 'foobar': + found.append(args[0]) + return do_tracing + co = compile("execfile('this-file-does-not-exist!')", + 'foobar', 'exec') + sys.settrace(do_tracing) + try: + exec co in {} + except IOError: + pass + sys.settrace(None) + assert found == ['call', 'line', 'exception'] From arigo at codespeak.net Tue Jan 27 16:14:12 2009 From: arigo at codespeak.net (arigo at codespeak.net) Date: Tue, 27 Jan 2009 16:14:12 +0100 (CET) Subject: [pypy-svn] r61394 - in pypy/trunk/pypy: interpreter/test module/signal module/thread Message-ID: <20090127151412.A8E78168435@codespeak.net> Author: arigo Date: Tue Jan 27 16:14:11 2009 New Revision: 61394 Modified: pypy/trunk/pypy/interpreter/test/test_executioncontext.py pypy/trunk/pypy/module/signal/interp_signal.py pypy/trunk/pypy/module/thread/gil.py Log: (antocuni, arigo) Forgot to add the extra argument to these classes. Modified: pypy/trunk/pypy/interpreter/test/test_executioncontext.py ============================================================================== --- pypy/trunk/pypy/interpreter/test/test_executioncontext.py (original) +++ pypy/trunk/pypy/interpreter/test/test_executioncontext.py Tue Jan 27 16:14:11 2009 @@ -12,7 +12,7 @@ class DemoAction(executioncontext.AsyncAction): counter = 0 - def perform(self, ec): + def perform(self, ec, frame): self.counter += 1 if self.counter == 10: raise Finished @@ -42,7 +42,7 @@ class DemoAction(executioncontext.PeriodicAsyncAction): counter = 0 - def perform(self, ec): + def perform(self, ec, frame): self.counter += 1 print '->', self.counter if self.counter == 3: Modified: pypy/trunk/pypy/module/signal/interp_signal.py ============================================================================== --- pypy/trunk/pypy/module/signal/interp_signal.py (original) +++ pypy/trunk/pypy/module/signal/interp_signal.py Tue Jan 27 16:14:11 2009 @@ -67,7 +67,7 @@ else: self.reissue_signal_action = None - def perform(self, executioncontext): + def perform(self, executioncontext, frame): while True: n = pypysig_poll() if n < 0: @@ -125,7 +125,7 @@ thread switch until we land in the main thread. """ - def perform(self, executioncontext): + def perform(self, executioncontext, frame): main_ec = self.space.threadlocals.getmainthreadvalue() if executioncontext is main_ec: # now running in the main thread: we can really report the signals Modified: pypy/trunk/pypy/module/thread/gil.py ============================================================================== --- pypy/trunk/pypy/module/thread/gil.py (original) +++ pypy/trunk/pypy/module/thread/gil.py Tue Jan 27 16:14:11 2009 @@ -57,7 +57,7 @@ the GIL to give some other thread a chance to run. """ - def perform(self, executioncontext): + def perform(self, executioncontext, frame): # Other threads can run between the release() and the acquire() # implicit in the following external function call (which has # otherwise no effect). From arigo at codespeak.net Tue Jan 27 16:23:35 2009 From: arigo at codespeak.net (arigo at codespeak.net) Date: Tue, 27 Jan 2009 16:23:35 +0100 (CET) Subject: [pypy-svn] r61395 - pypy/trunk/lib-python/modified-2.5.2/test Message-ID: <20090127152335.35CEF16857F@codespeak.net> Author: arigo Date: Tue Jan 27 16:23:32 2009 New Revision: 61395 Modified: pypy/trunk/lib-python/modified-2.5.2/test/test_doctest.py Log: (antocuni, arigo) Remove the checking of some of the exact error messages. Modified: pypy/trunk/lib-python/modified-2.5.2/test/test_doctest.py ============================================================================== --- pypy/trunk/lib-python/modified-2.5.2/test/test_doctest.py (original) +++ pypy/trunk/lib-python/modified-2.5.2/test/test_doctest.py Tue Jan 27 16:23:32 2009 @@ -804,7 +804,7 @@ print 'pre-exception output', x//0 Exception raised: ... - ZeroDivisionError: integer division or modulo by zero + ZeroDivisionError: ... (1, 2) Exception messages may contain newlines: @@ -901,7 +901,7 @@ Exception raised: Traceback (most recent call last): ... - ZeroDivisionError: integer division or modulo by zero + ZeroDivisionError: ... (1, 1) """ def optionflags(): r""" @@ -2096,7 +2096,7 @@ favorite_color Exception raised: ... - NameError: name 'favorite_color' is not defined + NameError: ...favorite_color... @@ -2149,7 +2149,7 @@ favorite_color Exception raised: ... - NameError: name 'favorite_color' is not defined + NameError: ...favorite_color... ********************************************************************** 1 items had failures: 1 of 2 in test_doctest.txt @@ -2242,7 +2242,7 @@ favorite_color Exception raised: ... - NameError: name 'favorite_color' is not defined + NameError: ...favorite_color... (1, 2) >>> doctest.master = None # Reset master. From arigo at codespeak.net Tue Jan 27 16:24:47 2009 From: arigo at codespeak.net (arigo at codespeak.net) Date: Tue, 27 Jan 2009 16:24:47 +0100 (CET) Subject: [pypy-svn] r61396 - pypy/trunk/lib-python Message-ID: <20090127152447.4A810169E14@codespeak.net> Author: arigo Date: Tue Jan 27 16:24:46 2009 New Revision: 61396 Modified: pypy/trunk/lib-python/failure_list.txt Log: Kill some tests that pass nowadays. Modified: pypy/trunk/lib-python/failure_list.txt ============================================================================== --- pypy/trunk/lib-python/failure_list.txt (original) +++ pypy/trunk/lib-python/failure_list.txt Tue Jan 27 16:24:46 2009 @@ -16,7 +16,6 @@ test_format test checking for exact exception messages test_gc internal stuff, we may want to provide placeholders test_generators ! the fix is in r60950 but doesn't work. See r60965 -test_gettext ! check this use of unicode() test_grammar implementation detail test_import importing from pyc-files-without-py-file disabled by default test_inspect ! test_wrapped_decorator: try to fix; isbuiltin([].append): cry and maaaybe try to fix @@ -34,7 +33,6 @@ test_pyclbr ! this import should find test/pyclbr_input.py test_pyexpat is that an implementation detail? test_quopri ! check if test_script{en,de}code() shows a real bug -test_random should probably be fixed, but no hurry i guess test_repr implementation detail test_shelve ! unknown test_signal ! missing signal.alarm(), probably easy to add @@ -56,7 +54,6 @@ test_urllib2_localnet bogus test? test_urllib2net skipped test test_urllibnet skipped test -test_uu ! unknown test_wait3 no os.wait3() test_wait4 no os.wait4() test_weakref probably missing some gc.collect() From fijal at codespeak.net Tue Jan 27 17:06:18 2009 From: fijal at codespeak.net (fijal at codespeak.net) Date: Tue, 27 Jan 2009 17:06:18 +0100 (CET) Subject: [pypy-svn] r61397 - pypy/trunk/pypy/objspace/std/test Message-ID: <20090127160618.95D7516849B@codespeak.net> Author: fijal Date: Tue Jan 27 17:06:16 2009 New Revision: 61397 Modified: pypy/trunk/pypy/objspace/std/test/test_unicodeobject.py Log: a failing test for subclasses of unicode Modified: pypy/trunk/pypy/objspace/std/test/test_unicodeobject.py ============================================================================== --- pypy/trunk/pypy/objspace/std/test/test_unicodeobject.py (original) +++ pypy/trunk/pypy/objspace/std/test/test_unicodeobject.py Tue Jan 27 17:06:16 2009 @@ -775,3 +775,11 @@ assert u'abc'.replace(buffer('b'), buffer('e')) == u'aec' assert u'abc'.replace(buffer('b'), u'e') == u'aec' assert u'abc'.replace(u'b', buffer('e')) == u'aec' + + def test_unicode_subclass(self): + skip("{fails}") + class S(unicode): + pass + + unicode(S(u'hello \u1234')) + # assert did not explode From antocuni at codespeak.net Tue Jan 27 17:15:46 2009 From: antocuni at codespeak.net (antocuni at codespeak.net) Date: Tue, 27 Jan 2009 17:15:46 +0100 (CET) Subject: [pypy-svn] r61398 - pypy/trunk/lib-python/modified-2.5.2/test Message-ID: <20090127161546.487A8169E2A@codespeak.net> Author: antocuni Date: Tue Jan 27 17:15:45 2009 New Revision: 61398 Modified: pypy/trunk/lib-python/modified-2.5.2/test/test_doctest.py Log: (antocuni, arigo) fix last little differences in the output. test_doctest finally passes :-) Modified: pypy/trunk/lib-python/modified-2.5.2/test/test_doctest.py ============================================================================== --- pypy/trunk/lib-python/modified-2.5.2/test/test_doctest.py (original) +++ pypy/trunk/lib-python/modified-2.5.2/test/test_doctest.py Tue Jan 27 17:15:45 2009 @@ -1605,10 +1605,10 @@ ... 'continue', # stop debugging ... '']) - >>> try: runner.run(test) + >>> try: runner.run(test) # doctest: +ELLIPSIS ... finally: sys.stdin = real_stdin --Return-- - > (1)()->None + > (1)<...>()->None -> import pdb; pdb.set_trace() (Pdb) print x 42 @@ -1634,7 +1634,7 @@ ... 'continue', # stop debugging ... '']) - >>> try: + >>> try: # doctest: +ELLIPSIS ... runner.run(test) ... finally: ... sys.stdin = real_stdin @@ -1644,7 +1644,7 @@ (Pdb) print y 2 (Pdb) up - > (1)() + > (1)<...>() -> calls_set_trace() (Pdb) print x 1 @@ -1672,7 +1672,7 @@ ... 'list', # list source from example 3 ... 'continue', # stop debugging ... '']) - >>> try: runner.run(test) + >>> try: runner.run(test) # doctest: +ELLIPSIS ... finally: sys.stdin = real_stdin ... # doctest: +NORMALIZE_WHITESPACE --Return-- @@ -1693,7 +1693,7 @@ [EOF] (Pdb) next --Return-- - > (1)()->None + > (1)<...>()->None -> f(3) (Pdb) list 1 -> f(3) @@ -1745,7 +1745,7 @@ ... 'continue', # stop debugging ... '']) - >>> try: + >>> try: # doctest: +ELLIPSIS ... runner.run(test) ... finally: ... sys.stdin = real_stdin @@ -1786,10 +1786,10 @@ (Pdb) print y 1 (Pdb) up - > (1)() + > (1)<...>() -> calls_set_trace() (Pdb) print foo - *** NameError: name 'foo' is not defined + *** NameError: ...foo... (Pdb) continue (0, 2) """ From arigo at codespeak.net Tue Jan 27 17:32:12 2009 From: arigo at codespeak.net (arigo at codespeak.net) Date: Tue, 27 Jan 2009 17:32:12 +0100 (CET) Subject: [pypy-svn] r61400 - in pypy/trunk/pypy/interpreter: astcompiler test Message-ID: <20090127163212.9BAFC169E31@codespeak.net> Author: arigo Date: Tue Jan 27 17:32:11 2009 New Revision: 61400 Modified: pypy/trunk/pypy/interpreter/astcompiler/pycodegen.py pypy/trunk/pypy/interpreter/test/test_compiler.py Log: Set a correct co_firstlineno in the presence of decorators -- namely, the line of the first decorator. Modified: pypy/trunk/pypy/interpreter/astcompiler/pycodegen.py ============================================================================== --- pypy/trunk/pypy/interpreter/astcompiler/pycodegen.py (original) +++ pypy/trunk/pypy/interpreter/astcompiler/pycodegen.py Tue Jan 27 17:32:11 2009 @@ -298,9 +298,13 @@ ndecorators = len(node.decorators.nodes) else: ndecorators = 0 + if ndecorators > 0: + initialnode = node.decorators.nodes[0] + else: + initialnode = None gen = FunctionCodeGenerator(self.space, node, isLambda, - self.get_module()) + self.get_module(), initialnode) node.code.accept( gen ) gen.finish() self.set_lineno(node) @@ -1347,7 +1351,7 @@ self.emit('PRINT_EXPR') class AbstractFunctionCode(CodeGenerator): - def __init__(self, space, scope, func, isLambda, mod): + def __init__(self, space, scope, func, isLambda, mod, initialnode=None): assert scope is not None self.scope = scope self.localsfullyknown = self.scope.locals_fully_known() @@ -1401,7 +1405,7 @@ self.graph.setFlag(CO_VARKEYWORDS) if not graph.freevars and not graph.cellvars: self.graph.setFlag(CO_NOFREE) - self.set_lineno(func) + self.set_lineno(initialnode or func) self.generateArgUnpack(func.argnames) def get_module(self): @@ -1438,9 +1442,9 @@ class FunctionCodeGenerator(AbstractFunctionCode): - def __init__(self, space, func, isLambda, mod): + def __init__(self, space, func, isLambda, mod, initialnode=None): AbstractFunctionCode.__init__(self, space, func.scope, - func, isLambda, mod) + func, isLambda, mod, initialnode) if self.scope.generator: self.graph.setFlag(CO_GENERATOR) if self.scope.return_with_arg is not None: Modified: pypy/trunk/pypy/interpreter/test/test_compiler.py ============================================================================== --- pypy/trunk/pypy/interpreter/test/test_compiler.py (original) +++ pypy/trunk/pypy/interpreter/test/test_compiler.py Tue Jan 27 17:32:11 2009 @@ -376,6 +376,22 @@ assert space.int_w(w_fline) == 2 assert space.int_w(w_gline) == 6 + def test_firstlineno_decorators(self): + snippet = str(py.code.Source(r''' + def foo(x): return x + @foo # line 3 + @foo # line 4 + def f(): # line 5 + pass # line 6 + fline = f.func_code.co_firstlineno + ''')) + code = self.compiler.compile(snippet, '', 'exec', 0) + space = self.space + w_d = space.newdict() + code.exec_code(space, w_d, w_d) + w_fline = space.getitem(w_d, space.wrap('fline')) + assert space.int_w(w_fline) == 3 + def test_mangling(self): snippet = str(py.code.Source(r''' __g = "42" From arigo at codespeak.net Tue Jan 27 17:35:51 2009 From: arigo at codespeak.net (arigo at codespeak.net) Date: Tue, 27 Jan 2009 17:35:51 +0100 (CET) Subject: [pypy-svn] r61401 - pypy/trunk/lib-python/modified-2.5.2/test Message-ID: <20090127163551.5C4E5169E34@codespeak.net> Author: arigo Date: Tue Jan 27 17:35:50 2009 New Revision: 61401 Added: pypy/trunk/lib-python/modified-2.5.2/test/test_inspect.py - copied, changed from r61397, pypy/trunk/lib-python/2.5.2/test/test_inspect.py Log: Mark test as an impl detail: isbuiltin([].append) Copied: pypy/trunk/lib-python/modified-2.5.2/test/test_inspect.py (from r61397, pypy/trunk/lib-python/2.5.2/test/test_inspect.py) ============================================================================== --- pypy/trunk/lib-python/2.5.2/test/test_inspect.py (original) +++ pypy/trunk/lib-python/modified-2.5.2/test/test_inspect.py Tue Jan 27 17:35:50 2009 @@ -4,7 +4,7 @@ import inspect import datetime -from test.test_support import TESTFN, run_unittest +from test.test_support import TESTFN, run_unittest, check_impl_detail from test import inspect_fodder as mod from test import inspect_fodder2 as mod2 @@ -51,7 +51,8 @@ def test_excluding_predicates(self): self.istest(inspect.isbuiltin, 'sys.exit') - self.istest(inspect.isbuiltin, '[].append') + if check_impl_detail(): + self.istest(inspect.isbuiltin, '[].append') self.istest(inspect.isclass, 'mod.StupidGit') self.istest(inspect.iscode, 'mod.spam.func_code') self.istest(inspect.isframe, 'tb.tb_frame') From antocuni at codespeak.net Tue Jan 27 18:03:21 2009 From: antocuni at codespeak.net (antocuni at codespeak.net) Date: Tue, 27 Jan 2009 18:03:21 +0100 (CET) Subject: [pypy-svn] r61403 - pypy/trunk/pypy/module/_lsprof Message-ID: <20090127170321.AB420169E2D@codespeak.net> Author: antocuni Date: Tue Jan 27 18:03:20 2009 New Revision: 61403 Modified: pypy/trunk/pypy/module/_lsprof/interp_lsprof.py Log: try to be more careful for corner cases when classes don't have __name__ and Functions don't have w_module Modified: pypy/trunk/pypy/module/_lsprof/interp_lsprof.py ============================================================================== --- pypy/trunk/pypy/module/_lsprof/interp_lsprof.py (original) +++ pypy/trunk/pypy/module/_lsprof/interp_lsprof.py Tue Jan 27 18:03:20 2009 @@ -162,16 +162,18 @@ def create_spec(space, w_arg): if isinstance(w_arg, Method): w_function = w_arg.w_function - w_class = w_arg.w_class - class_name = space.str_w(space.str(w_class)) + class_name = w_arg.w_class.getname(space, '?') assert isinstance(w_function, Function) return "{method '%s' of '%s' objects}" % (w_function.name, class_name) elif isinstance(w_arg, Function): - module = space.str_w(w_arg.w_module) - if module == '__builtin__': + if w_arg.w_module is None: module = '' else: - module += '.' + module = space.str_w(w_arg.w_module) + if module == '__builtin__': + module = '' + else: + module += '.' return '{%s%s function}' % (module, w_arg.name) else: return '{!!!unknown!!!}' From arigo at codespeak.net Tue Jan 27 18:30:24 2009 From: arigo at codespeak.net (arigo at codespeak.net) Date: Tue, 27 Jan 2009 18:30:24 +0100 (CET) Subject: [pypy-svn] r61404 - pypy/trunk/lib-python Message-ID: <20090127173024.7F47216857F@codespeak.net> Author: arigo Date: Tue Jan 27 18:30:21 2009 New Revision: 61404 Modified: pypy/trunk/lib-python/failure_list.txt Log: Remove tests that have been fixed. Modified: pypy/trunk/lib-python/failure_list.txt ============================================================================== --- pypy/trunk/lib-python/failure_list.txt (original) +++ pypy/trunk/lib-python/failure_list.txt Tue Jan 27 18:30:21 2009 @@ -7,7 +7,6 @@ test_descrtut implementation detail only test_dis probably not worth the pain of whacking at the compiler test_distutils this is our issue367 -test_doctest ! obscure differencies test_email_codecs test skipped test_enumerate same as test_iterlen test_file some more exceptions should be raised @@ -18,7 +17,6 @@ test_generators ! the fix is in r60950 but doesn't work. See r60965 test_grammar implementation detail test_import importing from pyc-files-without-py-file disabled by default -test_inspect ! test_wrapped_decorator: try to fix; isbuiltin([].append): cry and maaaybe try to fix test_iterlen somehow implementation detail (missing __length_hint__()) test_itertools same as test_iterlen test_logging ! exception classes have different repr than the rest in cpython @@ -26,13 +24,11 @@ test_parser missing parser.compilest(). I don't think we care for now test_peepholer implementation detail (might be useful to look, though) test_pep277 NT only -test_platform ! we should ensure that our sys.version is compatible enough do that the unmodified _sys_version_parser regexp recognizes it test_plistlib plistlib seems to be Mac only test_poll easy fix, I suppose test_profile ! why is the "profile.py" module not found?? test_pyclbr ! this import should find test/pyclbr_input.py test_pyexpat is that an implementation detail? -test_quopri ! check if test_script{en,de}code() shows a real bug test_repr implementation detail test_shelve ! unknown test_signal ! missing signal.alarm(), probably easy to add From afa at codespeak.net Tue Jan 27 20:28:47 2009 From: afa at codespeak.net (afa at codespeak.net) Date: Tue, 27 Jan 2009 20:28:47 +0100 (CET) Subject: [pypy-svn] r61405 - pypy/trunk/pypy/lib Message-ID: <20090127192847.A1BBF169E1E@codespeak.net> Author: afa Date: Tue Jan 27 20:28:45 2009 New Revision: 61405 Added: pypy/trunk/pypy/lib/_csv.py Log: A pure python implementation of the _csv module. All tests pass ("bin/py.py -m test.test_csv") except one which should be marked as impl_detail IMO Added: pypy/trunk/pypy/lib/_csv.py ============================================================================== --- (empty file) +++ pypy/trunk/pypy/lib/_csv.py Tue Jan 27 20:28:45 2009 @@ -0,0 +1,531 @@ +"""CSV parsing and writing. + +This module provides classes that assist in the reading and writing +of Comma Separated Value (CSV) files, and implements the interface +described by PEP 305. Although many CSV files are simple to parse, +the format is not formally defined by a stable specification and +is subtle enough that parsing lines of a CSV file with something +like line.split(\",\") is bound to fail. The module supports three +basic APIs: reading, writing, and registration of dialects. + + +DIALECT REGISTRATION: + +Readers and writers support a dialect argument, which is a convenient +handle on a group of settings. When the dialect argument is a string, +it identifies one of the dialects previously registered with the module. +If it is a class or instance, the attributes of the argument are used as +the settings for the reader or writer: + + class excel: + delimiter = ',' + quotechar = '\"' + escapechar = None + doublequote = True + skipinitialspace = False + lineterminator = '\\r\\n' + quoting = QUOTE_MINIMAL + +SETTINGS: + + * quotechar - specifies a one-character string to use as the + quoting character. It defaults to '\"'. + * delimiter - specifies a one-character string to use as the + field separator. It defaults to ','. + * skipinitialspace - specifies how to interpret whitespace which + immediately follows a delimiter. It defaults to False, which + means that whitespace immediately following a delimiter is part + of the following field. + * lineterminator - specifies the character sequence which should + terminate rows. + * quoting - controls when quotes should be generated by the writer. + It can take on any of the following module constants: + + csv.QUOTE_MINIMAL means only when required, for example, when a + field contains either the quotechar or the delimiter + csv.QUOTE_ALL means that quotes are always placed around fields. + csv.QUOTE_NONNUMERIC means that quotes are always placed around + fields which do not parse as integers or floating point + numbers. + csv.QUOTE_NONE means that quotes are never placed around fields. + * escapechar - specifies a one-character string used to escape + the delimiter when quoting is set to QUOTE_NONE. + * doublequote - controls the handling of quotes inside fields. When + True, two consecutive quotes are interpreted as one during read, + and when writing, each quote character embedded in the data is + written as two quotes. +""" + +__version__ = "1.0" + +QUOTE_MINIMAL, QUOTE_ALL, QUOTE_NONNUMERIC, QUOTE_NONE = range(4) +_dialects = {} +_field_limit = 128 * 1024 # max parsed field size + +class Error(Exception): + pass + +class Dialect(object): + """CSV dialect + + The Dialect type records CSV parsing and generation options.""" + + __slots__ = ["delimiter", "doublequote", "escapechar", "lineterminator", + "quotechar", "quoting", "skipinitialspace", "strict"] + + def __new__(cls, dialect, **kwargs): + + for name in kwargs: + if name not in Dialect.__slots__: + raise TypeError("unexpected keyword argument '%s'" % + (name,)) + + if dialect is not None: + if isinstance(dialect, basestring): + dialect = get_dialect(dialect) + + # Can we reuse this instance? + if (isinstance(dialect, Dialect) + and all(value is None for value in kwargs.itervalues())): + return dialect + + self = object.__new__(cls) + + + def set_char(x): + if x is None: + return None + if isinstance(x, str) and len(x) <= 1: + return x + raise TypeError("%r must be a 1-character string" % (name,)) + def set_str(x): + if isinstance(x, str): + return x + raise TypeError("%r must be a string" % (name,)) + def set_quoting(x): + if x in range(4): + return x + raise TypeError("bad 'quoting' value") + + attributes = {"delimiter": (',', set_char), + "doublequote": (True, bool), + "escapechar": (None, set_char), + "lineterminator": ("\r\n", set_str), + "quotechar": ('"', set_char), + "quoting": (QUOTE_MINIMAL, set_quoting), + "skipinitialspace": (False, bool), + "strict": (False, bool), + } + + # Copy attributes + notset = object() + for name in Dialect.__slots__: + value = notset + if name in kwargs: + value = kwargs[name] + elif dialect is not None: + value = getattr(dialect, name, notset) + + # mapping by name: (default, converter) + if value is notset: + value = attributes[name][0] + if name == 'quoting' and not self.quotechar: + value = QUOTE_NONE + else: + converter = attributes[name][1] + if converter: + value = converter(value) + + setattr(self, name, value) + + if not self.delimiter: + raise TypeError("delimiter must be set") + + if self.quoting != QUOTE_NONE and not self.quotechar: + raise TypeError("quotechar must be set if quoting enabled") + + if not self.lineterminator: + raise TypeError("lineterminator must be set") + + return self + + +def _call_dialect(dialect_inst, kwargs): + return Dialect(dialect_inst, **kwargs) + +def register_dialect(name, dialect=None, **kwargs): + """Create a mapping from a string name to a dialect class. + dialect = csv.register_dialect(name, dialect)""" + if not isinstance(name, basestring): + raise TypeError("dialect name must be a string or unicode") + + dialect = _call_dialect(dialect, kwargs) + _dialects[name] = dialect + +def unregister_dialect(name): + """Delete the name/dialect mapping associated with a string name.\n + csv.unregister_dialect(name)""" + try: + del _dialects[name] + except KeyError: + raise Error("unknown dialect") + +def get_dialect(name): + """Return the dialect instance associated with name. + dialect = csv.get_dialect(name)""" + try: + return _dialects[name] + except KeyError: + raise Error("unknown dialect") + +def list_dialects(): + """Return a list of all know dialect names + names = csv.list_dialects()""" + return list(_dialects) + +class Reader: + + """CSV reader + + Reader objects are responsible for reading and parsing tabular data + in CSV format.""" + + + (START_RECORD, START_FIELD, ESCAPED_CHAR, IN_FIELD, + IN_QUOTED_FIELD, ESCAPE_IN_QUOTED_FIELD, QUOTE_IN_QUOTED_FIELD, + EAT_CRNL) = range(8) + + def __init__(self, iterator, dialect=None, **kwargs): + self.dialect = _call_dialect(dialect, kwargs) + self.input_iter = iter(iterator) + self.line_num = 0 + + self._parse_reset() + + def _parse_reset(self): + self.field = [] + self.fields = [] + self.state = self.START_RECORD + self.numeric_field = False + + def __iter__(self): + return self + + def next(self): + self._parse_reset() + while True: + try: + line = self.input_iter.next() + except StopIteration: + # End of input OR exception + if len(self.field) > 0: + raise Error("newline inside string") + raise + + self.line_num += 1 + + for c in line: + if c == '\0': + raise Error("line contains NULL byte") + self._parse_process_char(c) + self._parse_process_char('\0') + + if self.state == self.START_RECORD: + break + + fields = self.fields + self.fields = [] + return fields + + def _parse_process_char(self, c): + if self.state == self.IN_FIELD: + # in unquoted field + if c in ('\n', '\r', '\0'): + # end of line - return [fields] + self._parse_save_field() + if c == '\0': + self.state = self.START_RECORD + else: + self.state = self.EAT_CRNL + elif c == self.dialect.escapechar: + # possible escaped character + self.state = self.ESCAPED_CHAR + elif c == self.dialect.delimiter: + # save field - wait for new field + self._parse_save_field() + self.state = self.START_FIELD + else: + # normal character - save in field + self._parse_add_char(c) + + elif self.state == self.START_RECORD: + if c == '\0': + # empty line - return [] + pass + elif c in ('\n', '\r'): + self.state = self.EAT_CRNL + else: + self.state = self.START_FIELD + # restart process + self._parse_process_char(c) + + elif self.state == self.START_FIELD: + if c in ('\n', '\r', '\0'): + # save empty field - return [fields] + self._parse_save_field() + if c == '\0': + self.state = self.START_RECORD + else: + self.state = self.EAT_CRNL + elif (c == self.dialect.quotechar + and self.dialect.quoting != QUOTE_NONE): + # start quoted field + self.state = self.IN_QUOTED_FIELD + elif c == self.dialect.escapechar: + # possible escaped character + self.state = self.ESCAPED_CHAR + elif c == ' ' and self.dialect.skipinitialspace: + # ignore space at start of field + pass + elif c == self.dialect.delimiter: + # save empty field + self._parse_save_field() + else: + # begin new unquoted field + if self.dialect.quoting == QUOTE_NONNUMERIC: + self.numeric_field = True + self._parse_add_char(c) + self.state = self.IN_FIELD + + elif self.state == self.ESCAPED_CHAR: + if c == '\0': + c = '\n' + self._parse_add_char(c) + self.state = self.IN_FIELD + + elif self.state == self.IN_QUOTED_FIELD: + if c == '\0': + pass + elif c == self.dialect.escapechar: + # possible escape character + self.state = self.ESCAPE_IN_QUOTED_FIELD + elif (c == self.dialect.quotechar + and self.dialect.quoting != QUOTE_NONE): + if self.dialect.doublequote: + # doublequote; " represented by "" + self.state = self.QUOTE_IN_QUOTED_FIELD + else: + #end of quote part of field + self.state = self.IN_FIELD + else: + # normal character - save in field + self._parse_add_char(c) + + elif self.state == self.ESCAPE_IN_QUOTED_FIELD: + if c == '\0': + c = '\n' + self._parse_add_char(c) + self.state = self.IN_QUOTED_FIELD + + elif self.state == self.QUOTE_IN_QUOTED_FIELD: + # doublequote - seen a quote in a quoted field + if (c == self.dialect.quotechar + and self.dialect.quoting != QUOTE_NONE): + # save "" as " + self._parse_add_char(c) + self.state = self.IN_QUOTED_FIELD + elif c == self.dialect.delimiter: + # save field - wait for new field + self._parse_save_field() + self.state = self.START_FIELD + elif c in ('\r', '\n', '\0'): + # end of line - return [fields] + self._parse_save_field() + if c == '\0': + self.state = self.START_RECORD + else: + self.state = self.EAT_CRNL + elif not self.dialect.strict: + self._parse_add_char(c) + self.state = self.IN_FIELD + else: + raise Error("'%c' expected after '%c'" % + (self.dialect.delimiter, self.dialect.quotechar)) + + elif self.state == self.EAT_CRNL: + if c in ('\r', '\n'): + pass + elif c == '\0': + self.state = self.START_RECORD + else: + raise Error("new-line character seen in unquoted field - " + "do you need to open the file " + "in universal-newline mode?") + + else: + raise RuntimeError("unknown state: %r" % (self.state,)) + + def _parse_save_field(self): + field, self.field = self.field, [] + field = ''.join(field) + if self.numeric_field: + self.numeric_field = False + field = float(field) + self.fields.append(field) + + def _parse_add_char(self, c): + if len(self.field) >= _field_limit: + raise Error("field larget than field limit (%d)" % (_field_limit)) + self.field.append(c) + + +class Writer: + """CSV writer + + Writer objects are responsible for generating tabular data + in CSV format from sequence input.""" + + def __init__(self, file, dialect=None, **kwargs): + if not (hasattr(file, 'write') and callable(file.write)): + raise TypeError("argument 1 must have a 'write' method") + self.writeline = file.write + self.dialect = _call_dialect(dialect, kwargs) + + def _join_reset(self): + self.rec = [] + self.num_fields = 0 + + def _join_append(self, field, quoted, quote_empty): + dialect = self.dialect + # If this is not the first field we need a field separator + if self.num_fields > 0: + self.rec.append(dialect.delimiter) + + if dialect.quoting == QUOTE_NONE: + need_escape = tuple(dialect.lineterminator) + ( + dialect.escapechar, # escapechar always first + dialect.delimiter, dialect.quotechar) + + else: + for c in tuple(dialect.lineterminator) + ( + dialect.delimiter, dialect.escapechar): + if c and c in field: + quoted = True + + need_escape = () + if dialect.quotechar in field: + if dialect.doublequote: + field = field.replace(dialect.quotechar, + dialect.quotechar * 2) + quoted = True + else: + need_escape = (dialect.quotechar,) + + + for c in need_escape: + if c and c in field: + if not dialect.escapechar: + raise Error("need to escape, but no escapechar set") + field = field.replace(c, dialect.escapechar + c) + + # If field is empty check if it needs to be quoted + if field == '' and quote_empty: + if dialect.quoting == QUOTE_NONE: + raise Error("single empty field record must be quoted") + quoted = 1 + + if quoted: + field = dialect.quotechar + field + dialect.quotechar + + self.rec.append(field) + self.num_fields += 1 + + + + def writerow(self, row): + dialect = self.dialect + try: + rowlen = len(row) + except TypeError: + raise Error("sequence expected") + + # join all fields in internal buffer + self._join_reset() + + for field in row: + quoted = False + if dialect.quoting == QUOTE_NONNUMERIC: + try: + float(field) + except: + quoted = True + # This changed since 2.5: + # quoted = not isinstance(field, (int, long, float)) + elif dialect.quoting == QUOTE_ALL: + quoted = True + + if field is None: + self._join_append("", quoted, rowlen == 1) + else: + self._join_append(str(field), quoted, rowlen == 1) + + # add line terminator + self.rec.append(dialect.lineterminator) + + self.writeline(''.join(self.rec)) + + def writerows(self, rows): + for row in rows: + self.writerow(row) + +def reader(*args, **kwargs): + """ + csv_reader = reader(iterable [, dialect='excel'] + [optional keyword args]) + for row in csv_reader: + process(row) + + The "iterable" argument can be any object that returns a line + of input for each iteration, such as a file object or a list. The + optional \"dialect\" parameter is discussed below. The function + also accepts optional keyword arguments which override settings + provided by the dialect. + + The returned object is an iterator. Each iteration returns a row + of the CSV file (which can span multiple input lines)""" + + return Reader(*args, **kwargs) + +def writer(*args, **kwargs): + """ + csv_writer = csv.writer(fileobj [, dialect='excel'] + [optional keyword args]) + for row in sequence: + csv_writer.writerow(row) + + [or] + + csv_writer = csv.writer(fileobj [, dialect='excel'] + [optional keyword args]) + csv_writer.writerows(rows) + + The \"fileobj\" argument can be any object that supports the file API.""" + return Writer(*args, **kwargs) + +def field_size_limit(limit=None): + """Sets an upper limit on parsed fields. + csv.field_size_limit([limit]) + + Returns old limit. If limit is not given, no new limit is set and + the old limit is returned""" + + global _field_limit + old_limit = _field_limit + + if limit is not None: + if not isinstance(limit, (int, long)): + raise TypeError("int expected, got %s" % + (limit.__class__.__name__,)) + _field_limit = limit + + return old_limit From fijal at codespeak.net Tue Jan 27 20:51:31 2009 From: fijal at codespeak.net (fijal at codespeak.net) Date: Tue, 27 Jan 2009 20:51:31 +0100 (CET) Subject: [pypy-svn] r61407 - pypy/trunk/lib-python Message-ID: <20090127195131.82EDC169E28@codespeak.net> Author: fijal Date: Tue Jan 27 20:51:31 2009 New Revision: 61407 Modified: pypy/trunk/lib-python/conftest.py Log: thanks to Amaury, csv is supported right now (need to skip one test, will look tomorrow to the log) Modified: pypy/trunk/lib-python/conftest.py ============================================================================== --- pypy/trunk/lib-python/conftest.py (original) +++ pypy/trunk/lib-python/conftest.py Tue Jan 27 20:51:31 2009 @@ -185,7 +185,7 @@ RegrTest('test_copy_reg.py', core=True), RegrTest('test_cpickle.py', core=True), RegrTest('test_crypt.py', usemodules='crypt'), - RegrTest('test_csv.py', skip="unsupported extension module"), + RegrTest('test_csv.py'), RegrTest('test_curses.py', skip="unsupported extension module"), RegrTest('test_datetime.py'), From pedronis at codespeak.net Tue Jan 27 20:59:38 2009 From: pedronis at codespeak.net (pedronis at codespeak.net) Date: Tue, 27 Jan 2009 20:59:38 +0100 (CET) Subject: [pypy-svn] r61408 - pypy/extradoc/sprintinfo/wroclaw2009 Message-ID: <20090127195938.4C65516850D@codespeak.net> Author: pedronis Date: Tue Jan 27 20:59:37 2009 New Revision: 61408 Modified: pypy/extradoc/sprintinfo/wroclaw2009/people.txt Log: my info fwiw Modified: pypy/extradoc/sprintinfo/wroclaw2009/people.txt ============================================================================== --- pypy/extradoc/sprintinfo/wroclaw2009/people.txt (original) +++ pypy/extradoc/sprintinfo/wroclaw2009/people.txt Tue Jan 27 20:59:37 2009 @@ -8,6 +8,7 @@ ==================== ============== ============================ Name Arrive/Depart Accomodation ==================== ============== ============================ +Samuele Pedroni 6/15 Hotel Duet ==================== ============== ============================ From fijal at codespeak.net Tue Jan 27 21:21:33 2009 From: fijal at codespeak.net (fijal at codespeak.net) Date: Tue, 27 Jan 2009 21:21:33 +0100 (CET) Subject: [pypy-svn] r61409 - in pypy/trunk/pypy/objspace/std: . test Message-ID: <20090127202133.BD30E169E36@codespeak.net> Author: fijal Date: Tue Jan 27 21:21:29 2009 New Revision: 61409 Modified: pypy/trunk/pypy/objspace/std/test/test_unicodeobject.py pypy/trunk/pypy/objspace/std/unicodetype.py Log: More convoluted logic :( This is kind of bug-to-bug compatibility Modified: pypy/trunk/pypy/objspace/std/test/test_unicodeobject.py ============================================================================== --- pypy/trunk/pypy/objspace/std/test/test_unicodeobject.py (original) +++ pypy/trunk/pypy/objspace/std/test/test_unicodeobject.py Tue Jan 27 21:21:29 2009 @@ -777,7 +777,6 @@ assert u'abc'.replace(u'b', buffer('e')) == u'aec' def test_unicode_subclass(self): - skip("{fails}") class S(unicode): pass Modified: pypy/trunk/pypy/objspace/std/unicodetype.py ============================================================================== --- pypy/trunk/pypy/objspace/std/unicodetype.py (original) +++ pypy/trunk/pypy/objspace/std/unicodetype.py Tue Jan 27 21:21:29 2009 @@ -257,8 +257,12 @@ from pypy.objspace.std.ropeunicodeobject import W_RopeUnicodeObject w_obj = w_string - encoding, errors = _get_encoding_and_errors(space, w_encoding, w_errors) - if space.is_w(space.type(w_obj), space.w_unicode): + encoding, errors = _get_encoding_and_errors(space, w_encoding, w_errors) + # convoluted logic for the case when unicode subclass has a __unicode__ + # method, we need to call this method + if (space.is_w(space.type(w_obj), space.w_unicode) or + (space.is_true(space.isinstance(w_obj, space.w_unicode)) and + space.findattr(w_obj, space.wrap('__unicode__')) is None)): if encoding is not None or errors is not None: raise OperationError(space.w_TypeError, space.wrap('decoding Unicode is not supported')) From antocuni at codespeak.net Tue Jan 27 22:00:02 2009 From: antocuni at codespeak.net (antocuni at codespeak.net) Date: Tue, 27 Jan 2009 22:00:02 +0100 (CET) Subject: [pypy-svn] r61410 - pypy/trunk/pypy/objspace/std/test Message-ID: <20090127210002.16293169E3B@codespeak.net> Author: antocuni Date: Tue Jan 27 22:00:01 2009 New Revision: 61410 Modified: pypy/trunk/pypy/objspace/std/test/test_unicodeobject.py Log: enhance this test Modified: pypy/trunk/pypy/objspace/std/test/test_unicodeobject.py ============================================================================== --- pypy/trunk/pypy/objspace/std/test/test_unicodeobject.py (original) +++ pypy/trunk/pypy/objspace/std/test/test_unicodeobject.py Tue Jan 27 22:00:01 2009 @@ -780,5 +780,7 @@ class S(unicode): pass - unicode(S(u'hello \u1234')) - # assert did not explode + a = S(u'hello \u1234') + b = unicode(a) + assert type(b) is unicode + assert b == u'hello \u1234' From getxsick at codespeak.net Tue Jan 27 22:23:55 2009 From: getxsick at codespeak.net (getxsick at codespeak.net) Date: Tue, 27 Jan 2009 22:23:55 +0100 (CET) Subject: [pypy-svn] r61411 - pypy/extradoc/sprintinfo/wroclaw2009 Message-ID: <20090127212355.12189169E2B@codespeak.net> Author: getxsick Date: Tue Jan 27 22:23:53 2009 New Revision: 61411 Modified: pypy/extradoc/sprintinfo/wroclaw2009/people.txt Log: added myself Modified: pypy/extradoc/sprintinfo/wroclaw2009/people.txt ============================================================================== --- pypy/extradoc/sprintinfo/wroclaw2009/people.txt (original) +++ pypy/extradoc/sprintinfo/wroclaw2009/people.txt Tue Jan 27 22:23:53 2009 @@ -9,6 +9,7 @@ Name Arrive/Depart Accomodation ==================== ============== ============================ Samuele Pedroni 6/15 Hotel Duet +Bartosz Skowron 7/14 private ==================== ============== ============================ From fijal at codespeak.net Tue Jan 27 22:52:18 2009 From: fijal at codespeak.net (fijal at codespeak.net) Date: Tue, 27 Jan 2009 22:52:18 +0100 (CET) Subject: [pypy-svn] r61412 - pypy/extradoc/sprintinfo/wroclaw2009 Message-ID: <20090127215218.383EC169E1F@codespeak.net> Author: fijal Date: Tue Jan 27 22:52:16 2009 New Revision: 61412 Modified: pypy/extradoc/sprintinfo/wroclaw2009/people.txt Log: me Modified: pypy/extradoc/sprintinfo/wroclaw2009/people.txt ============================================================================== --- pypy/extradoc/sprintinfo/wroclaw2009/people.txt (original) +++ pypy/extradoc/sprintinfo/wroclaw2009/people.txt Tue Jan 27 22:52:16 2009 @@ -10,6 +10,7 @@ ==================== ============== ============================ Samuele Pedroni 6/15 Hotel Duet Bartosz Skowron 7/14 private +Maciej Fijalkowski 5/15 private ==================== ============== ============================ @@ -20,7 +21,6 @@ ==================== ============== ===================== Antonio Cuni ? ? Holger Krekel ? ? -Maciej Fijalkowski ? ? Jakub Gustak ? ? Stephan Diehl ? ? Samuele Pedroni ? ? From afa at codespeak.net Wed Jan 28 00:23:10 2009 From: afa at codespeak.net (afa at codespeak.net) Date: Wed, 28 Jan 2009 00:23:10 +0100 (CET) Subject: [pypy-svn] r61414 - pypy/trunk/pypy/lib Message-ID: <20090127232310.3B4C1169E1A@codespeak.net> Author: afa Date: Wed Jan 28 00:23:07 2009 New Revision: 61414 Modified: pypy/trunk/pypy/lib/_hashlib.py pypy/trunk/pypy/lib/hashlib.py Log: - Ensure that "import _hashlib" raises ImportError when OpenSSL cannot be found. - Fix hashlib to expose our builtin implementations in this case. This should fix the "import urllib" failures on the win32 buildbot. Modified: pypy/trunk/pypy/lib/_hashlib.py ============================================================================== --- pypy/trunk/pypy/lib/_hashlib.py (original) +++ pypy/trunk/pypy/lib/_hashlib.py Wed Jan 28 00:23:07 2009 @@ -4,6 +4,8 @@ # Note: OpenSSL on OS X only provides md5 and sha1 libpath = ctypes.util.find_library('ssl') +if not libpath: + raise ImportError('could not find OpenSSL library') lib = CDLL(libpath) # Linux, OS X lib.EVP_get_digestbyname.restype = c_void_p lib.EVP_DigestInit.argtypes = [c_void_p, c_void_p] Modified: pypy/trunk/pypy/lib/hashlib.py ============================================================================== --- pypy/trunk/pypy/lib/hashlib.py (original) +++ pypy/trunk/pypy/lib/hashlib.py Wed Jan 28 00:23:07 2009 @@ -50,8 +50,10 @@ 'a4337bc45a8fc544c03f52dc550cd6e1e87021bc896588bd79e901e2' """ -import _hashlib - +try: + import _hashlib +except ImportError: + _hashlib = None def __get_builtin_constructor(name): if name in ('SHA1', 'sha1'): @@ -73,13 +75,16 @@ optionally initialized with a string. """ try: - return _hashlib.new(name, string) + if _hashlib: + return _hashlib.new(name, string) except ValueError: # If the _hashlib module (OpenSSL) doesn't support the named # hash, try using our builtin implementations. # This allows for SHA224/256 and SHA384/512 support even though # the OpenSSL library prior to 0.9.8 doesn't provide them. - return __get_builtin_constructor(name)(string) + pass + + return __get_builtin_constructor(name)(string) new = __hash_new @@ -105,4 +110,13 @@ # this one has no builtin implementation, don't define it pass -_setfuncs() +if _hashlib: + _setfuncs() +else: + # lookup the C function to use directly for the named constructors + md5 = __get_builtin_constructor('md5') + sha1 = __get_builtin_constructor('sha1') + sha224 = __get_builtin_constructor('sha224') + sha256 = __get_builtin_constructor('sha256') + #sha384 = __get_builtin_constructor('sha384') + #sha512 = __get_builtin_constructor('sha512') From afa at codespeak.net Wed Jan 28 09:55:33 2009 From: afa at codespeak.net (afa at codespeak.net) Date: Wed, 28 Jan 2009 09:55:33 +0100 (CET) Subject: [pypy-svn] r61415 - pypy/trunk/pypy/lib Message-ID: <20090128085533.9D50A169E41@codespeak.net> Author: afa Date: Wed Jan 28 09:55:31 2009 New Revision: 61415 Modified: pypy/trunk/pypy/lib/grp.py Log: Raise ImportError when trying to import the grp module on Windows. This should fix test___all__. Modified: pypy/trunk/pypy/lib/grp.py ============================================================================== --- pypy/trunk/pypy/lib/grp.py (original) +++ pypy/trunk/pypy/lib/grp.py Wed Jan 28 09:55:31 2009 @@ -2,6 +2,10 @@ """ This module provides ctypes version of cpython's grp module """ +import sys +if sys.platform == 'win32': + raise ImportError("No grp module on Windows") + from ctypes import Structure, c_char_p, c_int, POINTER from ctypes_support import standard_c_lib as libc From afa at codespeak.net Wed Jan 28 10:13:46 2009 From: afa at codespeak.net (afa at codespeak.net) Date: Wed, 28 Jan 2009 10:13:46 +0100 (CET) Subject: [pypy-svn] r61416 - pypy/trunk/pypy/lib Message-ID: <20090128091346.D0805169E35@codespeak.net> Author: afa Date: Wed Jan 28 10:13:46 2009 New Revision: 61416 Modified: pypy/trunk/pypy/lib/_csv.py Log: Fix one test in test_csv Modified: pypy/trunk/pypy/lib/_csv.py ============================================================================== --- pypy/trunk/pypy/lib/_csv.py (original) +++ pypy/trunk/pypy/lib/_csv.py Wed Jan 28 10:13:46 2009 @@ -519,6 +519,9 @@ Returns old limit. If limit is not given, no new limit is set and the old limit is returned""" + if not isinstance(limit, (long, int)): + raise TypeError("limit must be an integer") + global _field_limit old_limit = _field_limit From arigo at codespeak.net Wed Jan 28 11:49:17 2009 From: arigo at codespeak.net (arigo at codespeak.net) Date: Wed, 28 Jan 2009 11:49:17 +0100 (CET) Subject: [pypy-svn] r61420 - pypy/extradoc/sprintinfo/wroclaw2009 Message-ID: <20090128104917.DEFE4169E46@codespeak.net> Author: arigo Date: Wed Jan 28 11:49:16 2009 New Revision: 61420 Modified: pypy/extradoc/sprintinfo/wroclaw2009/people.txt Log: Register myself. Modified: pypy/extradoc/sprintinfo/wroclaw2009/people.txt ============================================================================== --- pypy/extradoc/sprintinfo/wroclaw2009/people.txt (original) +++ pypy/extradoc/sprintinfo/wroclaw2009/people.txt Wed Jan 28 11:49:16 2009 @@ -11,6 +11,7 @@ Samuele Pedroni 6/15 Hotel Duet Bartosz Skowron 7/14 private Maciej Fijalkowski 5/15 private +Armin Rigo 5/13 ? ==================== ============== ============================ From afa at codespeak.net Wed Jan 28 12:51:13 2009 From: afa at codespeak.net (afa at codespeak.net) Date: Wed, 28 Jan 2009 12:51:13 +0100 (CET) Subject: [pypy-svn] r61421 - pypy/trunk/pypy/module/posix/test Message-ID: <20090128115113.E92B3169E3B@codespeak.net> Author: afa Date: Wed Jan 28 12:51:12 2009 New Revision: 61421 Modified: pypy/trunk/pypy/module/posix/test/test_posix2.py Log: Don't test os.uname on Windows Modified: pypy/trunk/pypy/module/posix/test/test_posix2.py ============================================================================== --- pypy/trunk/pypy/module/posix/test/test_posix2.py (original) +++ pypy/trunk/pypy/module/posix/test/test_posix2.py Wed Jan 28 12:51:12 2009 @@ -296,13 +296,14 @@ assert os.WIFSIGNALED(0) == False assert os.WIFSIGNALED(1) == True - def test_os_uname(self): - os = self.posix - res = os.uname() - assert len(res) == 5 - for i in res: - assert isinstance(i, str) - assert isinstance(res, tuple) + if hasattr(os, 'uname'): + def test_os_uname(self): + os = self.posix + res = os.uname() + assert len(res) == 5 + for i in res: + assert isinstance(i, str) + assert isinstance(res, tuple) if hasattr(os, 'getuid'): def test_os_getuid(self): From afa at codespeak.net Wed Jan 28 13:40:16 2009 From: afa at codespeak.net (afa at codespeak.net) Date: Wed, 28 Jan 2009 13:40:16 +0100 (CET) Subject: [pypy-svn] r61422 - pypy/trunk/pypy/lib Message-ID: <20090128124016.3E10C169E4A@codespeak.net> Author: afa Date: Wed Jan 28 13:40:13 2009 New Revision: 61422 Modified: pypy/trunk/pypy/lib/ctypes_support.py Log: The _rawffi module is not available when running app tests directly on top of CPython. Since running app tests does not work at all on Windows (a distutils problem probably), I moved "import _rawffi" into the win32 specific part of the file. Modified: pypy/trunk/pypy/lib/ctypes_support.py ============================================================================== --- pypy/trunk/pypy/lib/ctypes_support.py (original) +++ pypy/trunk/pypy/lib/ctypes_support.py Wed Jan 28 13:40:13 2009 @@ -9,9 +9,8 @@ # __________ the standard C library __________ -import _rawffi - if sys.platform == 'win32': + import _rawffi standard_c_lib = ctypes.CDLL('msvcrt', handle=_rawffi.get_libc()) else: standard_c_lib = ctypes.CDLL(ctypes.util.find_library('c')) From fijal at codespeak.net Wed Jan 28 15:07:00 2009 From: fijal at codespeak.net (fijal at codespeak.net) Date: Wed, 28 Jan 2009 15:07:00 +0100 (CET) Subject: [pypy-svn] r61423 - in pypy/trunk/pypy/interpreter: . astcompiler/test pyparser test Message-ID: <20090128140700.76A96169E4A@codespeak.net> Author: fijal Date: Wed Jan 28 15:06:58 2009 New Revision: 61423 Modified: pypy/trunk/pypy/interpreter/astcompiler/test/test_compiler.py pypy/trunk/pypy/interpreter/pycompiler.py pypy/trunk/pypy/interpreter/pyparser/error.py pypy/trunk/pypy/interpreter/pyparser/grammar.py pypy/trunk/pypy/interpreter/pyparser/pythonlexer.py pypy/trunk/pypy/interpreter/pyparser/pythonparse.py pypy/trunk/pypy/interpreter/test/test_compiler.py Log: fishy fishy fish. A hackish way of introducing correct errors. The thing is that I failed a bit to do it correct way, so I introduce cpython-like scheme of storing error encountered for some examples. Modified: pypy/trunk/pypy/interpreter/astcompiler/test/test_compiler.py ============================================================================== --- pypy/trunk/pypy/interpreter/astcompiler/test/test_compiler.py (original) +++ pypy/trunk/pypy/interpreter/astcompiler/test/test_compiler.py Wed Jan 28 15:06:58 2009 @@ -3,6 +3,7 @@ from pypy.interpreter.pyparser.test.test_astbuilder import source2ast from pypy.interpreter.pyparser.test import expressions from pypy.interpreter.pycode import PyCode +from pypy.interpreter.pyparser.error import SyntaxError, IndentationError def compile_with_astcompiler(expr, mode, space): ast = source2ast(expr, mode, space) @@ -654,3 +655,6 @@ assert e.msg == 'expected an indented block' else: raise Exception("DID NOT RAISE") + + def test_kwargs_last(self): + py.test.raises(SyntaxError, "int(base=10, '2')") Modified: pypy/trunk/pypy/interpreter/pycompiler.py ============================================================================== --- pypy/trunk/pypy/interpreter/pycompiler.py (original) +++ pypy/trunk/pypy/interpreter/pycompiler.py Wed Jan 28 15:06:58 2009 @@ -239,6 +239,7 @@ from pypy.interpreter.function import Function from pypy.interpreter.pyparser.future import getFutures + from pypy.interpreter.pyparser.pythonlexer import TokenIndentationError ## flags |= stdlib___future__.generators.compiler_flag # always on (2.2 compat) space = self.space @@ -255,6 +256,9 @@ except IndentationError, e: raise OperationError(space.w_IndentationError, e.wrap_info(space, filename)) + except TokenIndentationError, e: + raise OperationError(space.w_IndentationError, + e.wrap_info(space, filename)) except SyntaxError, e: raise OperationError(space.w_SyntaxError, e.wrap_info(space, filename)) Modified: pypy/trunk/pypy/interpreter/pyparser/error.py ============================================================================== --- pypy/trunk/pypy/interpreter/pyparser/error.py (original) +++ pypy/trunk/pypy/interpreter/pyparser/error.py Wed Jan 28 15:06:58 2009 @@ -33,7 +33,7 @@ class TokenError(Exception): - def __init__(self, msg, tokens ): + def __init__(self, msg, tokens): self.msg = msg self.tokens = tokens Modified: pypy/trunk/pypy/interpreter/pyparser/grammar.py ============================================================================== --- pypy/trunk/pypy/interpreter/pyparser/grammar.py (original) +++ pypy/trunk/pypy/interpreter/pyparser/grammar.py Wed Jan 28 15:06:58 2009 @@ -15,6 +15,8 @@ Wrappable = object NULLTOKEN = -1 # None +NO_ERROR = 0 +ERROR_EXPECTED_INDENT = 1 from syntaxtree import SyntaxNode, TempSyntaxNode, TokenNode @@ -712,6 +714,11 @@ if DEBUG > 1: print "tried tok:", self.display() source.restore( ctx ) + try: + if self.codename == self.parser.tokens['INDENT']: + self.parser.found_error = ERROR_EXPECTED_INDENT + except KeyError: + pass # XXX bootstrapping return 0 def display(self, level=0): @@ -773,6 +780,7 @@ self._sym_count = 0 self.all_rules = [] self.root_rules = {} + self.found_error = NO_ERROR def symbol_repr( self, codename ): if codename in self.tok_name: Modified: pypy/trunk/pypy/interpreter/pyparser/pythonlexer.py ============================================================================== --- pypy/trunk/pypy/interpreter/pyparser/pythonlexer.py (original) +++ pypy/trunk/pypy/interpreter/pyparser/pythonlexer.py Wed Jan 28 15:06:58 2009 @@ -63,6 +63,9 @@ SyntaxError.__init__(self, msg, lineno, offset + 1, line) self.token_stack = token_stack +class TokenIndentationError(TokenError): + pass + def generate_tokens( parser, lines, flags, keywords): """ This is a rewrite of pypy.module.parser.pytokenize.generate_tokens since @@ -170,7 +173,7 @@ token_list.append((tok, line, lnum, pos)) last_comment = '' if column != indents[-1]: - raise TokenError("unindent does not match any outer indentation level", + raise TokenIndentationError("unindent does not match any outer indentation level", line, (lnum, 0), token_list) else: # continued statement Modified: pypy/trunk/pypy/interpreter/pyparser/pythonparse.py ============================================================================== --- pypy/trunk/pypy/interpreter/pyparser/pythonparse.py (original) +++ pypy/trunk/pypy/interpreter/pyparser/pythonparse.py Wed Jan 28 15:06:58 2009 @@ -139,11 +139,16 @@ src = Source(self, lines, keywords, flags) if not target.match(src, builder): + # clean up errors + found_error = self.found_error + self.found_error = grammar.NO_ERROR tok, line, lnum, pos = src.most_recent_token() if tok.codename == self.tokens['INDENT']: raise IndentationError("unexpected indent", lnum, pos, line) if tok.codename == self.tokens['DEDENT']: raise IndentationError("unexpected dedent", lnum, pos, line) + if found_error == grammar.ERROR_EXPECTED_INDENT: + raise IndentationError("expected an indented block", lnum, pos, line) raise SyntaxError("invalid syntax", lnum, pos, line) return builder Modified: pypy/trunk/pypy/interpreter/test/test_compiler.py ============================================================================== --- pypy/trunk/pypy/interpreter/test/test_compiler.py (original) +++ pypy/trunk/pypy/interpreter/test/test_compiler.py Wed Jan 28 15:06:58 2009 @@ -779,3 +779,17 @@ else: raise Exception("DID NOT RAISE") + + + def test_bad_oudent(self): + source = """if 1: + x + y + z + """ + try: + exec source + except IndentationError, e: + assert e.msg == 'unindent does not match any outer indentation level' + else: + raise Exception("DID NOT RAISE") From fijal at codespeak.net Wed Jan 28 16:31:35 2009 From: fijal at codespeak.net (fijal at codespeak.net) Date: Wed, 28 Jan 2009 16:31:35 +0100 (CET) Subject: [pypy-svn] r61425 - in pypy/trunk/pypy/interpreter: astcompiler/test pyparser Message-ID: <20090128153135.48971169E3E@codespeak.net> Author: fijal Date: Wed Jan 28 16:31:32 2009 New Revision: 61425 Modified: pypy/trunk/pypy/interpreter/astcompiler/test/test_compiler.py pypy/trunk/pypy/interpreter/pyparser/asthelper.py Log: another convoluted layer of logic, for catching x(y=3, 4) Modified: pypy/trunk/pypy/interpreter/astcompiler/test/test_compiler.py ============================================================================== --- pypy/trunk/pypy/interpreter/astcompiler/test/test_compiler.py (original) +++ pypy/trunk/pypy/interpreter/astcompiler/test/test_compiler.py Wed Jan 28 16:31:32 2009 @@ -657,4 +657,9 @@ raise Exception("DID NOT RAISE") def test_kwargs_last(self): - py.test.raises(SyntaxError, "int(base=10, '2')") + py.test.raises(SyntaxError, self.simple_test, "int(base=10, '2')", + None, None) + + def test_crap_after_starargs(self): + source = "call(*args, *args)" + py.test.raises(SyntaxError, self.simple_test, source, None, None) Modified: pypy/trunk/pypy/interpreter/pyparser/asthelper.py ============================================================================== --- pypy/trunk/pypy/interpreter/pyparser/asthelper.py (original) +++ pypy/trunk/pypy/interpreter/pyparser/asthelper.py Wed Jan 28 16:31:32 2009 @@ -68,6 +68,21 @@ if not isinstance(cur_token, TokenObject): index += 1 if not building_kw: + # this logic states that it'll be triggered once we built a kw + # already and 1. we're at then end -or- + # next token is a comma + if kw_built: + if index == l: + raise SyntaxError("non-keyword arg after keyword arg", + cur_token.lineno, 0) + token = tokens[index] + if (isinstance(token, TokenObject) and + token.name == builder.parser.tokens['COMMA']): + raise SyntaxError("non-keyword arg after keyword arg", + cur_token.lineno, 0) + + # XXX where to get col num? + arguments.append(cur_token) else: last_token = arguments.pop() From fijal at codespeak.net Wed Jan 28 17:26:36 2009 From: fijal at codespeak.net (fijal at codespeak.net) Date: Wed, 28 Jan 2009 17:26:36 +0100 (CET) Subject: [pypy-svn] r61426 - in pypy/trunk/pypy/interpreter: astcompiler/test pyparser Message-ID: <20090128162636.0A8D6169E27@codespeak.net> Author: fijal Date: Wed Jan 28 17:26:33 2009 New Revision: 61426 Modified: pypy/trunk/pypy/interpreter/astcompiler/test/test_compiler.py pypy/trunk/pypy/interpreter/pyparser/asthelper.py Log: never ever use assert in interpreter source where it might not be true. Modified: pypy/trunk/pypy/interpreter/astcompiler/test/test_compiler.py ============================================================================== --- pypy/trunk/pypy/interpreter/astcompiler/test/test_compiler.py (original) +++ pypy/trunk/pypy/interpreter/astcompiler/test/test_compiler.py Wed Jan 28 17:26:33 2009 @@ -663,3 +663,7 @@ def test_crap_after_starargs(self): source = "call(*args, *args)" py.test.raises(SyntaxError, self.simple_test, source, None, None) + + def test_not_a_name(self): + source = "call(a, b, c, 3=3)" + py.test.raises(SyntaxError, self.simple_test, source, None, None) Modified: pypy/trunk/pypy/interpreter/pyparser/asthelper.py ============================================================================== --- pypy/trunk/pypy/interpreter/pyparser/asthelper.py (original) +++ pypy/trunk/pypy/interpreter/pyparser/asthelper.py Wed Jan 28 17:26:33 2009 @@ -86,7 +86,9 @@ arguments.append(cur_token) else: last_token = arguments.pop() - assert isinstance(last_token, ast.Name) # used by rtyper + if not isinstance(last_token, ast.Name): + raise SyntaxError("invalid syntax", last_token.lineno, + 0) arguments.append(ast.Keyword(last_token.varname, cur_token, last_token.lineno)) building_kw = False kw_built = True From fijal at codespeak.net Wed Jan 28 17:46:25 2009 From: fijal at codespeak.net (fijal at codespeak.net) Date: Wed, 28 Jan 2009 17:46:25 +0100 (CET) Subject: [pypy-svn] r61427 - pypy/trunk/lib-python/modified-2.5.2/test Message-ID: <20090128164625.CB380169E4D@codespeak.net> Author: fijal Date: Wed Jan 28 17:46:24 2009 New Revision: 61427 Added: pypy/trunk/lib-python/modified-2.5.2/test/test_syntax.py - copied, changed from r61425, pypy/trunk/lib-python/2.5.2/test/test_syntax.py Log: a go at test_syntax. it passes, besides some doctests. some are real and some are obscure Copied: pypy/trunk/lib-python/modified-2.5.2/test/test_syntax.py (from r61425, pypy/trunk/lib-python/2.5.2/test/test_syntax.py) ============================================================================== --- pypy/trunk/lib-python/2.5.2/test/test_syntax.py (original) +++ pypy/trunk/lib-python/modified-2.5.2/test/test_syntax.py Wed Jan 28 17:46:24 2009 @@ -3,9 +3,9 @@ Here's an example of the sort of thing that is tested. >>> def f(x): -... global x +... global x # doctest: +ELLIPSIS Traceback (most recent call last): -SyntaxError: name 'x' is local and global +SyntaxError: name 'x' is ... global... The tests are all raise SyntaxErrors. They were created by checking each C call that raises SyntaxError. There are several modules that @@ -29,23 +29,23 @@ TODO(jhylton): "assignment to None" is inconsistent with other messages ->>> obj.None = 1 +>>> obj.None = 1 # doctest: +ELLIPSIS Traceback (most recent call last): -SyntaxError: assignment to None (, line 1) +SyntaxError: assignment to None ...(, line 1) ->>> None = 1 +>>> None = 1 # doctest: +ELLIPSIS Traceback (most recent call last): -SyntaxError: assignment to None (, line 1) +SyntaxError: assignment to None ...(, line 1) It's a syntax error to assign to the empty tuple. Why isn't it an error to assign to the empty list? It will always raise some error at runtime. ->>> () = 1 +>>> () = 1 # doctest: +ELLIPSIS Traceback (most recent call last): -SyntaxError: can't assign to () (, line 1) +SyntaxError: can't assign to ... (, line 1) ->>> f() = 1 +>>> f() = 1 # doctest: +ELLIPSIS Traceback (most recent call last): SyntaxError: can't assign to function call (, line 1) From antocuni at codespeak.net Wed Jan 28 18:18:53 2009 From: antocuni at codespeak.net (antocuni at codespeak.net) Date: Wed, 28 Jan 2009 18:18:53 +0100 (CET) Subject: [pypy-svn] r61428 - pypy/trunk/pypy/module/_lsprof/test Message-ID: <20090128171853.4BF1A169E7D@codespeak.net> Author: antocuni Date: Wed Jan 28 18:18:52 2009 New Revision: 61428 Modified: pypy/trunk/pypy/module/_lsprof/test/test_cprofile.py Log: this test finally passes (but it takes ages). However, the same test under pypy-c py.test -A fails, so there must be something wrong in the some fast path, more investigation needed. Modified: pypy/trunk/pypy/module/_lsprof/test/test_cprofile.py ============================================================================== --- pypy/trunk/pypy/module/_lsprof/test/test_cprofile.py (original) +++ pypy/trunk/pypy/module/_lsprof/test/test_cprofile.py Wed Jan 28 18:18:52 2009 @@ -5,21 +5,12 @@ class PyPyOutput: nfunc = 127 nprim = 107 - optional_line = '\n 1 0.000 0.000 0.000 0.000 ?:1()' - hasattr = "{hasattr function}" - disable = "{method 'disable' of 'Profile' objects}" - range = "{range function}" - exc_info = "{sys.exc_info function}" - + optional_line = '\n.*().*' class CPythonOutput: nfunc = 126 nprim = 106 optional_line = '' - hasattr = "{hasattr}" - disable = "{method 'disable' of '_lsprof.Profiler' objects}" - range = "{range}" - exc_info = "{sys.exc_info}" class AppTestCProfile(object): @@ -117,6 +108,7 @@ # have __file__ at app-level here sys.path.insert(0, os.path.dirname(self.file)) try: + import re from cProfile import Profile from profilee import testfunc, timer @@ -144,22 +136,19 @@ got = res[i + 1] expected = self.expected_output[method] expected = expected % self.output - if got != expected: - print method, 'differs:' - print '---------- GOT: ----------' - print got - print '---------- EXPECTED: ----------' - print expected - print '----------' - for line1, line2 in zip(got.splitlines(), - expected.splitlines()): - if line1 != line2: - print 'Difference is here:' - print ' GOT:', line1.rstrip('\n') - print 'EXPECTED:', line2.rstrip('\n') - break - assert 0 - #assert res[i + 1] == self.expected_output[method] + expected = expected.splitlines() + lines = got.splitlines() + for pattern, string in zip(expected, lines): + pattern = pattern.replace('(', '\\(') + pattern = pattern.replace(')', '\\)') + pattern = pattern.replace('?', '\\?') + if not re.match(pattern, string): + print method, 'differs:' + print 'Difference is here:' + print ' GOT:', pattern.rstrip('\n') + print 'EXPECTED:', string.rstrip('\n') + assert False + assert len(expected) == len(lines) finally: sys.path.pop(0) @@ -180,71 +169,72 @@ 2 0.000 0.000 0.140 0.070 profilee.py:84(helper2_indirect) 8 0.312 0.039 0.400 0.050 profilee.py:88(helper2) 8 0.064 0.008 0.080 0.010 profilee.py:98(subhelper) - 12 0.000 0.000 0.012 0.001 %(hasattr)s + 12 0.000 0.000 0.012 0.001 {hasattr.*} 4 0.000 0.000 0.000 0.000 {method 'append' of 'list' objects} - 1 0.000 0.000 0.000 0.000 %(disable)s - 8 0.000 0.000 0.000 0.000 %(range)s - 4 0.000 0.000 0.000 0.000 %(exc_info)s + 1 0.000 0.000 0.000 0.000 {method 'disable' of '.*' objects} + 8 0.000 0.000 0.000 0.000 {range.*} + 4 0.000 0.000 0.000 0.000 {sys.exc_info.*} """ + expected_output['print_callers'] = """\ Ordered by: standard name -Function was called by... - ncalls tottime cumtime -:1() <- -profilee.py:110(__getattr__) <- 16 0.016 0.016 profilee.py:98(subhelper) - 12 0.012 0.012 {hasattr} -profilee.py:25(testfunc) <- 1 0.270 1.000 :1() -profilee.py:35(factorial) <- 1 0.014 0.130 profilee.py:25(testfunc) - 20/3 0.130 0.147 profilee.py:35(factorial) - 2 0.006 0.040 profilee.py:84(helper2_indirect) -profilee.py:48(mul) <- 20 0.020 0.020 profilee.py:35(factorial) -profilee.py:55(helper) <- 2 0.040 0.600 profilee.py:25(testfunc) -profilee.py:73(helper1) <- 4 0.116 0.120 profilee.py:55(helper) -profilee.py:84(helper2_indirect) <- 2 0.000 0.140 profilee.py:55(helper) -profilee.py:88(helper2) <- 6 0.234 0.300 profilee.py:55(helper) - 2 0.078 0.100 profilee.py:84(helper2_indirect) -profilee.py:98(subhelper) <- 8 0.064 0.080 profilee.py:88(helper2) -{hasattr} <- 4 0.000 0.004 profilee.py:73(helper1) - 8 0.000 0.008 profilee.py:88(helper2) -{method 'append' of 'list' objects} <- 4 0.000 0.000 profilee.py:73(helper1) -{method 'disable' of '_lsprof.Profiler' objects} <- -{range} <- 8 0.000 0.000 profilee.py:98(subhelper) -{sys.exc_info} <- 4 0.000 0.000 profilee.py:73(helper1) +Function * was called by... + * ncalls tottime cumtime +:1() * <-%(optional_line)s +profilee.py:110(__getattr__) * <- 16 0.016 0.016 profilee.py:98(subhelper) + * 12 0.012 0.012 {hasattr.*} +profilee.py:25(testfunc) * <- 1 0.270 1.000 :1() +profilee.py:35(factorial) * <- 1 0.014 0.130 profilee.py:25(testfunc) + * 20/3 0.130 0.147 profilee.py:35(factorial) + * 2 0.006 0.040 profilee.py:84(helper2_indirect) +profilee.py:48(mul) * <- 20 0.020 0.020 profilee.py:35(factorial) +profilee.py:55(helper) * <- 2 0.040 0.600 profilee.py:25(testfunc) +profilee.py:73(helper1) * <- 4 0.116 0.120 profilee.py:55(helper) +profilee.py:84(helper2_indirect) * <- 2 0.000 0.140 profilee.py:55(helper) +profilee.py:88(helper2) * <- 6 0.234 0.300 profilee.py:55(helper) + * 2 0.078 0.100 profilee.py:84(helper2_indirect) +profilee.py:98(subhelper) * <- 8 0.064 0.080 profilee.py:88(helper2) +{hasattr.*} * <- 4 0.000 0.004 profilee.py:73(helper1) + * 8 0.000 0.008 profilee.py:88(helper2) +{method 'append' .*} * <- 4 0.000 0.000 profilee.py:73(helper1) +{method 'disable' .*} * <- +{range.*} * <- 8 0.000 0.000 profilee.py:98(subhelper) +{sys.exc_info.*} * <- 4 0.000 0.000 profilee.py:73(helper1) """ expected_output['print_callees'] = """\ Ordered by: standard name -Function called... - ncalls tottime cumtime -:1() -> 1 0.270 1.000 profilee.py:25(testfunc) -profilee.py:110(__getattr__) -> -profilee.py:25(testfunc) -> 1 0.014 0.130 profilee.py:35(factorial) - 2 0.040 0.600 profilee.py:55(helper) -profilee.py:35(factorial) -> 20/3 0.130 0.147 profilee.py:35(factorial) - 20 0.020 0.020 profilee.py:48(mul) -profilee.py:48(mul) -> -profilee.py:55(helper) -> 4 0.116 0.120 profilee.py:73(helper1) - 2 0.000 0.140 profilee.py:84(helper2_indirect) - 6 0.234 0.300 profilee.py:88(helper2) -profilee.py:73(helper1) -> 4 0.000 0.004 {hasattr} - 4 0.000 0.000 {method 'append' of 'list' objects} - 4 0.000 0.000 {sys.exc_info} -profilee.py:84(helper2_indirect) -> 2 0.006 0.040 profilee.py:35(factorial) - 2 0.078 0.100 profilee.py:88(helper2) -profilee.py:88(helper2) -> 8 0.064 0.080 profilee.py:98(subhelper) - 8 0.000 0.008 {hasattr} -profilee.py:98(subhelper) -> 16 0.016 0.016 profilee.py:110(__getattr__) - 8 0.000 0.000 {range} -{hasattr} -> 12 0.012 0.012 profilee.py:110(__getattr__) -{method 'append' of 'list' objects} -> -{method 'disable' of '_lsprof.Profiler' objects} -> -{range} -> -{sys.exc_info} -> +Function * called... + * ncalls tottime cumtime +:1() * -> 1 0.270 1.000 profilee.py:25(testfunc)%(optional_line)s +profilee.py:110(__getattr__) * -> +profilee.py:25(testfunc) * -> 1 0.014 0.130 profilee.py:35(factorial) + * 2 0.040 0.600 profilee.py:55(helper) +profilee.py:35(factorial) * -> 20/3 0.130 0.147 profilee.py:35(factorial) + * 20 0.020 0.020 profilee.py:48(mul) +profilee.py:48(mul) * -> +profilee.py:55(helper) * -> 4 0.116 0.120 profilee.py:73(helper1) + * 2 0.000 0.140 profilee.py:84(helper2_indirect) + * 6 0.234 0.300 profilee.py:88(helper2) +profilee.py:73(helper1) * -> 4 0.000 0.004 {hasattr.*} + * 4 0.000 0.000 {method 'append' of 'list' objects} + * 4 0.000 0.000 {sys.exc_info.*} +profilee.py:84(helper2_indirect) * -> 2 0.006 0.040 profilee.py:35(factorial) + * 2 0.078 0.100 profilee.py:88(helper2) +profilee.py:88(helper2) * -> 8 0.064 0.080 profilee.py:98(subhelper) + * 8 0.000 0.008 {hasattr.*} +profilee.py:98(subhelper) * -> 16 0.016 0.016 profilee.py:110(__getattr__) + * 8 0.000 0.000 {range.*} +{hasattr.*} * -> 12 0.012 0.012 profilee.py:110(__getattr__) +{method 'append' .*} * -> +{method 'disable' .*} * -> +{range.*} * -> +{sys.exc_info.*} * -> """ From fijal at codespeak.net Wed Jan 28 18:31:06 2009 From: fijal at codespeak.net (fijal at codespeak.net) Date: Wed, 28 Jan 2009 18:31:06 +0100 (CET) Subject: [pypy-svn] r61429 - pypy/trunk/pypy/module/_lsprof/test Message-ID: <20090128173106.2F166169E45@codespeak.net> Author: fijal Date: Wed Jan 28 18:31:03 2009 New Revision: 61429 Modified: pypy/trunk/pypy/module/_lsprof/test/test_cprofile.py Log: a magic trick how this test can take less Modified: pypy/trunk/pypy/module/_lsprof/test/test_cprofile.py ============================================================================== --- pypy/trunk/pypy/module/_lsprof/test/test_cprofile.py (original) +++ pypy/trunk/pypy/module/_lsprof/test/test_cprofile.py Wed Jan 28 18:31:03 2009 @@ -12,6 +12,16 @@ nprim = 106 optional_line = '' +def match(pattern, string): + import re + if not re.match(pattern, string): + print method, 'differs:' + print 'Difference is here:' + print ' GOT:', pattern.rstrip('\n') + print 'EXPECTED:', string.rstrip('\n') + return False + return True + class AppTestCProfile(object): def setup_class(cls): @@ -24,6 +34,7 @@ else: output = PyPyOutput.__dict__ cls.w_output = space.wrap(output) + cls.w_match = space.wrap(match) def test_direct(self): import _lsprof @@ -142,11 +153,7 @@ pattern = pattern.replace('(', '\\(') pattern = pattern.replace(')', '\\)') pattern = pattern.replace('?', '\\?') - if not re.match(pattern, string): - print method, 'differs:' - print 'Difference is here:' - print ' GOT:', pattern.rstrip('\n') - print 'EXPECTED:', string.rstrip('\n') + if not self.match(pattern, string): assert False assert len(expected) == len(lines) finally: From fijall at gmail.com Wed Jan 28 18:30:02 2009 From: fijall at gmail.com (Maciej Fijalkowski) Date: Wed, 28 Jan 2009 18:30:02 +0100 Subject: [pypy-svn] r61428 - pypy/trunk/pypy/module/_lsprof/test In-Reply-To: <20090128171853.4BF1A169E7D@codespeak.net> References: <20090128171853.4BF1A169E7D@codespeak.net> Message-ID: <693bc9ab0901280930q5b2d01cdyeee29caf93ac2da9@mail.gmail.com> > this test finally passes (but it takes ages). However, the same test under > pypy-c py.test -A fails, so there must be something wrong in the some fast > path, more investigation needed. works for me (pypy-c py.test -A) From fijal at codespeak.net Wed Jan 28 18:44:18 2009 From: fijal at codespeak.net (fijal at codespeak.net) Date: Wed, 28 Jan 2009 18:44:18 +0100 (CET) Subject: [pypy-svn] r61430 - in pypy/trunk/pypy/interpreter/astcompiler: . test Message-ID: <20090128174418.AF700169E49@codespeak.net> Author: fijal Date: Wed Jan 28 18:44:18 2009 New Revision: 61430 Modified: pypy/trunk/pypy/interpreter/astcompiler/pycodegen.py pypy/trunk/pypy/interpreter/astcompiler/test/test_compiler.py Log: why o why we do crash instead of nicely reporting SyntaxError to user? Modified: pypy/trunk/pypy/interpreter/astcompiler/pycodegen.py ============================================================================== --- pypy/trunk/pypy/interpreter/astcompiler/pycodegen.py (original) +++ pypy/trunk/pypy/interpreter/astcompiler/pycodegen.py Wed Jan 28 18:44:18 2009 @@ -1526,8 +1526,9 @@ self.main = main_visitor def default(self, node): - raise pyassem.InternalCompilerError("shouldn't arrive here!") - + raise SyntaxError("illegal expression for augmented assignment", + node.lineno) + def visitName(self, node ): self.main.loadName(node.varname, node.lineno) Modified: pypy/trunk/pypy/interpreter/astcompiler/test/test_compiler.py ============================================================================== --- pypy/trunk/pypy/interpreter/astcompiler/test/test_compiler.py (original) +++ pypy/trunk/pypy/interpreter/astcompiler/test/test_compiler.py Wed Jan 28 18:44:18 2009 @@ -667,3 +667,9 @@ def test_not_a_name(self): source = "call(a, b, c, 3=3)" py.test.raises(SyntaxError, self.simple_test, source, None, None) + + def test_assignment_to_call_func(self): + source = "call(a, b, c) = 3" + py.test.raises(SyntaxError, self.simple_test, source, None, None) + + From afa at codespeak.net Wed Jan 28 20:14:14 2009 From: afa at codespeak.net (afa at codespeak.net) Date: Wed, 28 Jan 2009 20:14:14 +0100 (CET) Subject: [pypy-svn] r61432 - in pypy/trunk/pypy/module/posix: . test Message-ID: <20090128191414.85FF9168510@codespeak.net> Author: afa Date: Wed Jan 28 20:14:12 2009 New Revision: 61432 Modified: pypy/trunk/pypy/module/posix/__init__.py pypy/trunk/pypy/module/posix/app_posix.py pypy/trunk/pypy/module/posix/interp_posix.py pypy/trunk/pypy/module/posix/test/test_posix2.py Log: Implement os.stat_float_times, and fill the stat_result structure accordingly. (No test for it in CPython test suite...) Now test_posix2.py::test_some_posix_basic_operation() passes on Windows: st[7] used to be a float; now it's always an int, like CPython. The test was wrong on Linux too, but it seems that all returned times are whole numbers. Note: I tried to reuse the existing interp_posix.State class, but translation failed, probably because State has a _freeze_() method. Modified: pypy/trunk/pypy/module/posix/__init__.py ============================================================================== --- pypy/trunk/pypy/module/posix/__init__.py (original) +++ pypy/trunk/pypy/module/posix/__init__.py Wed Jan 28 20:14:12 2009 @@ -32,6 +32,7 @@ 'fstat' : 'interp_posix.fstat', 'stat' : 'interp_posix.stat', 'lstat' : 'interp_posix.lstat', + 'stat_float_times' : 'interp_posix.stat_float_times', 'dup' : 'interp_posix.dup', 'dup2' : 'interp_posix.dup2', 'access' : 'interp_posix.access', Modified: pypy/trunk/pypy/module/posix/app_posix.py ============================================================================== --- pypy/trunk/pypy/module/posix/app_posix.py (original) +++ pypy/trunk/pypy/module/posix/app_posix.py Wed Jan 28 20:14:12 2009 @@ -28,18 +28,18 @@ st_size = structseqfield(6, "total size, in bytes") # NOTE: float times are disabled for now, for compatibility with CPython. - # access to indices 7 to 9 gives the timestamps as integers: - #_integer_atime = structseqfield(7) - #_integer_mtime = structseqfield(8) - #_integer_ctime = structseqfield(9) - - st_atime = structseqfield(7, "time of last access") - st_mtime = structseqfield(8, "time of last modification") - st_ctime = structseqfield(9, "time of last status change") + _integer_atime = structseqfield(7) + _integer_mtime = structseqfield(8) + _integer_ctime = structseqfield(9) # further fields, not accessible by index (the numbers are still needed # but not visible because they are no longer consecutive) + + st_atime = structseqfield(15, "time of last access") + st_mtime = structseqfield(16, "time of last modification") + st_ctime = structseqfield(17, "time of last status change") + if "st_blksize" in posix._statfields: st_blksize = structseqfield(20, "blocksize for filesystem I/O") if "st_blocks" in posix._statfields: Modified: pypy/trunk/pypy/module/posix/interp_posix.py ============================================================================== --- pypy/trunk/pypy/module/posix/interp_posix.py (original) +++ pypy/trunk/pypy/module/posix/interp_posix.py Wed Jan 28 20:14:12 2009 @@ -1,4 +1,4 @@ -from pypy.interpreter.baseobjspace import ObjSpace, W_Root +from pypy.interpreter.gateway import ObjSpace, W_Root, NoneNotWrapped from pypy.rlib import rposix from pypy.rlib.rarithmetic import r_longlong from pypy.rlib.unroll import unrolling_iterable @@ -99,21 +99,32 @@ FIELDS = STAT_FIELDS # also when not translating at all lst = [None] * ll_os_stat.N_INDEXABLE_FIELDS w_keywords = space.newdict() + stat_float_times = space.fromcache(StatState).stat_float_times for i, (name, TYPE) in FIELDS: value = getattr(st, name) - #if name in ('st_atime', 'st_mtime', 'st_ctime'): - # value = int(value) # rounded to an integer for indexed access + if name in ('st_atime', 'st_mtime', 'st_ctime'): + value = int(value) # rounded to an integer for indexed access w_value = space.wrap(value) if i < ll_os_stat.N_INDEXABLE_FIELDS: lst[i] = w_value else: space.setitem(w_keywords, space.wrap(name), w_value) - # NOTE: float times are disabled for now, for compatibility with CPython # non-rounded values for name-based access - #space.setitem(w_keywords, space.wrap('st_atime'), space.wrap(st.st_atime)) - #space.setitem(w_keywords, space.wrap('st_mtime'), space.wrap(st.st_mtime)) - #space.setitem(w_keywords, space.wrap('st_ctime'), space.wrap(st.st_ctime)) + if stat_float_times: + space.setitem(w_keywords, + space.wrap('st_atime'), space.wrap(st.st_atime)) + space.setitem(w_keywords, + space.wrap('st_mtime'), space.wrap(st.st_mtime)) + space.setitem(w_keywords, + space.wrap('st_ctime'), space.wrap(st.st_ctime)) + else: + space.setitem(w_keywords, + space.wrap('st_atime'), space.wrap(int(st.st_atime))) + space.setitem(w_keywords, + space.wrap('st_mtime'), space.wrap(int(st.st_mtime))) + space.setitem(w_keywords, + space.wrap('st_ctime'), space.wrap(int(st.st_ctime))) w_tuple = space.newtuple(lst) w_stat_result = space.getattr(space.getbuiltinmodule(os.name), @@ -164,6 +175,26 @@ return build_stat_result(space, st) lstat.unwrap_spec = [ObjSpace, str] +class StatState(object): + def __init__(self, space): + self.stat_float_times = True + +def stat_float_times(space, w_value=NoneNotWrapped): + """stat_float_times([newval]) -> oldval + +Determine whether os.[lf]stat represents time stamps as float objects. +If newval is True, future calls to stat() return floats, if it is False, +future calls return ints. +If newval is omitted, return the current setting. +""" + state = space.fromcache(StatState) + + if w_value is None: + return space.wrap(state.stat_float_times) + else: + state.stat_float_times = space.bool_w(w_value) +stat_float_times.unwrap_spec = [ObjSpace, W_Root] + def dup(space, fd): """Create a copy of the file descriptor. Return the new file descriptor.""" Modified: pypy/trunk/pypy/module/posix/test/test_posix2.py ============================================================================== --- pypy/trunk/pypy/module/posix/test/test_posix2.py (original) +++ pypy/trunk/pypy/module/posix/test/test_posix2.py Wed Jan 28 20:14:12 2009 @@ -100,6 +100,24 @@ if sys.platform.startswith('linux2'): assert hasattr(st, 'st_rdev') + def test_stat_float_times(self): + path = self.path + posix = self.posix + current = posix.stat_float_times() + assert current is True + try: + posix.stat_float_times(True) + st = posix.stat(path) + assert isinstance(st.st_mtime, float) + assert st[7] == int(st.st_atime) + + posix.stat_float_times(False) + st = posix.stat(path) + assert isinstance(st.st_mtime, (int, long)) + assert st[7] == st.st_atime + finally: + posix.stat_float_times(current) + def test_pickle(self): import pickle, os st = self.posix.stat(os.curdir) From fijal at codespeak.net Wed Jan 28 22:55:36 2009 From: fijal at codespeak.net (fijal at codespeak.net) Date: Wed, 28 Jan 2009 22:55:36 +0100 (CET) Subject: [pypy-svn] r61434 - in pypy/trunk/pypy/interpreter/astcompiler: . test Message-ID: <20090128215536.014C3168502@codespeak.net> Author: fijal Date: Wed Jan 28 22:55:35 2009 New Revision: 61434 Modified: pypy/trunk/pypy/interpreter/astcompiler/pycodegen.py pypy/trunk/pypy/interpreter/astcompiler/test/test_compiler.py Log: a test and a fix for bytecode corruption Modified: pypy/trunk/pypy/interpreter/astcompiler/pycodegen.py ============================================================================== --- pypy/trunk/pypy/interpreter/astcompiler/pycodegen.py (original) +++ pypy/trunk/pypy/interpreter/astcompiler/pycodegen.py Wed Jan 28 22:55:35 2009 @@ -429,7 +429,10 @@ self.nextBlock(after) def visitBreak(self, node): - if len(self.setups) == 0: + # compute setups + setups = [s for s in self.setups if + (s[0] != EXCEPT and s[0] != TRY_FINALLY)] + if len(setups) == 0: raise SyntaxError( "'break' outside loop", node.lineno) self.set_lineno(node) self.emit('BREAK_LOOP') Modified: pypy/trunk/pypy/interpreter/astcompiler/test/test_compiler.py ============================================================================== --- pypy/trunk/pypy/interpreter/astcompiler/test/test_compiler.py (original) +++ pypy/trunk/pypy/interpreter/astcompiler/test/test_compiler.py Wed Jan 28 22:55:35 2009 @@ -672,4 +672,11 @@ source = "call(a, b, c) = 3" py.test.raises(SyntaxError, self.simple_test, source, None, None) - + def test_broken_setups(self): + source = """if 1: + try: + break + finally: + pass + """ + py.test.raises(SyntaxError, self.simple_test, source, None, None) From fijal at codespeak.net Thu Jan 29 00:08:59 2009 From: fijal at codespeak.net (fijal at codespeak.net) Date: Thu, 29 Jan 2009 00:08:59 +0100 (CET) Subject: [pypy-svn] r61436 - in pypy/trunk/pypy/interpreter/astcompiler: . test Message-ID: <20090128230859.061791684F6@codespeak.net> Author: fijal Date: Thu Jan 29 00:08:59 2009 New Revision: 61436 Modified: pypy/trunk/pypy/interpreter/astcompiler/pycodegen.py pypy/trunk/pypy/interpreter/astcompiler/test/test_compiler.py Log: provide a line number Modified: pypy/trunk/pypy/interpreter/astcompiler/pycodegen.py ============================================================================== --- pypy/trunk/pypy/interpreter/astcompiler/pycodegen.py (original) +++ pypy/trunk/pypy/interpreter/astcompiler/pycodegen.py Thu Jan 29 00:08:59 2009 @@ -984,7 +984,8 @@ def _visitAssSequence(self, node, op='UNPACK_SEQUENCE'): if not node.nodes: - raise SyntaxError('Cannot assign to empty sequence') + raise SyntaxError('Cannot assign to empty sequence', + node.lineno) if findOp(node) != OP_DELETE: self.emitop_int(op, len(node.nodes)) for child in node.nodes: Modified: pypy/trunk/pypy/interpreter/astcompiler/test/test_compiler.py ============================================================================== --- pypy/trunk/pypy/interpreter/astcompiler/test/test_compiler.py (original) +++ pypy/trunk/pypy/interpreter/astcompiler/test/test_compiler.py Thu Jan 29 00:08:59 2009 @@ -680,3 +680,5 @@ pass """ py.test.raises(SyntaxError, self.simple_test, source, None, None) + + From fijal at codespeak.net Thu Jan 29 00:09:20 2009 From: fijal at codespeak.net (fijal at codespeak.net) Date: Thu, 29 Jan 2009 00:09:20 +0100 (CET) Subject: [pypy-svn] r61437 - pypy/trunk/lib-python/modified-2.5.2/test Message-ID: <20090128230920.C5B371684F6@codespeak.net> Author: fijal Date: Thu Jan 29 00:09:20 2009 New Revision: 61437 Modified: pypy/trunk/lib-python/modified-2.5.2/test/test_syntax.py Log: a test_syntax that we'll hopefully pass. doctests suck Modified: pypy/trunk/lib-python/modified-2.5.2/test/test_syntax.py ============================================================================== --- pypy/trunk/lib-python/modified-2.5.2/test/test_syntax.py (original) +++ pypy/trunk/lib-python/modified-2.5.2/test/test_syntax.py Thu Jan 29 00:09:20 2009 @@ -43,7 +43,7 @@ >>> () = 1 # doctest: +ELLIPSIS Traceback (most recent call last): -SyntaxError: can't assign to ... (, line 1) +SyntaxError: ... (, line 1) >>> f() = 1 # doctest: +ELLIPSIS Traceback (most recent call last): @@ -53,49 +53,49 @@ Traceback (most recent call last): SyntaxError: can't delete function call (, line 1) ->>> a + 1 = 2 +>>> a + 1 = 2 # doctest: +ELLIPSIS Traceback (most recent call last): -SyntaxError: can't assign to operator (, line 1) +SyntaxError: can't assign to ... (, line 1) ->>> (x for x in x) = 1 +>>> (x for x in x) = 1 # doctest: +ELLIPSIS Traceback (most recent call last): -SyntaxError: can't assign to generator expression (, line 1) +SyntaxError: ... (, line 1) ->>> 1 = 1 +>>> 1 = 1 # doctest: +ELLIPSIS Traceback (most recent call last): -SyntaxError: can't assign to literal (, line 1) +SyntaxError: can't assign ... (, line 1) ->>> "abc" = 1 +>>> "abc" = 1 # doctest: +ELLIPSIS Traceback (most recent call last): -SyntaxError: can't assign to literal (, line 1) +SyntaxError: can't assign to ... (, line 1) ->>> `1` = 1 +>>> `1` = 1 # doctest: +ELLIPSIS Traceback (most recent call last): -SyntaxError: can't assign to repr (, line 1) +SyntaxError: can't assign to ... (, line 1) If the left-hand side of an assignment is a list or tuple, an illegal expression inside that contain should still cause a syntax error. This test just checks a couple of cases rather than enumerating all of them. ->>> (a, "b", c) = (1, 2, 3) +>>> (a, "b", c) = (1, 2, 3) # doctest: +ELLIPSIS Traceback (most recent call last): -SyntaxError: can't assign to literal (, line 1) +SyntaxError: can't assign to ... (, line 1) ->>> [a, b, c + 1] = [1, 2, 3] +>>> [a, b, c + 1] = [1, 2, 3] # doctest: +ELLIPSIS Traceback (most recent call last): -SyntaxError: can't assign to operator (, line 1) +SyntaxError: can't assign to ... (, line 1) ->>> a if 1 else b = 1 +>>> a if 1 else b = 1 # doctest: +ELLIPSIS Traceback (most recent call last): -SyntaxError: can't assign to conditional expression (, line 1) +SyntaxError: can't assign ... (, line 1) From compiler_complex_args(): >>> def f(None=1): -... pass +... pass # doctest: +ELLIPSIS Traceback (most recent call last): -SyntaxError: assignment to None (, line 1) +SyntaxError: assignment to None... (, line 1) From ast_for_arguments(): @@ -106,27 +106,27 @@ SyntaxError: non-default argument follows default argument (, line 1) >>> def f(x, None): -... pass +... pass # doctest: +ELLIPSIS Traceback (most recent call last): -SyntaxError: assignment to None (, line 1) +SyntaxError: assignment to None... (, line 1) >>> def f(*None): -... pass +... pass # doctest: +ELLIPSIS Traceback (most recent call last): -SyntaxError: assignment to None (, line 1) +SyntaxError: assignment to None... (, line 1) >>> def f(**None): -... pass +... pass # doctest: +ELLIPSIS Traceback (most recent call last): -SyntaxError: assignment to None (, line 1) +SyntaxError: assignment to None... (, line 1) From ast_for_funcdef(): >>> def None(x): -... pass +... pass # doctest: +ELLIPSIS Traceback (most recent call last): -SyntaxError: assignment to None (, line 1) +SyntaxError: assignment to None... (, line 1) From ast_for_call(): @@ -136,105 +136,41 @@ >>> L = range(10) >>> f(x for x in L) [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] ->>> f(x for x in L, 1) +>>> f(x for x in L, 1) # doctest: +ELLIPSIS Traceback (most recent call last): -SyntaxError: Generator expression must be parenthesized if not sole argument (, line 1) +SyntaxError: ... (, line 1) >>> f((x for x in L), 1) [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] ->>> f(i0, i1, i2, i3, i4, i5, i6, i7, i8, i9, i10, i11, -... i12, i13, i14, i15, i16, i17, i18, i19, i20, i21, i22, -... i23, i24, i25, i26, i27, i28, i29, i30, i31, i32, i33, -... i34, i35, i36, i37, i38, i39, i40, i41, i42, i43, i44, -... i45, i46, i47, i48, i49, i50, i51, i52, i53, i54, i55, -... i56, i57, i58, i59, i60, i61, i62, i63, i64, i65, i66, -... i67, i68, i69, i70, i71, i72, i73, i74, i75, i76, i77, -... i78, i79, i80, i81, i82, i83, i84, i85, i86, i87, i88, -... i89, i90, i91, i92, i93, i94, i95, i96, i97, i98, i99, -... i100, i101, i102, i103, i104, i105, i106, i107, i108, -... i109, i110, i111, i112, i113, i114, i115, i116, i117, -... i118, i119, i120, i121, i122, i123, i124, i125, i126, -... i127, i128, i129, i130, i131, i132, i133, i134, i135, -... i136, i137, i138, i139, i140, i141, i142, i143, i144, -... i145, i146, i147, i148, i149, i150, i151, i152, i153, -... i154, i155, i156, i157, i158, i159, i160, i161, i162, -... i163, i164, i165, i166, i167, i168, i169, i170, i171, -... i172, i173, i174, i175, i176, i177, i178, i179, i180, -... i181, i182, i183, i184, i185, i186, i187, i188, i189, -... i190, i191, i192, i193, i194, i195, i196, i197, i198, -... i199, i200, i201, i202, i203, i204, i205, i206, i207, -... i208, i209, i210, i211, i212, i213, i214, i215, i216, -... i217, i218, i219, i220, i221, i222, i223, i224, i225, -... i226, i227, i228, i229, i230, i231, i232, i233, i234, -... i235, i236, i237, i238, i239, i240, i241, i242, i243, -... i244, i245, i246, i247, i248, i249, i250, i251, i252, -... i253, i254, i255) -Traceback (most recent call last): -SyntaxError: more than 255 arguments (, line 1) - -The actual error cases counts positional arguments, keyword arguments, -and generator expression arguments separately. This test combines the -three. - ->>> f(i0, i1, i2, i3, i4, i5, i6, i7, i8, i9, i10, i11, -... i12, i13, i14, i15, i16, i17, i18, i19, i20, i21, i22, -... i23, i24, i25, i26, i27, i28, i29, i30, i31, i32, i33, -... i34, i35, i36, i37, i38, i39, i40, i41, i42, i43, i44, -... i45, i46, i47, i48, i49, i50, i51, i52, i53, i54, i55, -... i56, i57, i58, i59, i60, i61, i62, i63, i64, i65, i66, -... i67, i68, i69, i70, i71, i72, i73, i74, i75, i76, i77, -... i78, i79, i80, i81, i82, i83, i84, i85, i86, i87, i88, -... i89, i90, i91, i92, i93, i94, i95, i96, i97, i98, i99, -... i100, i101, i102, i103, i104, i105, i106, i107, i108, -... i109, i110, i111, i112, i113, i114, i115, i116, i117, -... i118, i119, i120, i121, i122, i123, i124, i125, i126, -... i127, i128, i129, i130, i131, i132, i133, i134, i135, -... i136, i137, i138, i139, i140, i141, i142, i143, i144, -... i145, i146, i147, i148, i149, i150, i151, i152, i153, -... i154, i155, i156, i157, i158, i159, i160, i161, i162, -... i163, i164, i165, i166, i167, i168, i169, i170, i171, -... i172, i173, i174, i175, i176, i177, i178, i179, i180, -... i181, i182, i183, i184, i185, i186, i187, i188, i189, -... i190, i191, i192, i193, i194, i195, i196, i197, i198, -... i199, i200, i201, i202, i203, i204, i205, i206, i207, -... i208, i209, i210, i211, i212, i213, i214, i215, i216, -... i217, i218, i219, i220, i221, i222, i223, i224, i225, -... i226, i227, i228, i229, i230, i231, i232, i233, i234, -... i235, i236, i237, i238, i239, i240, i241, i242, i243, -... (x for x in i244), i245, i246, i247, i248, i249, i250, i251, -... i252=1, i253=1, i254=1, i255=1) +>>> f(lambda x: x[0] = 3) # doctest: +ELLIPSIS Traceback (most recent call last): -SyntaxError: more than 255 arguments (, line 1) - ->>> f(lambda x: x[0] = 3) -Traceback (most recent call last): -SyntaxError: lambda cannot contain assignment (, line 1) +SyntaxError: ... (, line 1) The grammar accepts any test (basically, any expression) in the keyword slot of a call site. Test a few different options. ->>> f(x()=2) +>>> f(x()=2) # doctest: +ELLIPSIS Traceback (most recent call last): -SyntaxError: keyword can't be an expression (, line 1) ->>> f(a or b=1) +SyntaxError: ... (, line 1) +>>> f(a or b=1) # doctest: +ELLIPSIS Traceback (most recent call last): -SyntaxError: keyword can't be an expression (, line 1) ->>> f(x.y=1) +SyntaxError: ... (, line 1) +>>> f(x.y=1) # doctest: +ELLIPSIS Traceback (most recent call last): -SyntaxError: keyword can't be an expression (, line 1) +SyntaxError: ... (, line 1) From ast_for_expr_stmt(): ->>> (x for x in x) += 1 +>>> (x for x in x) += 1 # doctest: +ELLIPSIS Traceback (most recent call last): -SyntaxError: augmented assignment to generator expression not possible (, line 1) ->>> None += 1 +SyntaxError: augmented assign...generator expression not possible (, line 1) +>>> None += 1 # doctest: +ELLIPSIS Traceback (most recent call last): -SyntaxError: assignment to None (, line 1) +SyntaxError: assignment to None... (, line 1) >>> f() += 1 Traceback (most recent call last): -SyntaxError: illegal expression for augmented assignment (, line 1) +SyntaxError: illegal expression for augmented assignment (, line 1) Test continue in finally in weird combinations. @@ -262,7 +198,7 @@ ... Traceback (most recent call last): ... - SyntaxError: 'continue' not supported inside 'finally' clause (, line 6) + SyntaxError: 'continue' not supported inside 'finally' clause (, line 6) This is essentially a continue in a finally which should not be allowed. @@ -277,7 +213,7 @@ ... pass Traceback (most recent call last): ... - SyntaxError: 'continue' not supported inside 'finally' clause (, line 7) + SyntaxError: 'continue' not supported inside 'finally' clause (, line 7) >>> def foo(): ... try: @@ -286,7 +222,7 @@ ... continue Traceback (most recent call last): ... - SyntaxError: 'continue' not supported inside 'finally' clause (, line 5) + SyntaxError: 'continue' not supported inside 'finally' clause (, line 5) >>> def foo(): ... for a in (): @@ -294,7 +230,7 @@ ... finally: continue Traceback (most recent call last): ... - SyntaxError: 'continue' not supported inside 'finally' clause (, line 4) + SyntaxError: 'continue' not supported inside 'finally' clause (, line 4) >>> def foo(): ... for a in (): @@ -305,7 +241,7 @@ ... finally: pass Traceback (most recent call last): ... - SyntaxError: 'continue' not supported inside 'finally' clause (, line 6) + SyntaxError: 'continue' not supported inside 'finally' clause (, line 6) >>> def foo(): ... for a in (): @@ -317,7 +253,7 @@ ... continue Traceback (most recent call last): ... - SyntaxError: 'continue' not supported inside 'finally' clause (, line 8) + SyntaxError: 'continue' not supported inside 'finally' clause (, line 8) There is one test for a break that is not in a loop. The compiler uses a single data structure to keep track of try-finally and loops, @@ -332,37 +268,7 @@ ... print 3 Traceback (most recent call last): ... - SyntaxError: 'break' outside loop (, line 3) - -This should probably raise a better error than a SystemError (or none at all). -In 2.5 there was a missing exception and an assert was triggered in a debug -build. The number of blocks must be greater than CO_MAXBLOCKS. SF #1565514 - - >>> while 1: - ... while 2: - ... while 3: - ... while 4: - ... while 5: - ... while 6: - ... while 8: - ... while 9: - ... while 10: - ... while 11: - ... while 12: - ... while 13: - ... while 14: - ... while 15: - ... while 16: - ... while 17: - ... while 18: - ... while 19: - ... while 20: - ... while 21: - ... while 22: - ... break - Traceback (most recent call last): - ... - SystemError: too many statically nested blocks + SyntaxError: 'break' outside loop (, line 3) This tests assignment-context; there was a bug in Python 2.5 where compiling a complex 'if' (one with 'elif') would fail to notice an invalid suite, @@ -374,7 +280,7 @@ ... pass Traceback (most recent call last): ... - SyntaxError: can't assign to function call (, line 2) + SyntaxError: can't assign to function call (, line 2) >>> if 1: ... pass @@ -382,7 +288,7 @@ ... x() = 1 Traceback (most recent call last): ... - SyntaxError: can't assign to function call (, line 4) + SyntaxError: can't assign to function call (, line 4) >>> if 1: ... x() = 1 @@ -392,7 +298,7 @@ ... pass Traceback (most recent call last): ... - SyntaxError: can't assign to function call (, line 2) + SyntaxError: can't assign to function call (, line 2) >>> if 1: ... pass @@ -402,7 +308,7 @@ ... pass Traceback (most recent call last): ... - SyntaxError: can't assign to function call (, line 4) + SyntaxError: can't assign to function call (, line 4) >>> if 1: ... pass @@ -412,7 +318,7 @@ ... x() = 1 Traceback (most recent call last): ... - SyntaxError: can't assign to function call (, line 6) + SyntaxError: can't assign to function call (, line 6) """ From afa at codespeak.net Thu Jan 29 00:48:17 2009 From: afa at codespeak.net (afa at codespeak.net) Date: Thu, 29 Jan 2009 00:48:17 +0100 (CET) Subject: [pypy-svn] r61438 - pypy/trunk/pypy/rlib Message-ID: <20090128234817.501E51684F2@codespeak.net> Author: afa Date: Thu Jan 29 00:48:15 2009 New Revision: 61438 Modified: pypy/trunk/pypy/rlib/rposix.py pypy/trunk/pypy/rlib/streamio.py Log: Implement streamio.truncate for windows. this fixes at least test.test_file. Modified: pypy/trunk/pypy/rlib/rposix.py ============================================================================== --- pypy/trunk/pypy/rlib/rposix.py (original) +++ pypy/trunk/pypy/rlib/rposix.py Thu Jan 29 00:48:15 2009 @@ -1,4 +1,4 @@ -import os +import os, sys from pypy.rpython.lltypesystem.rffi import CConstant, CExternVariable, INT from pypy.rpython.lltypesystem import lltype, ll2ctypes, rffi from pypy.translator.tool.cbuild import ExternalCompilationInfo @@ -42,3 +42,24 @@ os.close(fd) except OSError: pass + +# An implementation of ftruncate for Windows +if sys.platform == 'win32': + from pypy.rlib import rwin32 + + eci = ExternalCompilationInfo() + _get_osfhandle = rffi.llexternal('_get_osfhandle', [rffi.INT], rffi.LONG, + compilation_info=eci) + SetEndOfFile = rffi.llexternal('SetEndOfFile', [rffi.LONG], rwin32.BOOL, + compilation_info=eci) + + def ftruncate(fd, size): + # move to the position to be truncated + os.lseek(fd, size, 0) + # Truncate. Note that this may grow the file! + handle = _get_osfhandle(fd) + if handle == -1: + raise IOError(get_errno(), "Invalid file handle") + if not SetEndOfFile(handle): + raise IOError("Could not truncate file") + return size Modified: pypy/trunk/pypy/rlib/streamio.py ============================================================================== --- pypy/trunk/pypy/rlib/streamio.py (original) +++ pypy/trunk/pypy/rlib/streamio.py Thu Jan 29 00:48:15 2009 @@ -253,7 +253,8 @@ if sys.platform == "win32": def truncate(self, size): - raise NotImplementedError + from pypy.rlib.rposix import ftruncate + ftruncate(self.fd, size) else: def truncate(self, size): os.ftruncate(self.fd, size) From afa at codespeak.net Thu Jan 29 01:30:42 2009 From: afa at codespeak.net (afa at codespeak.net) Date: Thu, 29 Jan 2009 01:30:42 +0100 (CET) Subject: [pypy-svn] r61439 - pypy/trunk/pypy/lib Message-ID: <20090129003042.7A5CE168514@codespeak.net> Author: afa Date: Thu Jan 29 01:30:38 2009 New Revision: 61439 Modified: pypy/trunk/pypy/lib/_exceptions.py Log: Implement WindowsError attributes Modified: pypy/trunk/pypy/lib/_exceptions.py ============================================================================== --- pypy/trunk/pypy/lib/_exceptions.py (original) +++ pypy/trunk/pypy/lib/_exceptions.py Thu Jan 29 01:30:38 2009 @@ -221,7 +221,37 @@ WindowsError class WindowsError(OSError): """MS-Windows OS system call failed.""" -except NameError:pass + def __init__(self, *args): + OSError.__init__(self, *args) + # Set errno to the POSIX errno, and winerror to the Win32 + # error code. + self.winerror = self.errno + self.errno = self._winerror_to_errno.get(self.errno, + 22) # EINVAL + + def __str__(self): + if self.filename is not None: + return "[Error %s] %s: %s" % (self.winerror, + self.strerror, + self.filename) + if self.errno and self.strerror: + return "[Error %s] %s" % (self.winerror, self.strerror) + return StandardError.__str__(self) + + # copied from CPython: PC/errmap.h + _winerror_to_errno = { + 2: 2, 3: 2, 4: 24, 5: 13, 6: 9, 7: 12, 8: 12, 9: 12, 10: 7, 11: 8, + 15: 2, 16: 13, 17: 18, 18: 2, 19: 13, 20: 13, 21: 13, 22: 13, + 23: 13, 24: 13, 25: 13, 26: 13, 27: 13, 28: 13, 29: 13, 30: 13, + 31: 13, 32: 13, 33: 13, 34: 13, 35: 13, 36: 13, 53: 2, 65: 13, + 67: 2, 80: 17, 82: 13, 83: 13, 89: 11, 108: 13, 109: 32, 112: 28, + 114: 9, 128: 10, 129: 10, 130: 9, 132: 13, 145: 41, 158: 13, + 161: 2, 164: 11, 167: 13, 183: 17, 188: 8, 189: 8, 190: 8, 191: 8, + 192: 8, 193: 8, 194: 8, 195: 8, 196: 8, 197: 8, 198: 8, 199: 8, + 200: 8, 201: 8, 202: 8, 206: 2, 215: 11, 1816: 12, + } +except NameError: + pass class DeprecationWarning(Warning): """Base class for warnings about deprecated features.""" From antocuni at codespeak.net Thu Jan 29 10:05:55 2009 From: antocuni at codespeak.net (antocuni at codespeak.net) Date: Thu, 29 Jan 2009 10:05:55 +0100 (CET) Subject: [pypy-svn] r61440 - pypy/trunk/pypy/module/_lsprof/test Message-ID: <20090129090555.6080B168515@codespeak.net> Author: antocuni Date: Thu Jan 29 10:05:54 2009 New Revision: 61440 Modified: pypy/trunk/pypy/module/_lsprof/test/test_cprofile.py Log: fix Modified: pypy/trunk/pypy/module/_lsprof/test/test_cprofile.py ============================================================================== --- pypy/trunk/pypy/module/_lsprof/test/test_cprofile.py (original) +++ pypy/trunk/pypy/module/_lsprof/test/test_cprofile.py Thu Jan 29 10:05:54 2009 @@ -12,7 +12,7 @@ nprim = 106 optional_line = '' -def match(pattern, string): +def match(method, pattern, string): import re if not re.match(pattern, string): print method, 'differs:' @@ -153,7 +153,7 @@ pattern = pattern.replace('(', '\\(') pattern = pattern.replace(')', '\\)') pattern = pattern.replace('?', '\\?') - if not self.match(pattern, string): + if not self.match(method, pattern, string): assert False assert len(expected) == len(lines) finally: From antocuni at codespeak.net Thu Jan 29 13:31:48 2009 From: antocuni at codespeak.net (antocuni at codespeak.net) Date: Thu, 29 Jan 2009 13:31:48 +0100 (CET) Subject: [pypy-svn] r61441 - pypy/trunk/pypy/module/_lsprof/test Message-ID: <20090129123148.33E701684DD@codespeak.net> Author: antocuni Date: Thu Jan 29 13:31:46 2009 New Revision: 61441 Modified: pypy/trunk/pypy/module/_lsprof/test/test_cprofile.py Log: template for a failing test Modified: pypy/trunk/pypy/module/_lsprof/test/test_cprofile.py ============================================================================== --- pypy/trunk/pypy/module/_lsprof/test/test_cprofile.py (original) +++ pypy/trunk/pypy/module/_lsprof/test/test_cprofile.py Thu Jan 29 13:31:46 2009 @@ -5,7 +5,7 @@ class PyPyOutput: nfunc = 127 nprim = 107 - optional_line = '\n.*().*' + optional_line = '\n.*' class CPythonOutput: nfunc = 126 @@ -17,15 +17,18 @@ if not re.match(pattern, string): print method, 'differs:' print 'Difference is here:' - print ' GOT:', pattern.rstrip('\n') - print 'EXPECTED:', string.rstrip('\n') + print ' GOT:', string.rstrip('\n') + print 'EXPECTED:', pattern.rstrip('\n') return False return True class AppTestCProfile(object): + objspace_options = {} + def setup_class(cls): - space = gettestobjspace(usemodules=('_lsprof',)) + space = gettestobjspace(usemodules=('_lsprof',), + **cls.objspace_options) cls.w_expected_output = space.wrap(expected_output) cls.space = space cls.w_file = space.wrap(__file__) @@ -147,18 +150,31 @@ got = res[i + 1] expected = self.expected_output[method] expected = expected % self.output - expected = expected.splitlines() + patterns = expected.splitlines() lines = got.splitlines() - for pattern, string in zip(expected, lines): + for pattern, line in zip(patterns, lines): pattern = pattern.replace('(', '\\(') pattern = pattern.replace(')', '\\)') pattern = pattern.replace('?', '\\?') - if not self.match(method, pattern, string): + if not self.match(method, pattern, line): + print '--- GOT ---' + print got + print + print '--- EXPECTED ---' + print expected assert False - assert len(expected) == len(lines) + assert len(patterns) == len(lines) finally: sys.path.pop(0) + +class AppTestOptimized(AppTestCProfile): + + objspace_options = {'objspace.std.builtinshortcut': True} + + def test_cprofile(self): + skip('fixme') + expected_output = {} expected_output['print_stats'] = """\ %(nfunc)d function calls (%(nprim)d primitive calls) in 1.000 CPU seconds From fijal at codespeak.net Thu Jan 29 13:39:28 2009 From: fijal at codespeak.net (fijal at codespeak.net) Date: Thu, 29 Jan 2009 13:39:28 +0100 (CET) Subject: [pypy-svn] r61442 - pypy/trunk/pypy/module/_lsprof/test Message-ID: <20090129123928.59BC41684DF@codespeak.net> Author: fijal Date: Thu Jan 29 13:39:27 2009 New Revision: 61442 Modified: pypy/trunk/pypy/module/_lsprof/test/test_cprofile.py Log: remove pointless test Modified: pypy/trunk/pypy/module/_lsprof/test/test_cprofile.py ============================================================================== --- pypy/trunk/pypy/module/_lsprof/test/test_cprofile.py (original) +++ pypy/trunk/pypy/module/_lsprof/test/test_cprofile.py Thu Jan 29 13:39:27 2009 @@ -167,14 +167,6 @@ finally: sys.path.pop(0) - -class AppTestOptimized(AppTestCProfile): - - objspace_options = {'objspace.std.builtinshortcut': True} - - def test_cprofile(self): - skip('fixme') - expected_output = {} expected_output['print_stats'] = """\ %(nfunc)d function calls (%(nprim)d primitive calls) in 1.000 CPU seconds From fijal at codespeak.net Thu Jan 29 13:39:37 2009 From: fijal at codespeak.net (fijal at codespeak.net) Date: Thu, 29 Jan 2009 13:39:37 +0100 (CET) Subject: [pypy-svn] r61443 - pypy/trunk/pypy/interpreter/test Message-ID: <20090129123937.2AB5F1684DF@codespeak.net> Author: fijal Date: Thu Jan 29 13:39:36 2009 New Revision: 61443 Modified: pypy/trunk/pypy/interpreter/test/test_executioncontext.py Log: a failing test Modified: pypy/trunk/pypy/interpreter/test/test_executioncontext.py ============================================================================== --- pypy/trunk/pypy/interpreter/test/test_executioncontext.py (original) +++ pypy/trunk/pypy/interpreter/test/test_executioncontext.py Thu Jan 29 13:39:36 2009 @@ -1,6 +1,6 @@ import py from pypy.interpreter import executioncontext - +from pypy.conftest import gettestobjspace class Finished(Exception): pass @@ -194,3 +194,28 @@ events = space.unwrap(w_events) assert [i[0] for i in events] == ['c_call', 'c_return', 'return', 'c_call'] assert events[0][1] == events[1][1] + + def test_tracing_range_builtinshortcut(self): + opts = {"objspace.opcodes.CALL_LIKELY_BUILTIN": True} + space = gettestobjspace(**opts) + source = """def f(profile): + import sys + sys.setprofile(profile) + range(10) + sys.setprofile(None) + """ + w_events = space.appexec([space.wrap(source)], """(source): + import sys + l = [] + def profile(frame, event, arg): + l.append((event, arg)) + d = {} + exec source in d + f = d['f'] + f(profile) + import dis + print dis.dis(f) + return l + """) + events = space.unwrap(w_events) + assert [i[0] for i in events] == ['c_call', 'c_return', 'c_call'] From fijal at codespeak.net Thu Jan 29 13:45:37 2009 From: fijal at codespeak.net (fijal at codespeak.net) Date: Thu, 29 Jan 2009 13:45:37 +0100 (CET) Subject: [pypy-svn] r61444 - pypy/trunk/pypy/objspace/std Message-ID: <20090129124537.B89601684DF@codespeak.net> Author: fijal Date: Thu Jan 29 13:45:36 2009 New Revision: 61444 Modified: pypy/trunk/pypy/objspace/std/objspace.py Log: tracing of builtin calls when invoked via CALL_LIKELY_BUILTIN. TODO: tracing of exceptions. Modified: pypy/trunk/pypy/objspace/std/objspace.py ============================================================================== --- pypy/trunk/pypy/objspace/std/objspace.py (original) +++ pypy/trunk/pypy/objspace/std/objspace.py Thu Jan 29 13:45:36 2009 @@ -158,7 +158,11 @@ def call_likely_builtin(f, w_function, nargs): if isinstance(w_function, function.Function): - return w_function.funccall_valuestack(nargs, f) + executioncontext = self.getexecutioncontext() + executioncontext.c_call_trace(f, w_function) + res = w_function.funccall_valuestack(nargs, f) + executioncontext.c_return_trace(f, w_function) + return res args = f.make_arguments(nargs) try: return f.space.call_args(w_function, args) From afa at codespeak.net Thu Jan 29 13:56:03 2009 From: afa at codespeak.net (afa at codespeak.net) Date: Thu, 29 Jan 2009 13:56:03 +0100 (CET) Subject: [pypy-svn] r61445 - in pypy/trunk/pypy/rlib: . test Message-ID: <20090129125603.1B73D1684C2@codespeak.net> Author: afa Date: Thu Jan 29 13:56:02 2009 New Revision: 61445 Modified: pypy/trunk/pypy/rlib/rarithmetic.py pypy/trunk/pypy/rlib/test/test_rarithmetic.py Log: "%F" format used to return '?.??' on windows. A test and a fix. Modified: pypy/trunk/pypy/rlib/rarithmetic.py ============================================================================== --- pypy/trunk/pypy/rlib/rarithmetic.py (original) +++ pypy/trunk/pypy/rlib/rarithmetic.py Thu Jan 29 13:56:02 2009 @@ -442,6 +442,12 @@ return fmt % (x,) def formatd_overflow(alt, prec, kind, x): + # msvcrt does not support the %F format. + # OTOH %F and %f only differ for 'inf' or 'nan' numbers + # which are already handled elsewhere + if kind == 'F': + kind = 'f' + if ((kind in 'gG' and formatd_max_length <= 10+prec) or (kind in 'fF' and formatd_max_length <= 53+prec)): raise OverflowError("formatted float is too long (precision too large?)") Modified: pypy/trunk/pypy/rlib/test/test_rarithmetic.py ============================================================================== --- pypy/trunk/pypy/rlib/test/test_rarithmetic.py (original) +++ pypy/trunk/pypy/rlib/test/test_rarithmetic.py Thu Jan 29 13:56:02 2009 @@ -323,6 +323,18 @@ res = self.ll_to_string(self.interpret(f, [10/3.0])) assert res == '3.33' + def test_formatd_overflow(self): + from pypy.translator.c.test.test_genc import compile + from pypy.rlib.rarithmetic import formatd_overflow + + def func(x): + # Test the %F format, which is not supported by + # the Microsoft's msvcrt library. + return formatd_overflow(0, 4, 'F', x) + + f = compile(func, [float]) + assert f(10/3.0) == '3.3333' + def test_parts_to_float(self): from pypy.rlib.rarithmetic import parts_to_float, break_up_float def f(x): From afa at codespeak.net Thu Jan 29 14:09:24 2009 From: afa at codespeak.net (afa at codespeak.net) Date: Thu, 29 Jan 2009 14:09:24 +0100 (CET) Subject: [pypy-svn] r61446 - in pypy/trunk/pypy/objspace/std: . test Message-ID: <20090129130924.C9F731684BF@codespeak.net> Author: afa Date: Thu Jan 29 14:09:24 2009 New Revision: 61446 Modified: pypy/trunk/pypy/objspace/std/formatting.py pypy/trunk/pypy/objspace/std/test/test_stringformat.py Log: '%f' did not make the distinction between positive and negative infinities Test and fix. Modified: pypy/trunk/pypy/objspace/std/formatting.py ============================================================================== --- pypy/trunk/pypy/objspace/std/formatting.py (original) +++ pypy/trunk/pypy/objspace/std/formatting.py Thu Jan 29 14:09:24 2009 @@ -111,7 +111,10 @@ if isnan(x): r = 'nan' elif isinf(x): - r = 'inf' + if x < 0: + r = '-inf' + else: + r = 'inf' else: prec = self.prec if prec < 0: Modified: pypy/trunk/pypy/objspace/std/test/test_stringformat.py ============================================================================== --- pypy/trunk/pypy/objspace/std/test/test_stringformat.py (original) +++ pypy/trunk/pypy/objspace/std/test/test_stringformat.py Thu Jan 29 14:09:24 2009 @@ -196,6 +196,14 @@ raises(OverflowError, f, "%.70f", 2.0) raises(OverflowError, f, "%.110g", 2.0) + def test_subnormal(self): + inf = 1e300 * 1e300 + assert "%f" % (inf,) == 'inf' + assert "%f" % (-inf,) == '-inf' + nan = inf / inf + assert "%f" % (nan,) == 'nan' + assert "%f" % (-nan,) == 'nan' + class AppTestUnicodeObject: def test_unicode_convert(self): assert isinstance("%s" % (u"x"), unicode) From antocuni at codespeak.net Thu Jan 29 14:18:15 2009 From: antocuni at codespeak.net (antocuni at codespeak.net) Date: Thu, 29 Jan 2009 14:18:15 +0100 (CET) Subject: [pypy-svn] r61447 - pypy/trunk/pypy/lib Message-ID: <20090129131815.279CC1684E0@codespeak.net> Author: antocuni Date: Thu Jan 29 14:18:14 2009 New Revision: 61447 Modified: pypy/trunk/pypy/lib/_csv.py Log: cpython makes a difference between field_size_limit() and field_size_limit(None). This fixes one test in test_csv Modified: pypy/trunk/pypy/lib/_csv.py ============================================================================== --- pypy/trunk/pypy/lib/_csv.py (original) +++ pypy/trunk/pypy/lib/_csv.py Thu Jan 29 14:18:14 2009 @@ -512,20 +512,19 @@ The \"fileobj\" argument can be any object that supports the file API.""" return Writer(*args, **kwargs) -def field_size_limit(limit=None): + +undefined = object() +def field_size_limit(limit=undefined): """Sets an upper limit on parsed fields. csv.field_size_limit([limit]) Returns old limit. If limit is not given, no new limit is set and the old limit is returned""" - if not isinstance(limit, (long, int)): - raise TypeError("limit must be an integer") - global _field_limit old_limit = _field_limit - if limit is not None: + if limit is not undefined: if not isinstance(limit, (int, long)): raise TypeError("int expected, got %s" % (limit.__class__.__name__,)) From antocuni at codespeak.net Thu Jan 29 14:22:08 2009 From: antocuni at codespeak.net (antocuni at codespeak.net) Date: Thu, 29 Jan 2009 14:22:08 +0100 (CET) Subject: [pypy-svn] r61448 - pypy/trunk/lib-python/modified-2.5.2/test Message-ID: <20090129132208.42B391684DF@codespeak.net> Author: antocuni Date: Thu Jan 29 14:22:07 2009 New Revision: 61448 Added: pypy/trunk/lib-python/modified-2.5.2/test/test_csv.py - copied, changed from r61444, pypy/trunk/lib-python/2.5.2/test/test_csv.py Log: mark this behaviour as impl detail. test_csv passes now :-) Copied: pypy/trunk/lib-python/modified-2.5.2/test/test_csv.py (from r61444, pypy/trunk/lib-python/2.5.2/test/test_csv.py) ============================================================================== --- pypy/trunk/lib-python/2.5.2/test/test_csv.py (original) +++ pypy/trunk/lib-python/modified-2.5.2/test/test_csv.py Thu Jan 29 14:22:07 2009 @@ -52,13 +52,14 @@ self.assertEqual(obj.dialect.quoting, csv.QUOTE_MINIMAL) self.assertEqual(obj.dialect.skipinitialspace, False) self.assertEqual(obj.dialect.strict, False) - # Try deleting or changing attributes (they are read-only) - self.assertRaises(TypeError, delattr, obj.dialect, 'delimiter') - self.assertRaises(TypeError, setattr, obj.dialect, 'delimiter', ':') - self.assertRaises(AttributeError, delattr, obj.dialect, 'quoting') - self.assertRaises(AttributeError, setattr, obj.dialect, - 'quoting', None) - + if test_support.check_impl_detail(): + # Try deleting or changing attributes (they are read-only) + self.assertRaises(TypeError, delattr, obj.dialect, 'delimiter') + self.assertRaises(TypeError, setattr, obj.dialect, 'delimiter', ':') + self.assertRaises(AttributeError, delattr, obj.dialect, 'quoting') + self.assertRaises(AttributeError, setattr, obj.dialect, + 'quoting', None) + def test_reader_attrs(self): self._test_default_attrs(csv.reader, []) From afa at codespeak.net Thu Jan 29 15:24:16 2009 From: afa at codespeak.net (afa at codespeak.net) Date: Thu, 29 Jan 2009 15:24:16 +0100 (CET) Subject: [pypy-svn] r61450 - pypy/trunk/pypy/module/posix/test Message-ID: <20090129142416.D950B168485@codespeak.net> Author: afa Date: Thu Jan 29 15:24:16 2009 New Revision: 61450 Modified: pypy/trunk/pypy/module/posix/test/test_posix2.py Log: Fix test in module/posix when running on top of CPython 2.4. Modified: pypy/trunk/pypy/module/posix/test/test_posix2.py ============================================================================== --- pypy/trunk/pypy/module/posix/test/test_posix2.py (original) +++ pypy/trunk/pypy/module/posix/test/test_posix2.py Thu Jan 29 15:24:16 2009 @@ -24,6 +24,11 @@ pdir.join('another_longer_file_name').write("test3") mod.pdir = pdir + # in applevel tests, os.stat uses the CPython os.stat. + # Be sure to return times with full precision + # even when running on top of CPython 2.4. + os.stat_float_times(True) + def need_sparse_files(): if sys.platform == 'darwin': py.test.skip("no sparse files on default Mac OS X file system") From fijal at codespeak.net Fri Jan 30 10:07:31 2009 From: fijal at codespeak.net (fijal at codespeak.net) Date: Fri, 30 Jan 2009 10:07:31 +0100 (CET) Subject: [pypy-svn] r61452 - pypy/trunk/pypy/module/_lsprof Message-ID: <20090130090731.9FEDA168481@codespeak.net> Author: fijal Date: Fri Jan 30 10:07:30 2009 New Revision: 61452 Modified: pypy/trunk/pypy/module/_lsprof/interp_lsprof.py Log: adapt a bit in direction of cpython Modified: pypy/trunk/pypy/module/_lsprof/interp_lsprof.py ============================================================================== --- pypy/trunk/pypy/module/_lsprof/interp_lsprof.py (original) +++ pypy/trunk/pypy/module/_lsprof/interp_lsprof.py Fri Jan 30 10:07:30 2009 @@ -174,7 +174,7 @@ module = '' else: module += '.' - return '{%s%s function}' % (module, w_arg.name) + return '{%s%s}' % (module, w_arg.name) else: return '{!!!unknown!!!}' From arigo at codespeak.net Fri Jan 30 10:19:51 2009 From: arigo at codespeak.net (arigo at codespeak.net) Date: Fri, 30 Jan 2009 10:19:51 +0100 (CET) Subject: [pypy-svn] r61453 - pypy/trunk/lib-python/modified-2.5.2/test Message-ID: <20090130091951.DF6B5168485@codespeak.net> Author: arigo Date: Fri Jan 30 10:19:50 2009 New Revision: 61453 Modified: pypy/trunk/lib-python/modified-2.5.2/test/test_traceback.py Log: Skip the remaining failure, with comments explaining why. Modified: pypy/trunk/lib-python/modified-2.5.2/test/test_traceback.py ============================================================================== --- pypy/trunk/lib-python/modified-2.5.2/test/test_traceback.py (original) +++ pypy/trunk/lib-python/modified-2.5.2/test/test_traceback.py Fri Jan 30 10:19:50 2009 @@ -1,7 +1,7 @@ """Test cases for traceback module""" import unittest -from test.test_support import run_unittest, impl_detail +from test.test_support import run_unittest, impl_detail, check_impl_detail import traceback @@ -47,8 +47,11 @@ IndentationError) self.assert_(len(err) == 4) self.assert_(err[1].strip() == "print 2") - self.assert_("^" in err[2]) - self.assert_(err[1].find("2") == err[2].find("^")) + if check_impl_detail(): + # on CPython, there is a "^" at the end of the line + # on PyPy, there is a "^" too, but at the start, more logically + self.assert_("^" in err[2]) + self.assert_(err[1].find("2") == err[2].find("^")) def test_bug737473(self): import sys, os, tempfile, time From fijal at codespeak.net Fri Jan 30 10:33:44 2009 From: fijal at codespeak.net (fijal at codespeak.net) Date: Fri, 30 Jan 2009 10:33:44 +0100 (CET) Subject: [pypy-svn] r61454 - pypy/trunk/lib-python Message-ID: <20090130093344.9A66F168486@codespeak.net> Author: fijal Date: Fri Jan 30 10:33:41 2009 New Revision: 61454 Modified: pypy/trunk/lib-python/conftest.py Log: skip test ctypes, with explanation Modified: pypy/trunk/lib-python/conftest.py ============================================================================== --- pypy/trunk/lib-python/conftest.py (original) +++ pypy/trunk/lib-python/conftest.py Fri Jan 30 10:33:41 2009 @@ -456,7 +456,11 @@ RegrTest('test_coding.py'), RegrTest('test_complex_args.py'), RegrTest('test_contextlib.py'), - RegrTest('test_ctypes.py'), + # we skip test ctypes, since we adapted it massively in order + # to test what we want to support. There are real failures, + # but it's about missing features that we don't want to support + # now + RegrTest('test_ctypes.py', skip="we have a replacement"), RegrTest('test_defaultdict.py'), RegrTest('test_email_renamed.py'), RegrTest('test_exception_variations.py'), From fijal at codespeak.net Fri Jan 30 10:46:16 2009 From: fijal at codespeak.net (fijal at codespeak.net) Date: Fri, 30 Jan 2009 10:46:16 +0100 (CET) Subject: [pypy-svn] r61455 - pypy/trunk/lib-python Message-ID: <20090130094616.DFC26168486@codespeak.net> Author: fijal Date: Fri Jan 30 10:46:16 2009 New Revision: 61455 Modified: pypy/trunk/lib-python/conftest.py Log: skip test_parser and test_compiler. Modified: pypy/trunk/lib-python/conftest.py ============================================================================== --- pypy/trunk/lib-python/conftest.py (original) +++ pypy/trunk/lib-python/conftest.py Fri Jan 30 10:46:16 2009 @@ -175,7 +175,7 @@ RegrTest('test_commands.py'), RegrTest('test_compare.py', core=True), RegrTest('test_compile.py', core=True), - RegrTest('test_compiler.py', core=False), + RegrTest('test_compiler.py', core=False, skip="slowly deprecating compiler"), RegrTest('test_complex.py', core=True), RegrTest('test_contains.py', core=True), @@ -310,7 +310,7 @@ RegrTest('test_os.py', core=True), RegrTest('test_ossaudiodev.py', skip="unsupported extension module"), - RegrTest('test_parser.py', core=True), + RegrTest('test_parser.py', skip="slowly deprecating compiler"), RegrTest('test_peepholer.py'), RegrTest('test_pep247.py'), From fijal at codespeak.net Fri Jan 30 11:08:56 2009 From: fijal at codespeak.net (fijal at codespeak.net) Date: Fri, 30 Jan 2009 11:08:56 +0100 (CET) Subject: [pypy-svn] r61456 - pypy/trunk/pypy/module/signal Message-ID: <20090130100856.9206E1684A3@codespeak.net> Author: fijal Date: Fri Jan 30 11:08:56 2009 New Revision: 61456 Modified: pypy/trunk/pypy/module/signal/__init__.py pypy/trunk/pypy/module/signal/interp_signal.py Log: implement signal.pause Modified: pypy/trunk/pypy/module/signal/__init__.py ============================================================================== --- pypy/trunk/pypy/module/signal/__init__.py (original) +++ pypy/trunk/pypy/module/signal/__init__.py Fri Jan 30 11:08:56 2009 @@ -13,6 +13,7 @@ if os.name == 'posix': interpleveldefs['alarm'] = 'interp_signal.alarm' + interpleveldefs['pause'] = 'interp_signal.pause' appleveldefs = { 'default_int_handler': 'app_signal.default_int_handler', Modified: pypy/trunk/pypy/module/signal/interp_signal.py ============================================================================== --- pypy/trunk/pypy/module/signal/interp_signal.py (original) +++ pypy/trunk/pypy/module/signal/interp_signal.py Fri Jan 30 11:08:56 2009 @@ -43,6 +43,7 @@ pypysig_set_occurred = external('pypysig_set_occurred', [lltype.Signed], lltype.Void, _nowrapper=True) c_alarm = external('alarm', [rffi.INT], rffi.INT) +c_pause = external('pause', [], rffi.INT) class SignalActionFlag(AbstractActionFlag): @@ -156,6 +157,11 @@ return space.wrap(c_alarm(timeout)) alarm.unwrap_spec = [ObjSpace, int] +def pause(space): + c_pause() + return space.w_None +pause.unwrap_spec = [ObjSpace] + def check_signum(space, signum): if signum < 1 or signum >= NSIG: raise OperationError(space.w_ValueError, From fijal at codespeak.net Fri Jan 30 11:37:38 2009 From: fijal at codespeak.net (fijal at codespeak.net) Date: Fri, 30 Jan 2009 11:37:38 +0100 (CET) Subject: [pypy-svn] r61457 - pypy/trunk/lib-python/modified-2.5.2/test Message-ID: <20090130103738.73EC71684A3@codespeak.net> Author: fijal Date: Fri Jan 30 11:37:36 2009 New Revision: 61457 Added: pypy/trunk/lib-python/modified-2.5.2/test/test_subprocess.py - copied, changed from r61434, pypy/trunk/lib-python/2.5.2/test/test_subprocess.py Log: I think it's safe to say that having os.fpathconf is a bit of implementation detail. Copied: pypy/trunk/lib-python/modified-2.5.2/test/test_subprocess.py (from r61434, pypy/trunk/lib-python/2.5.2/test/test_subprocess.py) ============================================================================== --- pypy/trunk/lib-python/2.5.2/test/test_subprocess.py (original) +++ pypy/trunk/lib-python/modified-2.5.2/test/test_subprocess.py Fri Jan 30 11:37:36 2009 @@ -312,6 +312,7 @@ self.assertEqual(stdout, None) self.assertEqual(stderr, None) + @test_support.impl_detail("os.fpathconf") def test_communicate_pipe_buf(self): # communicate() with writes larger than pipe_buf # This test will probably deadlock rather than fail, if From fijal at codespeak.net Fri Jan 30 14:56:16 2009 From: fijal at codespeak.net (fijal at codespeak.net) Date: Fri, 30 Jan 2009 14:56:16 +0100 (CET) Subject: [pypy-svn] r61459 - pypy/trunk/pypy/rpython/module Message-ID: <20090130135616.3F30D1684AA@codespeak.net> Author: fijal Date: Fri Jan 30 14:56:15 2009 New Revision: 61459 Modified: pypy/trunk/pypy/rpython/module/ll_os.py Log: Damn, it was lying in my wc (WildChild) a patch for someBSD Modified: pypy/trunk/pypy/rpython/module/ll_os.py ============================================================================== --- pypy/trunk/pypy/rpython/module/ll_os.py (original) +++ pypy/trunk/pypy/rpython/module/ll_os.py Fri Jan 30 14:56:15 2009 @@ -522,7 +522,20 @@ @registering_if(os, 'setpgrp') def register_os_setpgrp(self): - return self.extdef_for_os_function_returning_int('setpgrp') + name = 'setpgrp' + if sys.platform.startswith('freebsd'): + c_func = self.llexternal(name, [rffi.INT, rffi.INT], rffi.INT) + def c_func_llimpl(): + res = rffi.cast(rffi.LONG, c_func(0, 0)) + if res == -1: + raise OSError(rposix.get_errno(), "%s failed" % name) + + c_func_llimpl.func_name = name + '_llimpl' + + return extdef([], None, llimpl=c_func_llimpl, + export_name='ll_os.ll_os_' + name) + else: + return self.extdef_for_os_function_returning_int(name) @registering_if(os, 'getppid') def register_os_getppid(self): From arigo at codespeak.net Fri Jan 30 16:02:10 2009 From: arigo at codespeak.net (arigo at codespeak.net) Date: Fri, 30 Jan 2009 16:02:10 +0100 (CET) Subject: [pypy-svn] r61460 - in pypy/trunk/pypy: interpreter module/_file module/signal/test Message-ID: <20090130150210.94B6B1684DB@codespeak.net> Author: arigo Date: Fri Jan 30 16:02:07 2009 New Revision: 61460 Modified: pypy/trunk/pypy/interpreter/pyopcode.py pypy/trunk/pypy/module/_file/interp_stream.py pypy/trunk/pypy/module/signal/test/test_signal.py Log: issue137 in-progress Add a hack to handle signals interrupting external function calls. This might take care of some more cases, as shown by the new test. What to do about the remaining cases is obscure (fijal, can you be more specific in your comments?) Modified: pypy/trunk/pypy/interpreter/pyopcode.py ============================================================================== --- pypy/trunk/pypy/interpreter/pyopcode.py (original) +++ pypy/trunk/pypy/interpreter/pyopcode.py Fri Jan 30 16:02:07 2009 @@ -128,6 +128,22 @@ def handle_operation_error(self, ec, operr, attach_tb=True): if attach_tb: + if not we_are_jitted(): + # xxx this is a hack. It allows bytecode_trace() to + # call a signal handler which raises, and catch the + # raised exception immediately. See test_alarm_raise in + # pypy/module/signal/test/test_signal.py. Without the + # next four lines, if an external call (like + # socket.accept()) is interrupted by a signal, it raises + # an exception carrying EINTR which arrives here, + # entering the next "except" block -- but the signal + # handler is then called on the next call to + # dispatch_bytecode(), causing the real exception to be + # raised after the exception handler block was popped. + try: + ec.bytecode_trace(self) + except OperationError, operr: + pass pytraceback.record_application_traceback( self.space, operr, self, self.last_instr) if not we_are_jitted(): Modified: pypy/trunk/pypy/module/_file/interp_stream.py ============================================================================== --- pypy/trunk/pypy/module/_file/interp_stream.py (original) +++ pypy/trunk/pypy/module/_file/interp_stream.py Fri Jan 30 16:02:07 2009 @@ -1,7 +1,6 @@ import py from pypy.rlib import streamio from pypy.rlib.streamio import StreamErrors -from errno import EINTR from pypy.interpreter.error import OperationError from pypy.interpreter.gateway import ObjSpace Modified: pypy/trunk/pypy/module/signal/test/test_signal.py ============================================================================== --- pypy/trunk/pypy/module/signal/test/test_signal.py (original) +++ pypy/trunk/pypy/module/signal/test/test_signal.py Fri Jan 30 16:02:07 2009 @@ -135,3 +135,34 @@ assert l == [42] finally: signal(SIGALRM, SIG_DFL) + + +class AppTestSignalSocket: + + def setup_class(cls): + space = gettestobjspace(usemodules=['signal', '_socket']) + cls.space = space + + def test_alarm_raise(self): + from signal import alarm, signal, SIG_DFL, SIGALRM + import _socket + class Alarm(Exception): + pass + def handler(*a): + raise Alarm() + + s = _socket.socket() + s.listen(1) + try: + signal(SIGALRM, handler) + alarm(1) + try: + s.accept() + except Alarm: + pass + else: + raise Exception("should have raised Alarm") + alarm(0) + finally: + signal(SIGALRM, SIG_DFL) + From arigo at codespeak.net Fri Jan 30 16:11:21 2009 From: arigo at codespeak.net (arigo at codespeak.net) Date: Fri, 30 Jan 2009 16:11:21 +0100 (CET) Subject: [pypy-svn] r61461 - pypy/trunk/pypy/interpreter Message-ID: <20090130151121.CFB02168445@codespeak.net> Author: arigo Date: Fri Jan 30 16:11:21 2009 New Revision: 61461 Modified: pypy/trunk/pypy/interpreter/pyopcode.py Log: Write equivalent (but much clearer) code. Modified: pypy/trunk/pypy/interpreter/pyopcode.py ============================================================================== --- pypy/trunk/pypy/interpreter/pyopcode.py (original) +++ pypy/trunk/pypy/interpreter/pyopcode.py Fri Jan 30 16:11:21 2009 @@ -142,8 +142,8 @@ # raised after the exception handler block was popped. try: ec.bytecode_trace(self) - except OperationError, operr: - pass + except OperationError, e: + operr = e pytraceback.record_application_traceback( self.space, operr, self, self.last_instr) if not we_are_jitted(): From antocuni at codespeak.net Fri Jan 30 17:02:15 2009 From: antocuni at codespeak.net (antocuni at codespeak.net) Date: Fri, 30 Jan 2009 17:02:15 +0100 (CET) Subject: [pypy-svn] r61462 - pypy/trunk/lib-python/modified-2.5.2/test Message-ID: <20090130160215.7C6AF1684DD@codespeak.net> Author: antocuni Date: Fri Jan 30 17:02:13 2009 New Revision: 61462 Removed: pypy/trunk/lib-python/modified-2.5.2/test/test_userstring.py Log: I don't really understand why this test was modified, as it passes neither on cpython nor pypy, while the original one passes on both. From antocuni at codespeak.net Fri Jan 30 17:27:51 2009 From: antocuni at codespeak.net (antocuni at codespeak.net) Date: Fri, 30 Jan 2009 17:27:51 +0100 (CET) Subject: [pypy-svn] r61463 - pypy/trunk/lib-python Message-ID: <20090130162751.06BA61684DD@codespeak.net> Author: antocuni Date: Fri Jan 30 17:27:51 2009 New Revision: 61463 Modified: pypy/trunk/lib-python/conftest.py Log: mark test_gc as impl detail Modified: pypy/trunk/lib-python/conftest.py ============================================================================== --- pypy/trunk/lib-python/conftest.py (original) +++ pypy/trunk/lib-python/conftest.py Fri Jan 30 17:27:51 2009 @@ -230,7 +230,7 @@ RegrTest('test_future1.py', core=True), RegrTest('test_future2.py', core=True), RegrTest('test_future3.py', core=True), - RegrTest('test_gc.py', usemodules='_weakref'), + RegrTest('test_gc.py', usemodules='_weakref', skip="implementation detail"), RegrTest('test_gdbm.py', skip="unsupported extension module"), RegrTest('test_generators.py', core=True, usemodules='thread _weakref'), RegrTest('test_genexps.py', core=True, usemodules='_weakref'), From arigo at codespeak.net Fri Jan 30 17:51:14 2009 From: arigo at codespeak.net (arigo at codespeak.net) Date: Fri, 30 Jan 2009 17:51:14 +0100 (CET) Subject: [pypy-svn] r61464 - pypy/trunk/lib-python Message-ID: <20090130165114.054E9168473@codespeak.net> Author: arigo Date: Fri Jan 30 17:51:13 2009 New Revision: 61464 Modified: pypy/trunk/lib-python/failure_list.txt Log: Passing tests. Modified: pypy/trunk/lib-python/failure_list.txt ============================================================================== --- pypy/trunk/lib-python/failure_list.txt (original) +++ pypy/trunk/lib-python/failure_list.txt Fri Jan 30 17:51:13 2009 @@ -43,8 +43,6 @@ test_thread the docs say it's ok to raise thread.error here, but maybe we need to have thread.stack_size() implemented anyway (no hurry I'd say) test_timeout skipped test test_trace probably all acceptable differences -test_traceback ! don't care about '__members__', but check the other tests -test_unicode ! some failures, look deeper test_unicode_file skipped test test_unicodedata unknown to me (but xorAxAx and fijal have a better clue) test_urllib2_localnet bogus test? From antocuni at codespeak.net Fri Jan 30 17:52:52 2009 From: antocuni at codespeak.net (antocuni at codespeak.net) Date: Fri, 30 Jan 2009 17:52:52 +0100 (CET) Subject: [pypy-svn] r61465 - pypy/pysqlite2/test Message-ID: <20090130165252.8A11D168495@codespeak.net> Author: antocuni Date: Fri Jan 30 17:52:51 2009 New Revision: 61465 Modified: pypy/pysqlite2/test/hooks.py Log: skip some tests about unsupported features Modified: pypy/pysqlite2/test/hooks.py ============================================================================== --- pypy/pysqlite2/test/hooks.py (original) +++ pypy/pysqlite2/test/hooks.py Fri Jan 30 17:52:51 2009 @@ -1,4 +1,4 @@ -#-*- coding: ISO-8859-1 -*- +#-*- coding: iso-8859-1 -*- # pysqlite2/test/hooks.py: tests for various SQLite-specific hooks # # Copyright (C) 2006-2007 Gerhard H?ring @@ -23,6 +23,7 @@ import os, unittest import pysqlite2.dbapi2 as sqlite +from test.test_support import impl_detail class CollationTests(unittest.TestCase): def setUp(self): @@ -31,6 +32,7 @@ def tearDown(self): pass + @impl_detail("unsupported feature") def CheckCreateCollationNotCallable(self): con = sqlite.connect(":memory:") try: @@ -39,6 +41,7 @@ except TypeError, e: self.failUnlessEqual(e.args[0], "parameter must be callable") + @impl_detail("unsupported feature") def CheckCreateCollationNotAscii(self): con = sqlite.connect(":memory:") try: @@ -76,6 +79,7 @@ except sqlite.OperationalError, e: self.failUnlessEqual(e.args[0].lower(), "no such collation sequence: mycoll") + @impl_detail("unsupported feature") def CheckCollationRegisterTwice(self): """ Register two different collation functions under the same name. @@ -90,6 +94,7 @@ if result[0][0] != 'b' or result[1][0] != 'a': self.fail("wrong collation function is used") + @impl_detail("unsupported feature") def CheckDeregisterCollation(self): """ Register a collation, then deregister it. Make sure an error is raised if we try @@ -106,6 +111,7 @@ self.fail("wrong OperationalError raised") class ProgressTests(unittest.TestCase): + @impl_detail("unsupported feature") def CheckProgressHandlerUsed(self): """ Test that the progress handler is invoked once it is set. @@ -121,7 +127,7 @@ """) self.failUnless(progress_calls) - + @impl_detail("unsupported feature") def CheckOpcodeCount(self): """ Test that the opcode argument is respected. @@ -145,6 +151,7 @@ second_count = len(progress_calls) self.failUnless(first_count > second_count) + @impl_detail("unsupported feature") def CheckCancelOperation(self): """ Test that returning a non-zero value stops the operation in progress. @@ -161,6 +168,7 @@ curs.execute, "create table bar (a, b)") + @impl_detail("unsupported feature") def CheckClearHandler(self): """ Test that setting the progress handler to None clears the previously set handler. From arigo at codespeak.net Fri Jan 30 18:44:35 2009 From: arigo at codespeak.net (arigo at codespeak.net) Date: Fri, 30 Jan 2009 18:44:35 +0100 (CET) Subject: [pypy-svn] r61466 - pypy/trunk/pypy/lib Message-ID: <20090130174435.E7DDB168488@codespeak.net> Author: arigo Date: Fri Jan 30 18:44:34 2009 New Revision: 61466 Modified: pypy/trunk/pypy/lib/dbm.py Log: Change the ctypes logic to try both names: 'dbm_xxx' and '__db_ndbm_xxx'. My system at least is a Linux system where the names are really 'dbm_xxx'... Modified: pypy/trunk/pypy/lib/dbm.py ============================================================================== --- pypy/trunk/pypy/lib/dbm.py (original) +++ pypy/trunk/pypy/lib/dbm.py Fri Jan 30 18:44:34 2009 @@ -2,7 +2,8 @@ import ctypes.util import os, sys -_singleton = 'one' +class _singleton(object): + pass class error(Exception): def __init__(self, msg): @@ -132,28 +133,19 @@ dat.dsize = c_int(len(key)) getattr(lib, funcs['delete'])(self._aobj, dat) -# initialization for Berkeley DB -_bdb_funcs = { - 'open': '__db_ndbm_open', - 'close': '__db_ndbm_close', - 'firstkey': '__db_ndbm_firstkey', - 'nextkey': '__db_ndbm_nextkey', - 'fetch': '__db_ndbm_fetch', - 'store': '__db_ndbm_store', - 'error': '__db_ndbm_error', - 'delete': '__db_ndbm_delete', -} - -_normal_funcs = { - 'open': 'dbm_open', - 'close': 'dbm_close', - 'firstkey': 'dbm_firstkey', - 'nextkey': 'dbm_nextkey', - 'fetch': 'dbm_fetch', - 'store': 'dbm_store', - 'error': 'dbm_error', - 'delete': 'dbm_delete', -} +### initialization: Berkeley DB versus normal DB + +def _init_func(name, argtypes=None, restype=None): + try: + func = getattr(lib, '__db_ndbm_' + name) + funcs[name] = '__db_ndbm_' + name + except AttributeError: + func = getattr(lib, 'dbm_' + name) + funcs[name] = 'dbm_' + name + if argtypes is not None: + func.argtypes = argtypes + if restype is not None: + func.restype = restype if sys.platform != 'darwin': libpath = ctypes.util.find_library('db') @@ -164,25 +156,19 @@ raise Exception("Cannot find dbm library") lib = CDLL(libpath) # Linux _platform = 'bdb' - lib.__db_ndbm_open.argtypes = [c_char_p, c_int, c_int] - lib.__db_ndbm_close.restype = c_void_p - lib.__db_ndbm_firstkey.restype = datum - lib.__db_ndbm_nextkey.restype = datum - lib.__db_ndbm_fetch.restype = datum - lib.__db_ndbm_store.restype = c_int - funcs = _bdb_funcs else: lib = CDLL("/usr/lib/libdbm.dylib") # OS X _platform = 'osx' - lib.dbm_open.argtypes = [c_char_p, c_int, c_int] - lib.dbm_close.restype = c_void_p - lib.dbm_firstkey.restype = datum - lib.dbm_nextkey.restype = datum - lib.dbm_fetch.restype = datum - lib.dbm_store.restype = c_int - funcs = _normal_funcs - +funcs = {} +_init_func('open', [c_char_p, c_int, c_int]) +_init_func('close', restype=c_void_p) +_init_func('firstkey', restype=datum) +_init_func('nextkey', restype=datum) +_init_func('fetch', restype=datum) +_init_func('store', restype=c_int) +_init_func('error') +_init_func('delete') lib.DBM_INSERT = 0 lib.DBM_REPLACE = 1 From arigo at codespeak.net Fri Jan 30 19:20:44 2009 From: arigo at codespeak.net (arigo at codespeak.net) Date: Fri, 30 Jan 2009 19:20:44 +0100 (CET) Subject: [pypy-svn] r61467 - in pypy/trunk/pypy/interpreter: . test Message-ID: <20090130182044.EA06E168527@codespeak.net> Author: arigo Date: Fri Jan 30 19:20:44 2009 New Revision: 61467 Modified: pypy/trunk/pypy/interpreter/generator.py pypy/trunk/pypy/interpreter/test/test_generator.py pypy/trunk/pypy/interpreter/typedef.py Log: Make sure gi_frame returns None when the generator is finished. Bit of a hack (ideally the internal self.frame should be set to None) but it can be done with minimal changes to the rest of the logic. Modified: pypy/trunk/pypy/interpreter/generator.py ============================================================================== --- pypy/trunk/pypy/interpreter/generator.py (original) +++ pypy/trunk/pypy/interpreter/generator.py Fri Jan 30 19:20:44 2009 @@ -111,6 +111,12 @@ msg = "generator ignored GeneratorExit" raise OperationError(space.w_RuntimeError, space.wrap(msg)) + def descr_gi_frame(space, self): + if not self.frame.frame_finished_execution: + return self.frame + else: + return space.w_None + def descr__del__(self): """ applevel __del__, which is called at a safe point after the Modified: pypy/trunk/pypy/interpreter/test/test_generator.py ============================================================================== --- pypy/trunk/pypy/interpreter/test/test_generator.py (original) +++ pypy/trunk/pypy/interpreter/test/test_generator.py Fri Jan 30 19:20:44 2009 @@ -120,6 +120,14 @@ g = f() raises(TypeError, g.throw, NameError("Error"), None, "not tb object") + def test_throw_finishes_generator(self): + def f(): + yield 1 + g = f() + assert g.gi_frame is not None + raises(ValueError, g.throw, ValueError) + assert g.gi_frame is None + def test_close(self): def f(): yield 1 Modified: pypy/trunk/pypy/interpreter/typedef.py ============================================================================== --- pypy/trunk/pypy/interpreter/typedef.py (original) +++ pypy/trunk/pypy/interpreter/typedef.py Fri Jan 30 19:20:44 2009 @@ -866,7 +866,7 @@ __del__ = interp2app(GeneratorIterator.descr__del__, descrmismatch='__del__'), gi_running = interp_attrproperty('running', cls=GeneratorIterator), - gi_frame = interp_attrproperty('frame', cls=GeneratorIterator), + gi_frame = GetSetProperty(GeneratorIterator.descr_gi_frame), __weakref__ = make_weakref_descr(GeneratorIterator), ) GeneratorIterator.typedef.acceptable_as_base_class = False From fijal at codespeak.net Sat Jan 31 12:03:44 2009 From: fijal at codespeak.net (fijal at codespeak.net) Date: Sat, 31 Jan 2009 12:03:44 +0100 (CET) Subject: [pypy-svn] r61478 - pypy/trunk/pypy/lib Message-ID: <20090131110344.0CADC168523@codespeak.net> Author: fijal Date: Sat Jan 31 12:03:43 2009 New Revision: 61478 Modified: pypy/trunk/pypy/lib/resource.py Log: fix test_resource, just because. Modified: pypy/trunk/pypy/lib/resource.py ============================================================================== --- pypy/trunk/pypy/lib/resource.py (original) +++ pypy/trunk/pypy/lib/resource.py Sat Jan 31 12:03:43 2009 @@ -4,7 +4,7 @@ from ctypes_support import standard_c_lib as libc from ctypes_support import get_errno -from ctypes import Structure, c_int, c_long, byref +from ctypes import Structure, c_int, c_long, byref, sizeof from errno import EINVAL, EPERM from ctypes_configure.configure import (configure, ExternalCompilationInfo, ConstantInteger, DefinedConstantInteger, @@ -64,6 +64,7 @@ # Configure constants and types config = configure(ResourceConfigure) rlim_t = config['rlim_t'] +sizeof_rlim_t = 1<<(sizeof(rlim_t) * 8) for key in _CONSTANTS: globals()[key] = config[key] optional_constants = [] @@ -124,6 +125,12 @@ ru_nvcsw = _structseq.structseqfield(14) ru_nivcsw = _structseq.structseqfield(15) +def rlimit_check_bounds(rlim_cur, rlim_max): + if rlim_cur > sizeof_rlim_t: + raise ValueError("%d does not fit into rlim_t" % rlim_cur) + if rlim_max > sizeof_rlim_t: + raise ValueError("%d does not fit into rlim_t" % rlim_max) + class rlimit(Structure): _fields_ = ( ("rlim_cur", rlim_t), @@ -171,6 +178,7 @@ def setrlimit(resource, rlim): if not(0 <= resource < RLIM_NLIMITS): return ValueError("invalid resource specified") + rlimit_check_bounds(*rlim) rlim = rlimit(rlim[0], rlim[1]) ret = _setrlimit(resource, byref(rlim)) From fijal at codespeak.net Sat Jan 31 12:06:14 2009 From: fijal at codespeak.net (fijal at codespeak.net) Date: Sat, 31 Jan 2009 12:06:14 +0100 (CET) Subject: [pypy-svn] r61479 - pypy/trunk/lib-python/modified-2.5.2/test Message-ID: <20090131110614.429D3168533@codespeak.net> Author: fijal Date: Sat Jan 31 12:06:13 2009 New Revision: 61479 Modified: pypy/trunk/lib-python/modified-2.5.2/test/test_sys.py Log: according to a comment in test, _current_frames is clearly an impl_detail Modified: pypy/trunk/lib-python/modified-2.5.2/test/test_sys.py ============================================================================== --- pypy/trunk/lib-python/modified-2.5.2/test/test_sys.py (original) +++ pypy/trunk/lib-python/modified-2.5.2/test/test_sys.py Sat Jan 31 12:06:13 2009 @@ -238,6 +238,7 @@ ) # sys._current_frames() is a CPython-only gimmick. + @test.test_support.impl_detail("CPython-only gimmick") def test_current_frames(self): have_threads = True try: From fijal at codespeak.net Sat Jan 31 12:33:47 2009 From: fijal at codespeak.net (fijal at codespeak.net) Date: Sat, 31 Jan 2009 12:33:47 +0100 (CET) Subject: [pypy-svn] r61481 - in pypy/branch/oo-jit/pypy/rpython: . lltypesystem Message-ID: <20090131113347.C328E168559@codespeak.net> Author: fijal Date: Sat Jan 31 12:33:47 2009 New Revision: 61481 Modified: pypy/branch/oo-jit/pypy/rpython/annlowlevel.py pypy/branch/oo-jit/pypy/rpython/lltypesystem/lloperation.py Log: port llstr from trunk Modified: pypy/branch/oo-jit/pypy/rpython/annlowlevel.py ============================================================================== --- pypy/branch/oo-jit/pypy/rpython/annlowlevel.py (original) +++ pypy/branch/oo-jit/pypy/rpython/annlowlevel.py Sat Jan 31 12:33:47 2009 @@ -463,6 +463,28 @@ return hop.genop('same_as', [v_ll_str], resulttype = hop.r_result.lowleveltype) +def llstr(s): + from pypy.rpython.lltypesystem.rstr import mallocstr + # XXX not sure what to do with ootypesystem + ll_s = mallocstr(len(s)) + for i, c in enumerate(s): + ll_s.chars[i] = c + return ll_s + +class LLStrEntry(extregistry.ExtRegistryEntry): + _about_ = llstr + + def compute_result_annotation(self, s_str): + from pypy.rpython.lltypesystem.rstr import STR + return annmodel.lltype_to_annotation(lltype.Ptr(STR)) + + def specialize_call(self, hop): + hop.exception_cannot_occur() + assert hop.args_r[0].lowleveltype == hop.r_result.lowleveltype + v_ll_str, = hop.inputargs(*hop.args_r) + return hop.genop('same_as', [v_ll_str], + resulttype = hop.r_result.lowleveltype) + # ____________________________________________________________ def cast_object_to_ptr(PTR, object): Modified: pypy/branch/oo-jit/pypy/rpython/lltypesystem/lloperation.py ============================================================================== --- pypy/branch/oo-jit/pypy/rpython/lltypesystem/lloperation.py (original) +++ pypy/branch/oo-jit/pypy/rpython/lltypesystem/lloperation.py Sat Jan 31 12:33:47 2009 @@ -381,6 +381,7 @@ 'call_boehm_gc_alloc': LLOp(canraise=(MemoryError,)), 'jit_marker': LLOp(), 'promote_virtualizable':LLOp(canrun=True), + 'can_enter_jit': LLOp(), # __________ GC operations __________ From magcius at codespeak.net Sat Jan 31 18:49:20 2009 From: magcius at codespeak.net (magcius at codespeak.net) Date: Sat, 31 Jan 2009 18:49:20 +0100 (CET) Subject: [pypy-svn] r61486 - pypy/branch/avm/pypy/translator/avm Message-ID: <20090131174920.38D89169E7E@codespeak.net> Author: magcius Date: Sat Jan 31 18:49:18 2009 New Revision: 61486 Modified: pypy/branch/avm/pypy/translator/avm/avm1.py pypy/branch/avm/pypy/translator/avm/function.py pypy/branch/avm/pypy/translator/avm/metavm.py Log: Latest port of Mecheye Fusion Modified: pypy/branch/avm/pypy/translator/avm/avm1.py ============================================================================== --- pypy/branch/avm/pypy/translator/avm/avm1.py (original) +++ pypy/branch/avm/pypy/translator/avm/avm1.py Sat Jan 31 18:49:18 2009 @@ -45,13 +45,12 @@ Undefined = object() Undefined.type = DataTypes.UNDEFINED +class ConstantIndexDescriptor(object): + def __get__(self, obj, objtype): + return DataTypes.CONSTANT8 if obj.index < 256 else DataTypes.CONSTANT16 + class Constant(Index): - def __getattr__(self, name): - if name == "type": - if self.index < 256: - return DataTypes.CONSTANT8 - return DataTypes.CONSTANT16 - return Index.__getattr__(self, name) + type = ConstantIndexDescriptor() class RegisterByIndex(Index): type = DataTypes.REGISTER @@ -541,7 +540,7 @@ def __len__(self): return 1 # 1 (Action ID) - def serialize(self) + def serialize(self): return chr(self.ACTION_ID) ActionNextFrame = ShortAction(0x04, "ActionNextFrame") Modified: pypy/branch/avm/pypy/translator/avm/function.py ============================================================================== --- pypy/branch/avm/pypy/translator/avm/function.py (original) +++ pypy/branch/avm/pypy/translator/avm/function.py Sat Jan 31 18:49:18 2009 @@ -24,10 +24,8 @@ self.ilasm.push_local(v) elif isinstance(v, flowmodel.Constant): self.db.push_const(v.concretetype, v.value, self.ilasm) - elif isinstance(v, str): + else: # Assume a primitive or special type self.ilasm.push_const(v) - else: - assert False def store(self, v): assert isinstance(v, flowmodel.Variable) Modified: pypy/branch/avm/pypy/translator/avm/metavm.py ============================================================================== --- pypy/branch/avm/pypy/translator/avm/metavm.py (original) +++ pypy/branch/avm/pypy/translator/avm/metavm.py Sat Jan 31 18:49:18 2009 @@ -49,29 +49,29 @@ def _render_builtin(self, generator, builtin, args): for func_arg in args[1:]: # push parameters - generator.load(func_arg) + generator.push(func_arg) generator.call_external(builtin, args[1:]) def _render_builtin_prepared_args(self, generator, builtin, args): for func_arg in args: - generator.load_str(func_arg) + generator.push(func_arg) generator.call_external(builtin, args) def _render_builtin_method(self, generator, builtin, args): for func_arg in args: - generator.load_special(func_arg) + generator.push(func_arg) generator.call_external_method(builtin, len(args)-1) def _render_function(self, generator, graph, args): for func_arg in args[1:]: # push parameters if func_arg.concretetype is not ootype.Void: - generator.load(func_arg) + generator.push(func_arg) generator.call_graph(graph) def _render_method(self, generator, method_name, args): this = args[0] - for arg in args: # push parametes - generator.load(arg) + for arg in args: # push parameters + generator.push(arg) generator.call_method(this.concretetype, method_name) Call = _Call()