[pypy-svn] r67358 - in pypy/branch/newtrunk/pypy: . config/test doc/jit interpreter interpreter/test lib module/__builtin__ module/__builtin__/test module/_weakref/test module/mmap/test module/posix module/sys objspace/std objspace/std/test rlib rlib/rsre rlib/rsre/test rpython/lltypesystem rpython/lltypesystem/test rpython/memory/gc rpython/test rpython/tool/test tool/test translator translator/c translator/c/test translator/cli/src translator/goal translator/jvm translator/platform translator/platform/test translator/test
pedronis at codespeak.net
pedronis at codespeak.net
Mon Aug 31 15:15:53 CEST 2009
Author: pedronis
Date: Mon Aug 31 15:15:51 2009
New Revision: 67358
Added:
pypy/branch/newtrunk/pypy/tool/test/test_license.py
- copied unchanged from r66700, pypy/trunk/pypy/tool/test/test_license.py
Modified:
pypy/branch/newtrunk/pypy/ (props changed)
pypy/branch/newtrunk/pypy/config/test/test_makerestdoc.py
pypy/branch/newtrunk/pypy/doc/jit/pyjitpl5.txt
pypy/branch/newtrunk/pypy/interpreter/generator.py
pypy/branch/newtrunk/pypy/interpreter/pyframe.py
pypy/branch/newtrunk/pypy/interpreter/test/test_objspace.py
pypy/branch/newtrunk/pypy/lib/_marshal.py
pypy/branch/newtrunk/pypy/module/__builtin__/functional.py
pypy/branch/newtrunk/pypy/module/__builtin__/test/test_classobj.py
pypy/branch/newtrunk/pypy/module/__builtin__/test/test_functional.py
pypy/branch/newtrunk/pypy/module/__builtin__/test/test_range.py
pypy/branch/newtrunk/pypy/module/_weakref/test/test_weakref.py
pypy/branch/newtrunk/pypy/module/mmap/test/test_mmap.py
pypy/branch/newtrunk/pypy/module/posix/__init__.py
pypy/branch/newtrunk/pypy/module/sys/version.py
pypy/branch/newtrunk/pypy/objspace/std/dictmultiobject.py
pypy/branch/newtrunk/pypy/objspace/std/dictobject.py
pypy/branch/newtrunk/pypy/objspace/std/test/test_dictmultiobject.py
pypy/branch/newtrunk/pypy/objspace/std/test/test_dictobject.py
pypy/branch/newtrunk/pypy/objspace/std/test/test_shadowtracking.py
pypy/branch/newtrunk/pypy/objspace/std/test/test_stringobject.py
pypy/branch/newtrunk/pypy/objspace/std/test/test_typeobject.py
pypy/branch/newtrunk/pypy/objspace/std/typeobject.py
pypy/branch/newtrunk/pypy/rlib/rarithmetic.py
pypy/branch/newtrunk/pypy/rlib/rsre/rsre.py
pypy/branch/newtrunk/pypy/rlib/rsre/test/test_rsre.py
pypy/branch/newtrunk/pypy/rlib/streamio.py
pypy/branch/newtrunk/pypy/rpython/lltypesystem/ll2ctypes.py
pypy/branch/newtrunk/pypy/rpython/lltypesystem/test/test_ll2ctypes.py
pypy/branch/newtrunk/pypy/rpython/memory/gc/semispace.py
pypy/branch/newtrunk/pypy/rpython/test/test_rfloat.py
pypy/branch/newtrunk/pypy/rpython/tool/test/test_rffi_platform.py
pypy/branch/newtrunk/pypy/translator/c/dlltool.py
pypy/branch/newtrunk/pypy/translator/c/genc.py
pypy/branch/newtrunk/pypy/translator/c/node.py
pypy/branch/newtrunk/pypy/translator/c/test/test_dlltool.py
pypy/branch/newtrunk/pypy/translator/c/test/test_genc.py
pypy/branch/newtrunk/pypy/translator/c/test/test_standalone.py
pypy/branch/newtrunk/pypy/translator/cli/src/ll_os.cs
pypy/branch/newtrunk/pypy/translator/geninterplevel.py
pypy/branch/newtrunk/pypy/translator/goal/sharedpypy.py
pypy/branch/newtrunk/pypy/translator/goal/targetpypystandalone.py
pypy/branch/newtrunk/pypy/translator/jvm/genjvm.py
pypy/branch/newtrunk/pypy/translator/platform/__init__.py
pypy/branch/newtrunk/pypy/translator/platform/darwin.py
pypy/branch/newtrunk/pypy/translator/platform/linux.py
pypy/branch/newtrunk/pypy/translator/platform/test/test_maemo.py
pypy/branch/newtrunk/pypy/translator/platform/test/test_platform.py
pypy/branch/newtrunk/pypy/translator/platform/windows.py
pypy/branch/newtrunk/pypy/translator/test/snippet.py
pypy/branch/newtrunk/pypy/translator/test/test_geninterp.py
Log:
(iko, pedronis)
wip: state before new compiler merge
Modified: pypy/branch/newtrunk/pypy/config/test/test_makerestdoc.py
==============================================================================
--- pypy/branch/newtrunk/pypy/config/test/test_makerestdoc.py (original)
+++ pypy/branch/newtrunk/pypy/config/test/test_makerestdoc.py Mon Aug 31 15:15:51 2009
@@ -5,6 +5,11 @@
tempdir = py.test.ensuretemp('config')
+try:
+ import docutils
+except ImportError:
+ py.test.skip("don't have docutils")
+
def checkrest(rest, filename):
tempfile = tempdir.join(filename)
tempfile.write(rest)
Modified: pypy/branch/newtrunk/pypy/doc/jit/pyjitpl5.txt
==============================================================================
--- pypy/branch/newtrunk/pypy/doc/jit/pyjitpl5.txt (original)
+++ pypy/branch/newtrunk/pypy/doc/jit/pyjitpl5.txt Mon Aug 31 15:15:51 2009
@@ -19,3 +19,5 @@
* http://morepypy.blogspot.com/2009/04/roadmap-for-jit.html
* http://morepypy.blogspot.com/2009/04/4-weeks-of-gdb.html
* http://morepypy.blogspot.com/2009/05/icooolps-submissions.html
+* http://morepypy.blogspot.com/2009/06/news-from-jit-front.html
+* http://morepypy.blogspot.com/2009/06/jit-progress.html
Modified: pypy/branch/newtrunk/pypy/interpreter/generator.py
==============================================================================
--- pypy/branch/newtrunk/pypy/interpreter/generator.py (original)
+++ pypy/branch/newtrunk/pypy/interpreter/generator.py Mon Aug 31 15:15:51 2009
@@ -2,6 +2,7 @@
from pypy.interpreter.baseobjspace import Wrappable
from pypy.interpreter.gateway import NoneNotWrapped
from pypy.rlib.rarithmetic import intmask
+from pypy.interpreter.pyopcode import LoopBlock
class GeneratorIterator(Wrappable):
@@ -122,8 +123,12 @@
applevel __del__, which is called at a safe point after the
interp-level __del__ enqueued the object for destruction
"""
- self.descr_close()
+ # Only bother raising an exception if the frame is still not
+ # finished and finally or except blocks are present.
+ if not self.frame.frame_finished_execution:
+ for block in self.frame.blockstack:
+ if not isinstance(block, LoopBlock):
+ self.descr_close()
def __del__(self):
- if not self.frame.frame_finished_execution:
- self._enqueue_for_destruction(self.space)
+ self._enqueue_for_destruction(self.space)
Modified: pypy/branch/newtrunk/pypy/interpreter/pyframe.py
==============================================================================
--- pypy/branch/newtrunk/pypy/interpreter/pyframe.py (original)
+++ pypy/branch/newtrunk/pypy/interpreter/pyframe.py Mon Aug 31 15:15:51 2009
@@ -23,7 +23,7 @@
"""Represents a frame for a regular Python function
that needs to be interpreted.
- See also pyopcode.PyStandardFrame and pynestedscope.PyNestedScopeFrame.
+ See also pyopcode.PyStandardFrame and nestedscope.PyNestedScopeFrame.
Public fields:
* 'space' is the object space this frame is running in
Modified: pypy/branch/newtrunk/pypy/interpreter/test/test_objspace.py
==============================================================================
--- pypy/branch/newtrunk/pypy/interpreter/test/test_objspace.py (original)
+++ pypy/branch/newtrunk/pypy/interpreter/test/test_objspace.py Mon Aug 31 15:15:51 2009
@@ -8,6 +8,10 @@
# this test isn't so much to test that the objspace interface *works*
# -- it's more to test that it's *there*
+
+INT32_MAX = 2147483648
+
+
class TestObjSpace:
def test_newlist(self):
w = self.space.wrap
@@ -154,9 +158,9 @@
res = space.r_longlong_w(w_value)
assert res == 12
assert type(res) is r_longlong
- w_value = space.wrap(r_longlong(-sys.maxint * 42))
+ w_value = space.wrap(r_longlong(-INT32_MAX * 42))
res = space.r_longlong_w(w_value)
- assert res == -sys.maxint * 42
+ assert res == -INT32_MAX * 42
assert type(res) is r_longlong
w_obj = space.wrap("hello world")
space.raises_w(space.w_TypeError, space.r_longlong_w, w_obj)
@@ -169,9 +173,9 @@
res = space.r_ulonglong_w(w_value)
assert res == 12
assert type(res) is r_ulonglong
- w_value = space.wrap(r_ulonglong(sys.maxint * 42))
+ w_value = space.wrap(r_ulonglong(INT32_MAX * 42))
res = space.r_ulonglong_w(w_value)
- assert res == sys.maxint * 42
+ assert res == INT32_MAX * 42
assert type(res) is r_ulonglong
w_obj = space.wrap("hello world")
space.raises_w(space.w_TypeError, space.r_ulonglong_w, w_obj)
Modified: pypy/branch/newtrunk/pypy/lib/_marshal.py
==============================================================================
--- pypy/branch/newtrunk/pypy/lib/_marshal.py (original)
+++ pypy/branch/newtrunk/pypy/lib/_marshal.py Mon Aug 31 15:15:51 2009
@@ -6,11 +6,6 @@
import types
from _codecs import utf_8_decode, utf_8_encode
-try:
- import new
-except ImportError:
- new = None
-
TYPE_NULL = '0'
TYPE_NONE = 'N'
TYPE_FALSE = 'F'
@@ -409,11 +404,9 @@
name = self.load()
firstlineno = self.r_long()
lnotab = self.load()
- if not new:
- raise RuntimeError, "can't unmarshal code objects; no 'new' module"
- return new.code(argcount, nlocals, stacksize, flags, code, consts,
- names, varnames, filename, name, firstlineno, lnotab,
- freevars, cellvars)
+ return types.CodeType(argcount, nlocals, stacksize, flags, code, consts,
+ names, varnames, filename, name, firstlineno,
+ lnotab, freevars, cellvars)
dispatch[TYPE_CODE] = load_code
def load_set(self):
@@ -627,11 +620,9 @@
name = self.load()
firstlineno = _r_long(self)
lnotab = self.load()
- if not new:
- raise RuntimeError, "can't unmarshal code objects; no 'new' module"
- return new.code(argcount, nlocals, stacksize, flags, code, consts,
- names, varnames, filename, name, firstlineno, lnotab,
- freevars, cellvars)
+ return types.CodeType(argcount, nlocals, stacksize, flags, code, consts,
+ names, varnames, filename, name, firstlineno,
+ lnotab, freevars, cellvars)
dispatch[TYPE_CODE] = load_code
def load_set(self):
@@ -650,17 +641,6 @@
# _________________________________________________________________
#
-# compatibility
-
-try:
- set
-except NameError:
- def set(x):
- raise ValueError("cannot unmarshal set objects on Python < 2.4")
- frozenset = set
-
-# _________________________________________________________________
-#
# user interface
version = 1
Modified: pypy/branch/newtrunk/pypy/module/__builtin__/functional.py
==============================================================================
--- pypy/branch/newtrunk/pypy/module/__builtin__/functional.py (original)
+++ pypy/branch/newtrunk/pypy/module/__builtin__/functional.py Mon Aug 31 15:15:51 2009
@@ -61,33 +61,27 @@
get a list in decending order."""
try:
- # save duplication by redirecting every error to applevel
- x = space.int_w(w_x)
+ x = space.int_w(space.int(w_x))
if space.is_w(w_y, space.w_None):
start, stop = 0, x
else:
- start, stop = x, space.int_w(w_y)
- step = space.int_w(w_step)
+ start, stop = x, space.int_w(space.int(w_y))
+ step = space.int_w(space.int(w_step))
howmany = get_len_of_range(start, stop, step)
- except OperationError, e:
- if not e.match(space, space.w_TypeError):
- pass
- else:
- raise
- except (ValueError, OverflowError):
- pass
- else:
- if (space.config.objspace.std.withmultilist or
- space.config.objspace.std.withrangelist):
- return range_withspecialized_implementation(space, start,
- step, howmany)
- res_w = [None] * howmany
- v = start
- for idx in range(howmany):
- res_w[idx] = space.wrap(v)
- v += step
- return space.newlist(res_w)
- return range_fallback(space, w_x, w_y, w_step)
+ except (ValueError, OverflowError, OperationError):
+ # save duplication by redirecting every error to applevel
+ return range_fallback(space, w_x, w_y, w_step)
+
+ if (space.config.objspace.std.withmultilist or
+ space.config.objspace.std.withrangelist):
+ return range_withspecialized_implementation(space, start,
+ step, howmany)
+ res_w = [None] * howmany
+ v = start
+ for idx in range(howmany):
+ res_w[idx] = space.wrap(v)
+ v += step
+ return space.newlist(res_w)
range_int = range
range_int.unwrap_spec = [ObjSpace, W_Root, W_Root, W_Root]
del range # don't hide the builtin one
@@ -207,7 +201,7 @@
def _toint(space, w_obj):
# trying to support float arguments, just because CPython still does
try:
- return space.int_w(w_obj)
+ return space.int_w(space.int(w_obj))
except OperationError, e:
if space.is_true(space.isinstance(w_obj, space.w_float)):
return space.int_w(space.int(w_obj))
Modified: pypy/branch/newtrunk/pypy/module/__builtin__/test/test_classobj.py
==============================================================================
--- pypy/branch/newtrunk/pypy/module/__builtin__/test/test_classobj.py (original)
+++ pypy/branch/newtrunk/pypy/module/__builtin__/test/test_classobj.py Mon Aug 31 15:15:51 2009
@@ -505,6 +505,7 @@
raises(TypeError, cmp, a, b)
def test_hash(self):
+ import sys
class A:
pass
hash(A()) # does not crash
@@ -528,11 +529,12 @@
return 1
a = A()
raises(TypeError, hash, a)
+ bigint = sys.maxint + 1
class A: # can return long
def __hash__(self):
- return long(2**31)
+ return long(bigint)
a = A()
- assert hash(a) == -2147483648
+ assert hash(a) == -bigint
def test_index(self):
import sys
Modified: pypy/branch/newtrunk/pypy/module/__builtin__/test/test_functional.py
==============================================================================
--- pypy/branch/newtrunk/pypy/module/__builtin__/test/test_functional.py (original)
+++ pypy/branch/newtrunk/pypy/module/__builtin__/test/test_functional.py Mon Aug 31 15:15:51 2009
@@ -117,6 +117,25 @@
# test again, to make sure that xrange() is not its own iterator
assert iter(x).next() == 2
+ def test_xrange_object_with___int__(self):
+ class A(object):
+ def __int__(self):
+ return 5
+
+ assert list(xrange(A())) == [0, 1, 2, 3, 4]
+ assert list(xrange(0, A())) == [0, 1, 2, 3, 4]
+ assert list(xrange(0, 10, A())) == [0, 5]
+
+ def test_xrange_float(self):
+ assert list(xrange(0.1, 2.0, 1.1)) == [0, 1]
+
+ def test_xrange_long(self):
+ import sys
+ a = long(10 * sys.maxint)
+ raises(OverflowError, xrange, a)
+ raises(OverflowError, xrange, 0, a)
+ raises(OverflowError, xrange, 0, 1, a)
+
class AppTestReversed:
def test_reversed(self):
r = reversed("hello")
Modified: pypy/branch/newtrunk/pypy/module/__builtin__/test/test_range.py
==============================================================================
--- pypy/branch/newtrunk/pypy/module/__builtin__/test/test_range.py (original)
+++ pypy/branch/newtrunk/pypy/module/__builtin__/test/test_range.py Mon Aug 31 15:15:51 2009
@@ -17,7 +17,6 @@
def test_range_negstartisstop(self):
assert range(-1, -1) == []
-
def test_range_zero(self):
assert range(0) == []
@@ -60,10 +59,34 @@
def test_range_zerostep(self):
raises(ValueError, range, 1, 5, 0)
- def DONT_test_range_float(self):
- "How CPython does it - UGLY, ignored for now."
+ def test_range_float(self):
+ "How CPython does it - UGLY."
assert range(0.1, 2.0, 1.1) == [0, 1]
def test_range_wrong_type(self):
raises(TypeError, range, "42")
+ def test_range_object_with___int__(self):
+ class A(object):
+ def __int__(self):
+ return 5
+
+ assert range(A()) == [0, 1, 2, 3, 4]
+ assert range(0, A()) == [0, 1, 2, 3, 4]
+ assert range(0, 10, A()) == [0, 5]
+
+ def test_range_long(self):
+ import sys
+ assert range(-2**100) == []
+ assert range(0, -2**100) == []
+ assert range(0, 2**100, -1) == []
+ assert range(0, 2**100, -1) == []
+
+ a = long(10 * sys.maxint)
+ b = long(100 * sys.maxint)
+ c = long(50 * sys.maxint)
+
+ assert range(a, a+2) == [a, a+1]
+ assert range(a+2, a, -1L) == [a+2, a+1]
+ assert range(a+4, a, -2) == [a+4, a+2]
+
Modified: pypy/branch/newtrunk/pypy/module/_weakref/test/test_weakref.py
==============================================================================
--- pypy/branch/newtrunk/pypy/module/_weakref/test/test_weakref.py (original)
+++ pypy/branch/newtrunk/pypy/module/_weakref/test/test_weakref.py Mon Aug 31 15:15:51 2009
@@ -231,6 +231,12 @@
del g
gc.collect()
assert w() is None
+ g = f(10)
+ w = _weakref.ref(g)
+ assert list(g) == range(10)
+ del g
+ gc.collect()
+ assert w() is None
def test_weakref_subclass_with_del(self):
import _weakref, gc
Modified: pypy/branch/newtrunk/pypy/module/mmap/test/test_mmap.py
==============================================================================
--- pypy/branch/newtrunk/pypy/module/mmap/test/test_mmap.py (original)
+++ pypy/branch/newtrunk/pypy/module/mmap/test/test_mmap.py Mon Aug 31 15:15:51 2009
@@ -42,7 +42,7 @@
raises(TypeError, mmap, 0, 1, 2, 3, 4, 5)
raises(TypeError, mmap, 0, 1, 2, 3, "foo", 5)
raises(TypeError, mmap, 0, 1, foo="foo")
- raises(TypeError, mmap, 0, -1)
+ raises((TypeError, OverflowError), mmap, 0, -1)
raises(OverflowError, mmap, 0, sys.maxint ** 3)
raises(ValueError, mmap, 0, 1, flags=2, access=3)
raises(ValueError, mmap, 0, 1, access=123)
@@ -410,7 +410,7 @@
def fn(m): m *= 1 # but it
raises((SystemError, TypeError), fn, m) # doesn't
def fn(): 1 * m # make much sense
- raises(TypeError, fn)
+ raises((SystemError, TypeError), fn)
m.close()
f.close()
#
Modified: pypy/branch/newtrunk/pypy/module/posix/__init__.py
==============================================================================
--- pypy/branch/newtrunk/pypy/module/posix/__init__.py (original)
+++ pypy/branch/newtrunk/pypy/module/posix/__init__.py Mon Aug 31 15:15:51 2009
@@ -120,6 +120,14 @@
if hasattr(os, name):
interpleveldefs[name] = 'interp_posix.' + name
+ def __init__(self, space, w_name):
+ backend = space.config.translation.backend
+ # the Win32 urandom implementation isn't going to translate on JVM or CLI
+ # so we have to remove it
+ if backend == 'cli' or backend == 'jvm':
+ del self.interpleveldefs['urandom']
+ MixedModule.__init__(self, space, w_name)
+
def startup(self, space):
from pypy.module.posix import interp_posix
interp_posix.get(space).startup(space)
Modified: pypy/branch/newtrunk/pypy/module/sys/version.py
==============================================================================
--- pypy/branch/newtrunk/pypy/module/sys/version.py (original)
+++ pypy/branch/newtrunk/pypy/module/sys/version.py Mon Aug 31 15:15:51 2009
@@ -11,9 +11,9 @@
# the last item is replaced by the svn revision ^^^
TRIM_URL_UP_TO = 'svn/pypy/'
-SVN_URL = "$HeadURL$"[10:-28]
+SVN_URL = """$HeadURL$"""[10:-28]
-REV = "$LastChangedRevision$"[22:-2]
+REV = """$LastChangedRevision$"""[22:-2]
import pypy
Modified: pypy/branch/newtrunk/pypy/objspace/std/dictmultiobject.py
==============================================================================
--- pypy/branch/newtrunk/pypy/objspace/std/dictmultiobject.py (original)
+++ pypy/branch/newtrunk/pypy/objspace/std/dictmultiobject.py Mon Aug 31 15:15:51 2009
@@ -1052,6 +1052,7 @@
w_self.implementation = SharedDictImplementation(space)
else:
w_self.implementation = space.emptydictimpl
+ w_self.space = space
def initialize_content(w_self, list_pairs_w):
impl = w_self.implementation
@@ -1059,6 +1060,11 @@
impl = impl.setitem(w_k, w_v)
w_self.implementation = impl
+ def initialize_from_strdict_shared(w_self, strdict):
+ impl = StrDictImplementation(w_self.space)
+ impl.content = strdict
+ w_self.implementation = impl
+
def __repr__(w_self):
""" representation for debugging purposes """
return "%s(%s)" % (w_self.__class__.__name__, w_self.implementation)
Modified: pypy/branch/newtrunk/pypy/objspace/std/dictobject.py
==============================================================================
--- pypy/branch/newtrunk/pypy/objspace/std/dictobject.py (original)
+++ pypy/branch/newtrunk/pypy/objspace/std/dictobject.py Mon Aug 31 15:15:51 2009
@@ -13,11 +13,18 @@
w_self.content = r_dict(space.eq_w, space.hash_w)
else:
w_self.content = w_otherdict.content.copy()
+ w_self.space = space
def initialize_content(w_self, list_pairs_w):
for w_k, w_v in list_pairs_w:
w_self.content[w_k] = w_v
+ def initialize_from_strdict_shared(w_self, strdict):
+ # XXX the stuff below is slightly broken, as the dict is not really shared
+ # this would be very very annoying to fix with non-multidicts
+ for key, w_value in strdict.items():
+ w_self.content[w_self.space.wrap(key)] = w_value
+
def __repr__(w_self):
""" representation for debugging purposes """
return "%s(%s)" % (w_self.__class__.__name__, w_self.content)
Modified: pypy/branch/newtrunk/pypy/objspace/std/test/test_dictmultiobject.py
==============================================================================
--- pypy/branch/newtrunk/pypy/objspace/std/test/test_dictmultiobject.py (original)
+++ pypy/branch/newtrunk/pypy/objspace/std/test/test_dictmultiobject.py Mon Aug 31 15:15:51 2009
@@ -12,6 +12,17 @@
def setup_class(cls):
cls.space = gettestobjspace(**{"objspace.std.withmultidict": True})
+ def test_initialize_from_strdict_really_shared(self):
+ space = self.space
+ w = space.wrap
+ d = {"a": w(1), "b": w(2)}
+ w_d = space.DictObjectCls(space)
+ w_d.initialize_from_strdict_shared(d)
+ assert self.space.eq_w(space.getitem(w_d, w("a")), w(1))
+ assert self.space.eq_w(space.getitem(w_d, w("b")), w(2))
+ d["c"] = w(41)
+ assert self.space.eq_w(space.getitem(w_d, w("c")), w(41))
+
class AppTest_DictMultiObject(test_dictobject.AppTest_DictObject):
def setup_class(cls):
cls.space = gettestobjspace(**{"objspace.std.withmultidict": True})
Modified: pypy/branch/newtrunk/pypy/objspace/std/test/test_dictobject.py
==============================================================================
--- pypy/branch/newtrunk/pypy/objspace/std/test/test_dictobject.py (original)
+++ pypy/branch/newtrunk/pypy/objspace/std/test/test_dictobject.py Mon Aug 31 15:15:51 2009
@@ -123,6 +123,16 @@
assert self.space.eq_w(space.call_function(get, w("33")), w(None))
assert self.space.eq_w(space.call_function(get, w("33"), w(44)), w(44))
+ def test_initialize_from_strdict_shared(self):
+ space = self.space
+ w = space.wrap
+ d = {"a": w(1), "b": w(2)}
+ w_d = space.DictObjectCls(space)
+ w_d.initialize_from_strdict_shared(d)
+ assert self.space.eq_w(space.getitem(w_d, w("a")), w(1))
+ assert self.space.eq_w(space.getitem(w_d, w("b")), w(2))
+
+
class AppTest_DictObject:
Modified: pypy/branch/newtrunk/pypy/objspace/std/test/test_shadowtracking.py
==============================================================================
--- pypy/branch/newtrunk/pypy/objspace/std/test/test_shadowtracking.py (original)
+++ pypy/branch/newtrunk/pypy/objspace/std/test/test_shadowtracking.py Mon Aug 31 15:15:51 2009
@@ -210,7 +210,7 @@
for name in names]
assert append_counter[0] >= 5 * len(names)
for name, count in zip(names, names_counters):
- assert count[0] >= 5
+ assert count[0] >= 5, str((name, count))
def test_mutating_bases(self):
class C(object):
Modified: pypy/branch/newtrunk/pypy/objspace/std/test/test_stringobject.py
==============================================================================
--- pypy/branch/newtrunk/pypy/objspace/std/test/test_stringobject.py (original)
+++ pypy/branch/newtrunk/pypy/objspace/std/test/test_stringobject.py Mon Aug 31 15:15:51 2009
@@ -723,6 +723,9 @@
raises(TypeError, len, iter(iterable))
def test_overflow_replace(self):
+ import sys
+ if sys.maxint > 2**31-1:
+ skip("Wrong platform")
x = "A" * (2**16)
raises(OverflowError, x.replace, '', x)
Modified: pypy/branch/newtrunk/pypy/objspace/std/test/test_typeobject.py
==============================================================================
--- pypy/branch/newtrunk/pypy/objspace/std/test/test_typeobject.py (original)
+++ pypy/branch/newtrunk/pypy/objspace/std/test/test_typeobject.py Mon Aug 31 15:15:51 2009
@@ -915,14 +915,19 @@
return 0
raises(TypeError, X)
+class AppTestWithMultidictTypes:
+ def setup_class(cls):
+ cls.space = gettestobjspace(**{"objspace.std.withmultidict": True})
+
def test_dictproxy_is_updated(self):
- skip("fix me")
class A(object):
x = 1
d = A.__dict__
assert d["x"] == 1
A.y = 2
assert d["y"] == 2
+ assert ("x", 1) in d.items()
+ assert ("y", 2) in d.items()
class AppTestMutableBuiltintypes:
Modified: pypy/branch/newtrunk/pypy/objspace/std/typeobject.py
==============================================================================
--- pypy/branch/newtrunk/pypy/objspace/std/typeobject.py (original)
+++ pypy/branch/newtrunk/pypy/objspace/std/typeobject.py Mon Aug 31 15:15:51 2009
@@ -256,14 +256,8 @@
if w_self.lazyloaders:
w_self._freeze_() # force un-lazification
space = w_self.space
- dictspec = []
- for key, w_value in w_self.dict_w.items():
- dictspec.append((space.wrap(key), w_value))
- # speed hack: instantiate a dict object cls directly
- # NB: cannot use newdict, because that could return something else
- # than an instance of DictObjectCls
newdic = space.DictObjectCls(space)
- newdic.initialize_content(dictspec)
+ newdic.initialize_from_strdict_shared(w_self.dict_w)
return W_DictProxyObject(newdic)
def unwrap(w_self, space):
Modified: pypy/branch/newtrunk/pypy/rlib/rarithmetic.py
==============================================================================
--- pypy/branch/newtrunk/pypy/rlib/rarithmetic.py (original)
+++ pypy/branch/newtrunk/pypy/rlib/rarithmetic.py Mon Aug 31 15:15:51 2009
@@ -5,7 +5,7 @@
such that before and after translation semantics are
consistent
-r_uint an unsigned integer which has not overflow
+r_uint an unsigned integer which has no overflow
checking. It is always positive and always
truncated to the internal machine word size.
intmask mask a possibly long value when running on CPython
Modified: pypy/branch/newtrunk/pypy/rlib/rsre/rsre.py
==============================================================================
--- pypy/branch/newtrunk/pypy/rlib/rsre/rsre.py (original)
+++ pypy/branch/newtrunk/pypy/rlib/rsre/rsre.py Mon Aug 31 15:15:51 2009
@@ -12,6 +12,7 @@
rsre_core_filename = rsre_core_filename[:-1]
rsre_core_filename = os.path.abspath(rsre_core_filename)
del rsre_core
+from pypy.rlib.rsre.rsre_char import getlower
def insert_sre_methods(locals, name):
"""A hack that inserts the SRE entry point methods into the 'locals'
@@ -58,3 +59,6 @@
def get_char_ord(self, p):
return ord(self.string[p])
+
+ def lower(self, char_ord):
+ return getlower(char_ord, 0)
Modified: pypy/branch/newtrunk/pypy/rlib/rsre/test/test_rsre.py
==============================================================================
--- pypy/branch/newtrunk/pypy/rlib/rsre/test/test_rsre.py (original)
+++ pypy/branch/newtrunk/pypy/rlib/rsre/test/test_rsre.py Mon Aug 31 15:15:51 2009
@@ -80,6 +80,11 @@
def test_getlower():
assert rsre_char.getlower(ord("A"), 0) == ord("a")
+def test_SimpleStringState():
+ state = SimpleStringState("A", 0, -1)
+ assert state.get_char_ord(0) == ord("A")
+ assert state.lower(state.get_char_ord(0)) == ord("a")
+
def test_get_byte_array():
if sys.byteorder == "big":
if rsre_char.CODESIZE == 2:
Modified: pypy/branch/newtrunk/pypy/rlib/streamio.py
==============================================================================
--- pypy/branch/newtrunk/pypy/rlib/streamio.py (original)
+++ pypy/branch/newtrunk/pypy/rlib/streamio.py Mon Aug 31 15:15:51 2009
@@ -176,6 +176,10 @@
compilation_info=_eci)
SetEndOfFile = rffi.llexternal('SetEndOfFile', [rffi.LONG], rwin32.BOOL,
compilation_info=_eci)
+
+ # HACK: These implementations are specific to MSVCRT and the C backend.
+ # When generating on CLI or JVM, these are patched out.
+ # See PyPyTarget.target() in targetpypystandalone.py
def _setfd_binary(fd):
_setmode(fd, os.O_BINARY)
Modified: pypy/branch/newtrunk/pypy/rpython/lltypesystem/ll2ctypes.py
==============================================================================
--- pypy/branch/newtrunk/pypy/rpython/lltypesystem/ll2ctypes.py (original)
+++ pypy/branch/newtrunk/pypy/rpython/lltypesystem/ll2ctypes.py Mon Aug 31 15:15:51 2009
@@ -19,6 +19,7 @@
from pypy.rpython.lltypesystem.rclass import OBJECT
from pypy.rpython.annlowlevel import base_ptr_lltype
from pypy.rpython import raddress
+from pypy.translator.platform import platform
def uaddressof(obj):
return fixid(ctypes.addressof(obj))
@@ -871,17 +872,16 @@
not_found = []
for libname in libraries:
libpath = None
+ ext = platform.so_ext
+ prefixes = platform.so_prefixes
for dir in eci.library_dirs:
- # xxx untested directly, what about 'lib' prefix
- if sys.platform == "win32":
- tryfile = os.path.join(dir, libname + '.dll')
- elif sys.platform == "darwin":
- tryfile = os.path.join(dir, libname + '.dylib')
- else:
- tryfile = os.path.join(dir, libname + '.so')
- if os.path.isfile(tryfile):
- libpath = tryfile
+ if libpath:
break
+ for prefix in prefixes:
+ tryfile = os.path.join(dir, prefix + libname + '.' + ext)
+ if os.path.isfile(tryfile):
+ libpath = tryfile
+ break
if not libpath:
libpath = ctypes.util.find_library(libname)
if not libpath:
@@ -890,8 +890,10 @@
libpath = libname
if libpath:
dllclass = getattr(ctypes, calling_conv + 'dll')
- # urgh, cannot pass the flag to dllclass.LoadLibrary
- clib = dllclass._dlltype(libpath, ctypes.RTLD_GLOBAL)
+ # on ie slackware there was need for RTLD_GLOBAL here.
+ # this breaks a lot of things, since passing RTLD_GLOBAL
+ # creates symbol conflicts on C level.
+ clib = dllclass.LoadLibrary(libpath)
cfunc = get_on_lib(clib, funcname)
if cfunc is not None:
break
Modified: pypy/branch/newtrunk/pypy/rpython/lltypesystem/test/test_ll2ctypes.py
==============================================================================
--- pypy/branch/newtrunk/pypy/rpython/lltypesystem/test/test_ll2ctypes.py (original)
+++ pypy/branch/newtrunk/pypy/rpython/lltypesystem/test/test_ll2ctypes.py Mon Aug 31 15:15:51 2009
@@ -15,6 +15,7 @@
from pypy.rpython.test.test_llinterp import interpret
from pypy.annotation.annrpython import RPythonAnnotator
from pypy.rpython.rtyper import RPythonTyper
+from pypy.tool.udir import udir
class TestLL2Ctypes(object):
@@ -1093,4 +1094,45 @@
assert not (ref2 != ref1)
-
+class TestPlatform(object):
+ def test_lib_on_libpaths(self):
+ from pypy.translator.platform import platform
+ from pypy.translator.tool.cbuild import ExternalCompilationInfo
+
+ tmpdir = udir.join('lib_on_libppaths')
+ tmpdir.ensure(dir=1)
+ c_file = tmpdir.join('c_file.c')
+ c_file.write('int f(int a, int b) { return (a + b); }')
+ eci = ExternalCompilationInfo(export_symbols=['f'])
+ so = platform.compile([c_file], eci, standalone=False)
+ eci = ExternalCompilationInfo(
+ libraries = ['c_file'],
+ library_dirs = [str(so.dirpath())]
+ )
+ f = rffi.llexternal('f', [rffi.INT, rffi.INT], rffi.INT,
+ compilation_info=eci)
+ assert f(3, 4) == 7
+
+ def test_prefix(self):
+
+ if sys.platform != 'linux2':
+ py.test.skip("Not supported")
+
+ from pypy.translator.platform import platform
+ from pypy.translator.tool.cbuild import ExternalCompilationInfo
+
+ tmpdir = udir.join('lib_on_libppaths_prefix')
+ tmpdir.ensure(dir=1)
+ c_file = tmpdir.join('c_file.c')
+ c_file.write('int f(int a, int b) { return (a + b); }')
+ eci = ExternalCompilationInfo()
+ so = platform.compile([c_file], eci, standalone=False)
+ sopath = py.path.local(so)
+ sopath.move(sopath.dirpath().join('libc_file.so'))
+ eci = ExternalCompilationInfo(
+ libraries = ['c_file'],
+ library_dirs = [str(so.dirpath())]
+ )
+ f = rffi.llexternal('f', [rffi.INT, rffi.INT], rffi.INT,
+ compilation_info=eci)
+ assert f(3, 4) == 7
Modified: pypy/branch/newtrunk/pypy/rpython/memory/gc/semispace.py
==============================================================================
--- pypy/branch/newtrunk/pypy/rpython/memory/gc/semispace.py (original)
+++ pypy/branch/newtrunk/pypy/rpython/memory/gc/semispace.py Mon Aug 31 15:15:51 2009
@@ -212,6 +212,11 @@
start_time = 0 # Help the flow space
start_usage = 0 # Help the flow space
#llop.debug_print(lltype.Void, 'semispace_collect', int(size_changing))
+
+ # Switch the spaces. We copy everything over to the empty space
+ # (self.fromspace at the beginning of the collection), and clear the old
+ # one (self.tospace at the beginning). Their purposes will be reversed
+ # for the next collection.
tospace = self.fromspace
fromspace = self.tospace
self.fromspace = fromspace
Modified: pypy/branch/newtrunk/pypy/rpython/test/test_rfloat.py
==============================================================================
--- pypy/branch/newtrunk/pypy/rpython/test/test_rfloat.py (original)
+++ pypy/branch/newtrunk/pypy/rpython/test/test_rfloat.py Mon Aug 31 15:15:51 2009
@@ -2,7 +2,7 @@
from pypy.translator.translator import TranslationContext
from pypy.rpython.test import snippet
from pypy.rpython.test.tool import BaseRtypingTest, LLRtypeMixin, OORtypeMixin
-from pypy.rlib.rarithmetic import r_uint, r_longlong, r_singlefloat,\
+from pypy.rlib.rarithmetic import r_int, r_uint, r_longlong, r_singlefloat,\
isnan, isinf
class TestSnippet(object):
@@ -76,12 +76,17 @@
assert res == fn(2.34)
def test_longlong_conversion(self):
+ import sys
def fn(f):
return r_longlong(f)
res = self.interpret(fn, [1.0])
assert res == 1
- assert self.is_of_type(res, r_longlong)
+ # r_longlong is int on a 64 bit system
+ if sys.maxint == 2**63 - 1:
+ assert self.is_of_type(res, int)
+ else:
+ assert self.is_of_type(res, r_longlong)
res = self.interpret(fn, [2.34])
assert res == fn(2.34)
big = float(0x7fffffffffffffff)
Modified: pypy/branch/newtrunk/pypy/rpython/tool/test/test_rffi_platform.py
==============================================================================
--- pypy/branch/newtrunk/pypy/rpython/tool/test/test_rffi_platform.py (original)
+++ pypy/branch/newtrunk/pypy/rpython/tool/test/test_rffi_platform.py Mon Aug 31 15:15:51 2009
@@ -4,6 +4,7 @@
from pypy.rpython.lltypesystem import rffi
from pypy.tool.udir import udir
from pypy.translator.tool.cbuild import ExternalCompilationInfo
+from pypy.translator.platform import platform
def import_ctypes():
try:
@@ -234,3 +235,24 @@
a = rffi_platform.memory_alignment()
print a
assert a % struct.calcsize("P") == 0
+
+def test_external_lib():
+ # XXX this one seems to be a bit too platform-specific. Check
+ # how to test it on windows correctly (using so_prefix?)
+ # and what are alternatives to LD_LIBRARY_PATH
+ eci = ExternalCompilationInfo()
+ c_source = """
+ int f(int a, int b)
+ {
+ return (a + b);
+ }
+ """
+ tmpdir = udir.join('external_lib').ensure(dir=1)
+ c_file = tmpdir.join('libc_lib.c')
+ c_file.write(c_source)
+ l = platform.compile([c_file], eci, standalone=False)
+ eci = ExternalCompilationInfo(
+ libraries = ['c_lib'],
+ library_dirs = [str(tmpdir)]
+ )
+ rffi_platform.verify_eci(eci)
Modified: pypy/branch/newtrunk/pypy/translator/c/dlltool.py
==============================================================================
--- pypy/branch/newtrunk/pypy/translator/c/dlltool.py (original)
+++ pypy/branch/newtrunk/pypy/translator/c/dlltool.py Mon Aug 31 15:15:51 2009
@@ -6,6 +6,7 @@
class CLibraryBuilder(CBuilder):
standalone = False
+ split = True
def __init__(self, *args, **kwds):
self.functions = kwds.pop('functions')
@@ -35,10 +36,10 @@
return self.so_name
class DLLDef(object):
- def __init__(self, name, functions=[], policy=None):
+ def __init__(self, name, functions=[], policy=None, config=None):
self.name = name
self.functions = functions # [(function, annotation), ...]
- self.driver = TranslationDriver()
+ self.driver = TranslationDriver(config=config)
self.driver.setup_library(self, policy=policy)
def compile(self):
Modified: pypy/branch/newtrunk/pypy/translator/c/genc.py
==============================================================================
--- pypy/branch/newtrunk/pypy/translator/c/genc.py (original)
+++ pypy/branch/newtrunk/pypy/translator/c/genc.py Mon Aug 31 15:15:51 2009
@@ -101,6 +101,7 @@
c_source_filename = None
_compiled = False
modulename = None
+ split = False
def __init__(self, translator, entrypoint, config, gcpolicy=None):
self.translator = translator
@@ -231,7 +232,8 @@
assert not self.config.translation.instrument
self.eci, cfile, extra = gen_source(db, modulename, targetdir,
self.eci,
- defines = defines)
+ defines = defines,
+ split=self.split)
else:
pfname = db.get(pf)
if self.config.translation.instrument:
@@ -428,9 +430,10 @@
bk = self.translator.annotator.bookkeeper
return getfunctionptr(bk.getdesc(self.entrypoint).getuniquegraph())
- def cmdexec(self, args=''):
+ def cmdexec(self, args='', env=None):
assert self._compiled
- res = self.translator.platform.execute(self.executable_name, args)
+ res = self.translator.platform.execute(self.executable_name, args,
+ env=env)
if res.returncode != 0:
raise Exception("Returned %d" % (res.returncode,))
return res.out
@@ -515,7 +518,7 @@
self.path = None
self.namespace = NameManager()
- def set_strategy(self, path):
+ def set_strategy(self, path, split=True):
all_nodes = list(self.database.globalcontainers())
# split off non-function nodes. We don't try to optimize these, yet.
funcnodes = []
@@ -526,7 +529,8 @@
else:
othernodes.append(node)
# for now, only split for stand-alone programs.
- if self.database.standalone:
+ #if self.database.standalone:
+ if split:
self.one_source_file = False
self.funcnodes = funcnodes
self.othernodes = othernodes
@@ -817,7 +821,7 @@
files, eci = eci.get_module_files()
return eci, filename, sg.getextrafiles() + list(files)
-def gen_source(database, modulename, targetdir, eci, defines={}):
+def gen_source(database, modulename, targetdir, eci, defines={}, split=False):
assert not database.standalone
if isinstance(targetdir, str):
targetdir = py.path.local(targetdir)
@@ -852,7 +856,9 @@
# 2) Implementation of functions and global structures and arrays
#
sg = SourceGenerator(database, preimplementationlines)
- sg.set_strategy(targetdir)
+ sg.set_strategy(targetdir, split)
+ if split:
+ database.prepare_inline_helpers()
sg.gen_readable_parts_of_source(f)
gen_startupcode(f, database)
Modified: pypy/branch/newtrunk/pypy/translator/c/node.py
==============================================================================
--- pypy/branch/newtrunk/pypy/translator/c/node.py (original)
+++ pypy/branch/newtrunk/pypy/translator/c/node.py Mon Aug 31 15:15:51 2009
@@ -13,6 +13,7 @@
from pypy.rlib.rarithmetic import isinf, isnan
from pypy.translator.c import extfunc
from pypy.translator.tool.cbuild import ExternalCompilationInfo
+from py.builtin import BaseException
def needs_gcheader(T):
if not isinstance(T, ContainerType):
@@ -892,7 +893,7 @@
return 'Py_None'
import types, py
if isinstance(value, (type, types.ClassType)):
- if (issubclass(value, Exception) and
+ if (issubclass(value, BaseException) and
(value.__module__ == 'exceptions'
or value is py.magic.AssertionError)):
return 'PyExc_' + value.__name__
Modified: pypy/branch/newtrunk/pypy/translator/c/test/test_dlltool.py
==============================================================================
--- pypy/branch/newtrunk/pypy/translator/c/test/test_dlltool.py (original)
+++ pypy/branch/newtrunk/pypy/translator/c/test/test_dlltool.py Mon Aug 31 15:15:51 2009
@@ -1,6 +1,7 @@
from pypy.translator.c.dlltool import DLLDef
from ctypes import CDLL
+import py
class TestDLLTool(object):
def test_basic(self):
@@ -15,3 +16,14 @@
dll = CDLL(str(so))
assert dll.f(3) == 3
assert dll.b(10) == 12
+
+ def test_split_criteria(self):
+ def f(x):
+ return x
+
+ def b(x):
+ return x + 2
+
+ d = DLLDef('lib', [(f, [int]), (b, [int])])
+ so = d.compile()
+ assert py.path.local(so).dirpath().join('implement.c').check()
Modified: pypy/branch/newtrunk/pypy/translator/c/test/test_genc.py
==============================================================================
--- pypy/branch/newtrunk/pypy/translator/c/test/test_genc.py (original)
+++ pypy/branch/newtrunk/pypy/translator/c/test/test_genc.py Mon Aug 31 15:15:51 2009
@@ -12,7 +12,6 @@
from pypy.translator.gensupp import uniquemodulename
from pypy.translator.backendopt.all import backend_optimizations
from pypy.translator.interactive import Translation
-from pypy import conftest
def compile(fn, argtypes, view=False, gcpolicy="ref", backendopt=True,
annotatorpolicy=None):
@@ -24,7 +23,7 @@
# XXX fish
t.driver.config.translation.countmallocs = True
compiled_fn = t.compile_c()
- if conftest.option.view:
+ if py.test.config.option.view:
t.view()
malloc_counters = t.driver.cbuilder.get_malloc_counters()
def checking_fn(*args, **kwds):
@@ -403,6 +402,6 @@
t = Translation(f, [], backend="c")
t.annotate()
compiled_fn = t.compile_c()
- if conftest.option.view:
+ if py.test.config.option.view:
t.view()
assert 'pypy_xyz_f' in t.driver.cbuilder.c_source_filename.read()
Modified: pypy/branch/newtrunk/pypy/translator/c/test/test_standalone.py
==============================================================================
--- pypy/branch/newtrunk/pypy/translator/c/test/test_standalone.py (original)
+++ pypy/branch/newtrunk/pypy/translator/c/test/test_standalone.py Mon Aug 31 15:15:51 2009
@@ -77,11 +77,11 @@
cbuilder.compile()
counters_fname = udir.join("_counters_")
- os.putenv('_INSTRUMENT_COUNTERS', str(counters_fname))
+ os.environ['_INSTRUMENT_COUNTERS'] = str(counters_fname)
try:
data = cbuilder.cmdexec()
finally:
- os.unsetenv('_INSTRUMENT_COUNTERS')
+ del os.environ['_INSTRUMENT_COUNTERS']
f = counters_fname.open('rb')
counters_data = f.read()
Modified: pypy/branch/newtrunk/pypy/translator/cli/src/ll_os.cs
==============================================================================
--- pypy/branch/newtrunk/pypy/translator/cli/src/ll_os.cs (original)
+++ pypy/branch/newtrunk/pypy/translator/cli/src/ll_os.cs Mon Aug 31 15:15:51 2009
@@ -261,7 +261,8 @@
public static void ll_os_close(int fd)
{
FileStream stream = getfd(fd).GetStream();
- stream.Close();
+ if (stream != null) // stdin/stdout/stderr files don't have a stream
+ stream.Close();
FileDescriptors.Remove(fd);
}
Modified: pypy/branch/newtrunk/pypy/translator/geninterplevel.py
==============================================================================
--- pypy/branch/newtrunk/pypy/translator/geninterplevel.py (original)
+++ pypy/branch/newtrunk/pypy/translator/geninterplevel.py Mon Aug 31 15:15:51 2009
@@ -982,7 +982,7 @@
globname = self.nameof(self.moddict)
self.initcode.append('space.setitem(%s, space.new_interned_str("__builtins__"), '
'space.builtin.w_dict)' % globname)
- self.initcode.append('%s = space.eval("property(%s)", %s, %s. hidden_applevel=True)' %(
+ self.initcode.append('%s = space.eval("property(%s)", %s, %s, hidden_applevel=True)' %(
name, origin, globname, globname) )
self.initcode.append('space.delitem(%s, space.new_interned_str("__builtins__"))'
% globname)
Modified: pypy/branch/newtrunk/pypy/translator/goal/sharedpypy.py
==============================================================================
--- pypy/branch/newtrunk/pypy/translator/goal/sharedpypy.py (original)
+++ pypy/branch/newtrunk/pypy/translator/goal/sharedpypy.py Mon Aug 31 15:15:51 2009
@@ -1,14 +1,15 @@
-import sys
+import sys, pdb, traceback
from pypy.translator.c.dlltool import DLLDef
from pypy.config.translationoption import get_combined_translation_config
-from pypy.rpython.lltypesystem.rffi import charp2str, CCHARP
+from pypy.rpython.lltypesystem.rffi import charp2str, CCHARP, VOIDP
from pypy.tool.option import make_objspace
from pypy.interpreter.error import OperationError
from pypy.config.pypyoption import pypy_optiondescription, set_pypy_opt_level
from pypy.interpreter.pyopcode import prepare_exec
from pypy.translator.goal.ann_override import PyPyAnnotatorPolicy
from pypy.config.translationoption import set_opt_level
+from pypy.config.pypyoption import enable_allworkingmodules
OVERRIDES = {
'translation.debug': False,
@@ -22,12 +23,13 @@
config.translating = True
set_opt_level(config, '1')
set_pypy_opt_level(config, '1')
- print config
+ enable_allworkingmodules(config)
space = make_objspace(config)
policy = PyPyAnnotatorPolicy(single_space = space)
+ policy.allow_someobjects = False
- def interpret(source):
+ def interpret(source, context):
source = charp2str(source)
w_dict = space.newdict()
try:
@@ -41,8 +43,18 @@
return 1
return 0
- dll = DLLDef('pypylib', [(interpret, [CCHARP])], policy=policy)
+ dll = DLLDef('pypylib', [(interpret, [CCHARP, VOIDP])], policy=policy,
+ config=config)
exe_name = dll.compile()
if __name__ == '__main__':
- main(sys.argv)
+ try:
+ main(sys.argv)
+ except KeyboardInterrupt:
+ raise
+ except:
+ e, v, tb = sys.exc_info()
+ traceback.print_tb(tb)
+ print e, v
+ pdb.post_mortem(tb)
+
Modified: pypy/branch/newtrunk/pypy/translator/goal/targetpypystandalone.py
==============================================================================
--- pypy/branch/newtrunk/pypy/translator/goal/targetpypystandalone.py (original)
+++ pypy/branch/newtrunk/pypy/translator/goal/targetpypystandalone.py Mon Aug 31 15:15:51 2009
@@ -199,6 +199,16 @@
wrapstr = 'space.wrap(%r)' % (options)
pypy.module.sys.Module.interpleveldefs['pypy_translation_info'] = wrapstr
+ if config.translation.backend in ["cli", "jvm"] and sys.platform == "win32":
+ # HACK: The ftruncate implementation in streamio.py which is used for the Win32 platform
+ # is specific for the C backend and can't be generated on CLI or JVM. Because of that,
+ # we have to patch it out.
+ from pypy.rlib import streamio
+ def ftruncate_win32_dummy(fd, size): pass
+ def _setfd_binary_dummy(fd): pass
+ streamio.ftruncate_win32 = ftruncate_win32_dummy
+ streamio._setfd_binary = _setfd_binary_dummy
+
return self.get_entry_point(config)
def jitpolicy(self, driver):
Modified: pypy/branch/newtrunk/pypy/translator/jvm/genjvm.py
==============================================================================
--- pypy/branch/newtrunk/pypy/translator/jvm/genjvm.py (original)
+++ pypy/branch/newtrunk/pypy/translator/jvm/genjvm.py Mon Aug 31 15:15:51 2009
@@ -3,6 +3,7 @@
"""
import sys
+import os
import py
from py.compat import subprocess
@@ -197,7 +198,7 @@
cmd = [getoption('java'),
'-Xmx256M', # increase the heapsize so the microbenchmarks run
'-cp',
- str(self.javadir)+":"+str(self.jnajar),
+ str(self.javadir)+os.pathsep+str(self.jnajar),
self.package+".Main"] + strargs
print "Invoking java to run the code"
stdout, stderr, retval = self._invoke(cmd, True)
Modified: pypy/branch/newtrunk/pypy/translator/platform/__init__.py
==============================================================================
--- pypy/branch/newtrunk/pypy/translator/platform/__init__.py (original)
+++ pypy/branch/newtrunk/pypy/translator/platform/__init__.py Mon Aug 31 15:15:51 2009
@@ -52,6 +52,8 @@
name = "abstract platform"
c_environ = None
+ so_prefixes = ['']
+
def __init__(self, cc):
if self.__class__ is Platform:
raise TypeError("You should not instantiate Platform class directly")
@@ -70,7 +72,12 @@
ofiles.append(self._compile_c_file(self.cc, cfile, compile_args))
return ofiles
- def execute(self, executable, args=None, env=None):
+ def execute(self, executable, args=None, env=None, compilation_info=None):
+ if env is None:
+ env = os.environ.copy()
+ if compilation_info is not None:
+ env['LD_LIBRARY_PATH'] = ':'.join(
+ [str(i) for i in compilation_info.library_dirs])
returncode, stdout, stderr = _run_subprocess(str(executable), args,
env)
return ExecutionResult(returncode, stdout, stderr)
@@ -120,7 +127,7 @@
cflags = self.cflags + extra
return (cflags + list(eci.compile_extra) + args)
- def _link_args_from_eci(self, eci):
+ def _link_args_from_eci(self, eci, standalone):
library_dirs = self._libdirs(eci.library_dirs)
libraries = self._libs(eci.libraries)
link_files = self._linkfiles(eci.link_files)
@@ -141,8 +148,8 @@
cc_link = 'g++' # XXX hard-coded so far
else:
cc_link = self.cc
- return self._link(cc_link, ofiles, self._link_args_from_eci(eci),
- standalone, exe_name)
+ largs = self._link_args_from_eci(eci, standalone)
+ return self._link(cc_link, ofiles, largs, standalone, exe_name)
# below are some detailed informations for platforms
Modified: pypy/branch/newtrunk/pypy/translator/platform/darwin.py
==============================================================================
--- pypy/branch/newtrunk/pypy/translator/platform/darwin.py (original)
+++ pypy/branch/newtrunk/pypy/translator/platform/darwin.py Mon Aug 31 15:15:51 2009
@@ -38,8 +38,8 @@
args.append(f)
return args
- def _link_args_from_eci(self, eci):
- args = super(Darwin, self)._link_args_from_eci(eci)
+ def _link_args_from_eci(self, eci, standalone):
+ args = super(Darwin, self)._link_args_from_eci(eci, standalone)
frameworks = self._frameworks(eci.frameworks)
include_dirs = self._includedirs(eci.include_dirs)
return (args + frameworks + include_dirs)
Modified: pypy/branch/newtrunk/pypy/translator/platform/linux.py
==============================================================================
--- pypy/branch/newtrunk/pypy/translator/platform/linux.py (original)
+++ pypy/branch/newtrunk/pypy/translator/platform/linux.py Mon Aug 31 15:15:51 2009
@@ -13,6 +13,7 @@
standalone_only = []
shared_only = []
so_ext = 'so'
+ so_prefixes = ['lib', '']
def _args_for_shared(self, args):
return ['-shared'] + args
Modified: pypy/branch/newtrunk/pypy/translator/platform/test/test_maemo.py
==============================================================================
--- pypy/branch/newtrunk/pypy/translator/platform/test/test_maemo.py (original)
+++ pypy/branch/newtrunk/pypy/translator/platform/test/test_maemo.py Mon Aug 31 15:15:51 2009
@@ -31,3 +31,6 @@
executable = self.platform.compile([cfile], eci)
res = self.platform.execute(executable)
self.check_res(res)
+
+ def test_environment_inheritance(self):
+ py.test.skip("FIXME")
Modified: pypy/branch/newtrunk/pypy/translator/platform/test/test_platform.py
==============================================================================
--- pypy/branch/newtrunk/pypy/translator/platform/test/test_platform.py (original)
+++ pypy/branch/newtrunk/pypy/translator/platform/test/test_platform.py Mon Aug 31 15:15:51 2009
@@ -1,5 +1,5 @@
-import py, sys
+import py, sys, ctypes, os
from pypy.tool.udir import udir
from pypy.translator.platform import CompilationError, Platform
from pypy.translator.platform import host
@@ -102,6 +102,18 @@
res = self.platform.execute(executable)
assert res.out.startswith('4.0')
+ def test_environment_inheritance(self):
+ # make sure that environment is inherited
+ cmd = 'import os; print os.environ["_SOME_VARIABLE_%d"]'
+ res = self.platform.execute('python', ['-c', cmd % 1],
+ env={'_SOME_VARIABLE_1':'xyz'})
+ assert 'xyz' in res.out
+ os.environ['_SOME_VARIABLE_2'] = 'zyz'
+ try:
+ res = self.platform.execute('python', ['-c', cmd % 2])
+ assert 'zyz' in res.out
+ finally:
+ del os.environ['_SOME_VARIABLE_2']
def test_equality():
class X(Platform):
Modified: pypy/branch/newtrunk/pypy/translator/platform/windows.py
==============================================================================
--- pypy/branch/newtrunk/pypy/translator/platform/windows.py (original)
+++ pypy/branch/newtrunk/pypy/translator/platform/windows.py Mon Aug 31 15:15:51 2009
@@ -133,8 +133,9 @@
def _args_for_shared(self, args):
return ['/dll'] + args
- def _link_args_from_eci(self, eci):
- args = super(MsvcPlatform, self)._link_args_from_eci(eci)
+ def _link_args_from_eci(self, eci, standalone):
+ # Windows needs to resolve all symbols even for DLLs
+ args = super(MsvcPlatform, self)._link_args_from_eci(eci, standalone=True)
return args + ['/EXPORT:%s' % symbol for symbol in eci.export_symbols]
def _compile_c_file(self, cc, cfile, compile_args):
Modified: pypy/branch/newtrunk/pypy/translator/test/snippet.py
==============================================================================
--- pypy/branch/newtrunk/pypy/translator/test/snippet.py (original)
+++ pypy/branch/newtrunk/pypy/translator/test/snippet.py Mon Aug 31 15:15:51 2009
@@ -675,7 +675,20 @@
raise Exc(x)
except Exception, e:
return e.args[0]
-
+
+
+class HaveProp(object):
+
+ def __init__(self, v):
+ self.v = v
+
+ def _hi(self):
+ return self.v
+ hi = property(_hi, doc="HaveProp._hi")
+
+
+def run_prop(v):
+ return HaveProp(v).hi
# --------------------(Currently) Non runnable Functions ---------------------
Modified: pypy/branch/newtrunk/pypy/translator/test/test_geninterp.py
==============================================================================
--- pypy/branch/newtrunk/pypy/translator/test/test_geninterp.py (original)
+++ pypy/branch/newtrunk/pypy/translator/test/test_geninterp.py Mon Aug 31 15:15:51 2009
@@ -304,3 +304,7 @@
fn = self.build_interpfunc(snippet.exception_subclass_sanity)
result = fn(7)
assert result == 7
+
+ def test_property(self):
+ fn = self.build_interpfunc(snippet.run_prop)
+ assert fn(23) == 23
More information about the Pypy-commit
mailing list