[pypy-commit] pypy default: Add a passing test that direct running and annotation both crash

2016-09-01 Thread arigo
Author: Armin Rigo 
Branch: 
Changeset: r86809:ce916c69cf00
Date: 2016-09-01 09:35 +0200
http://bitbucket.org/pypy/pypy/changeset/ce916c69cf00/

Log:Add a passing test that direct running and annotation both crash if
we give a float to an llexternal function expecting an int

diff --git a/rpython/rtyper/lltypesystem/test/test_rffi.py 
b/rpython/rtyper/lltypesystem/test/test_rffi.py
--- a/rpython/rtyper/lltypesystem/test/test_rffi.py
+++ b/rpython/rtyper/lltypesystem/test/test_rffi.py
@@ -38,6 +38,24 @@
 xf = self.compile(f, [])
 assert xf() == 8+3
 
+def test_no_float_to_int_conversion(self):
+c_source = py.code.Source("""
+int someexternalfunction(int x)
+{
+return (x + 3);
+}
+""")
+
+eci = ExternalCompilationInfo(separate_module_sources=[c_source])
+z = llexternal('someexternalfunction', [Signed], Signed,
+   compilation_info=eci)
+
+def f():
+return z(8.2)
+
+py.test.raises(TypeError, f)
+py.test.raises(TypeError, self.compile, f, [])
+
 def test_hashdefine(self):
 h_source = """
 #define X(i) (i+3)
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: Another passing test

2016-09-01 Thread arigo
Author: Armin Rigo 
Branch: 
Changeset: r86810:809a3f78b64f
Date: 2016-09-01 09:43 +0200
http://bitbucket.org/pypy/pypy/changeset/809a3f78b64f/

Log:Another passing test

diff --git a/rpython/translator/sandbox/test/test_sandbox.py 
b/rpython/translator/sandbox/test/test_sandbox.py
--- a/rpython/translator/sandbox/test/test_sandbox.py
+++ b/rpython/translator/sandbox/test/test_sandbox.py
@@ -29,6 +29,7 @@
 assert msg == fnname
 msg = read_message(f)
 assert msg == args
+assert [type(x) for x in msg] == [type(x) for x in args]
 if isinstance(result, Exception):
 write_exception(g, result)
 else:
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: pfff another hack on top of this pile of hacks

2016-09-01 Thread arigo
Author: Armin Rigo 
Branch: 
Changeset: r86811:76e37b5f30ae
Date: 2016-09-01 09:50 +0200
http://bitbucket.org/pypy/pypy/changeset/76e37b5f30ae/

Log:pfff another hack on top of this pile of hacks

diff --git a/rpython/rlib/rdynload.py b/rpython/rlib/rdynload.py
--- a/rpython/rlib/rdynload.py
+++ b/rpython/rlib/rdynload.py
@@ -170,11 +170,15 @@
 #
 # hck for 'pypy py.test -A' if libm.so is a linker script
 # (see reason in _dlerror_on_dlopen_untranslated())
+must_free = False
 if not we_are_translated() and platform.name == "linux":
 if name and rffi.charp2str(name) == 'libm.so':
-name = rffi.str2charp('libm.so.6', track_allocation=False)
+name = rffi.str2charp('libm.so.6')
+must_free = True
 #
 res = c_dlopen(name, rffi.cast(rffi.INT, mode))
+if must_free:
+rffi.free_charp(name)
 if not res:
 if not we_are_translated():
 err = _dlerror_on_dlopen_untranslated(name)
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: Issue #2388: the problem is obscure interaction with a different call (I

2016-09-01 Thread arigo
Author: Armin Rigo 
Branch: 
Changeset: r86812:7d6c66b14770
Date: 2016-09-01 10:26 +0200
http://bitbucket.org/pypy/pypy/changeset/7d6c66b14770/

Log:Issue #2388: the problem is obscure interaction with a different
call (I don't know which one) with the signature (string, float),
which was considered as more general than the signature (string,
int) of os.access().

diff --git a/rpython/annotator/binaryop.py b/rpython/annotator/binaryop.py
--- a/rpython/annotator/binaryop.py
+++ b/rpython/annotator/binaryop.py
@@ -17,7 +17,7 @@
 from rpython.flowspace.model import Variable, Constant, const
 from rpython.flowspace.operation import op
 from rpython.rlib import rarithmetic
-from rpython.annotator.model import AnnotatorError
+from rpython.annotator.model import AnnotatorError, TLS
 
 BINARY_OPERATIONS = set([oper.opname for oper in op.__dict__.values()
 if oper.dispatch == 2])
@@ -436,6 +436,11 @@
 class __extend__(pairtype(SomeFloat, SomeFloat)):
 
 def union((flt1, flt2)):
+if not TLS.allow_int_to_float:
+# in this mode, if one of the two is actually the
+# subclass SomeInteger, complain
+if isinstance(flt1, SomeInteger) or isinstance(flt2, SomeInteger):
+raise UnionError(flt1, flt2)
 return SomeFloat()
 
 add = sub = mul = union
diff --git a/rpython/annotator/model.py b/rpython/annotator/model.py
--- a/rpython/annotator/model.py
+++ b/rpython/annotator/model.py
@@ -44,6 +44,7 @@
 # A global attribute :-(  Patch it with 'True' to enable checking of
 # the no_nul attribute...
 check_str_without_nul = False
+allow_int_to_float = True
 TLS = State()
 
 class SomeObject(object):
diff --git a/rpython/rlib/rmarshal.py b/rpython/rlib/rmarshal.py
--- a/rpython/rlib/rmarshal.py
+++ b/rpython/rlib/rmarshal.py
@@ -346,11 +346,15 @@
 # on s_bigger.  It relies on the fact that s_bigger was created with
 # an expression like 'annotation([s_item])' which returns a ListDef with
 # no bookkeeper, on which side-effects are not allowed.
+saved = annmodel.TLS.allow_int_to_float
 try:
+annmodel.TLS.allow_int_to_float = False
 s_union = annmodel.unionof(s_bigger, s_smaller)
 return s_bigger.contains(s_union)
 except (annmodel.UnionError, TooLateForChange):
 return False
+finally:
+annmodel.TLS.allow_int_to_float = saved
 
 
 class __extend__(pairtype(MTag, annmodel.SomeObject)):
diff --git a/rpython/rlib/test/test_rmarshal.py 
b/rpython/rlib/test/test_rmarshal.py
--- a/rpython/rlib/test/test_rmarshal.py
+++ b/rpython/rlib/test/test_rmarshal.py
@@ -128,10 +128,12 @@
 
 def test_llinterp_marshal():
 from rpython.rtyper.test.test_llinterp import interpret
-marshaller = get_marshaller([(int, str, float)])
+marshaller1 = get_marshaller([(int, str, float)])
+marshaller2 = get_marshaller([(int, str, int)])
 def f():
 buf = []
-marshaller(buf, [(5, "hello", -0.5), (7, "world", 1E100)])
+marshaller1(buf, [(5, "hello", -0.5), (7, "world", 1E100)])
+marshaller2(buf, [(5, "hello", 1)])
 return ''.join(buf)
 res = interpret(f, [])
 res = ''.join(res.chars)
@@ -139,14 +141,20 @@
 assert res == ('[\x02\x00\x00\x00(\x03\x00\x00\x00i\x05\x00\x00\x00'
's\x05\x00\x00\x00hellof\x04-0.5(\x03\x00\x00\x00'
'i\x07\x00\x00\x00s\x05\x00\x00\x00world'
-   'f\x061e+100')
+   'f\x061e+100'
+   '[\x01\x00\x00\x00(\x03\x00\x00\x00i\x05\x00\x00\x00'
+   's\x05\x00\x00\x00helloi\x01\x00\x00\x00')
 else:
 assert res == ('[\x02\x00\x00\x00(\x03\x00\x00\x00'
'I\x05\x00\x00\x00\x00\x00\x00\x00'
's\x05\x00\x00\x00hellof\x04-0.5(\x03\x00\x00\x00'
'I\x07\x00\x00\x00\x00\x00\x00\x00'
's\x05\x00\x00\x00world'
-   'f\x061e+100')
+   'f\x061e+100'
+   '[\x01\x00\x00\x00(\x03\x00\x00\x00'
+   'I\x05\x00\x00\x00\x00\x00\x00\x00'
+   's\x05\x00\x00\x00hello'
+   'I\x01\x00\x00\x00\x00\x00\x00\x00')
 
 def test_llinterp_unmarshal():
 from rpython.rtyper.test.test_llinterp import interpret
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: Don't put an __init__ in a Test class, it makes py.test skip(!?!!) that class

2016-09-01 Thread arigo
Author: Armin Rigo 
Branch: 
Changeset: r86813:8e7fe0c9ab70
Date: 2016-09-01 11:49 +0200
http://bitbucket.org/pypy/pypy/changeset/8e7fe0c9ab70/

Log:Don't put an __init__ in a Test class, it makes py.test skip(!?!!)
that class

diff --git a/rpython/rlib/test/test_runicode.py 
b/rpython/rlib/test/test_runicode.py
--- a/rpython/rlib/test/test_runicode.py
+++ b/rpython/rlib/test/test_runicode.py
@@ -286,7 +286,7 @@
 
 
 class TestUTF8Decoding(UnicodeTests):
-def __init__(self):
+def setup_method(self, meth):
 self.decoder = self.getdecoder('utf-8')
 
 def to_bytestring(self, bytes):
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: Hack at our included py.test to fail, not quietly skip, when it sees a

2016-09-01 Thread arigo
Author: Armin Rigo 
Branch: 
Changeset: r86815:0ace73a20a81
Date: 2016-09-01 11:03 +0100
http://bitbucket.org/pypy/pypy/changeset/0ace73a20a81/

Log:Hack at our included py.test to fail, not quietly skip, when it sees
a TestXxx class with an __init__() method

diff --git a/_pytest/python.py b/_pytest/python.py
--- a/_pytest/python.py
+++ b/_pytest/python.py
@@ -498,7 +498,10 @@
 """ Collector for test methods. """
 def collect(self):
 if hasinit(self.obj):
-pytest.skip("class %s.%s with __init__ won't get collected" % (
+# XXX used to be skip(), but silently skipping classes
+# XXX just because they have been written long ago is
+# XXX imho a very, very, very bad idea
+pytest.fail("class %s.%s with __init__ won't get collected" % (
 self.obj.__module__,
 self.obj.__name__,
 ))
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: Rename the exception that we call TestException to some class name that

2016-09-01 Thread arigo
Author: Armin Rigo 
Branch: 
Changeset: r86814:955998701207
Date: 2016-09-01 11:02 +0100
http://bitbucket.org/pypy/pypy/changeset/955998701207/

Log:Rename the exception that we call TestException to some class name
that doesn't start with Test, which confuses py.test

diff --git a/rpython/translator/c/test/test_exception.py 
b/rpython/translator/c/test/test_exception.py
--- a/rpython/translator/c/test/test_exception.py
+++ b/rpython/translator/c/test/test_exception.py
@@ -9,7 +9,7 @@
 getcompiledopt = test_backendoptimized.TestTypedOptimizedTestCase().getcompiled
 
 
-class TestException(Exception):
+class InTestException(Exception):
 pass
 
 class MyException(Exception):
@@ -18,7 +18,7 @@
 def test_simple1():
 def raise_(i):
 if i == 0:
-raise TestException()
+raise InTestException()
 elif i == 1:
 raise MyException()
 else:
@@ -29,7 +29,7 @@
 b = raise_(i) + 12
 c = raise_(i) + 13
 return a+b+c
-except TestException:
+except InTestException:
 return 7
 except MyException:
 return 123
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: Issue #2389: the custom error handler may return a 'pos' that is smaller

2016-09-01 Thread arigo
Author: Armin Rigo 
Branch: 
Changeset: r86816:e9dd5882eed6
Date: 2016-09-01 12:23 +0200
http://bitbucket.org/pypy/pypy/changeset/e9dd5882eed6/

Log:Issue #2389: the custom error handler may return a 'pos' that is
smaller than 'size', in which case we need to continue looping

diff --git a/rpython/rlib/runicode.py b/rpython/rlib/runicode.py
--- a/rpython/rlib/runicode.py
+++ b/rpython/rlib/runicode.py
@@ -157,22 +157,26 @@
 if pos + n > size:
 if not final:
 break
+# argh, this obscure block of code is mostly a copy of
+# what follows :-(
 charsleft = size - pos - 1 # either 0, 1, 2
-# note: when we get the 'unexpected end of data' we don't care
-# about the pos anymore and we just ignore the value
+# note: when we get the 'unexpected end of data' we need
+# to care about the pos returned; it can be lower than size,
+# in case we need to continue running this loop
 if not charsleft:
 # there's only the start byte and nothing else
 r, pos = errorhandler(errors, 'utf8',
   'unexpected end of data',
   s, pos, pos+1)
 result.append(r)
-break
+continue
 ordch2 = ord(s[pos+1])
 if n == 3:
 # 3-bytes seq with only a continuation byte
 if (ordch2>>6 != 0x2 or   # 0b10
-(ordch1 == 0xe0 and ordch2 < 0xa0)):
-# or (ordch1 == 0xed and ordch2 > 0x9f)
+(ordch1 == 0xe0 and ordch2 < 0xa0)
+or (not allow_surrogates and ordch1 == 0xed and ordch2 > 0x9f)
+):
 # second byte invalid, take the first and continue
 r, pos = errorhandler(errors, 'utf8',
   'invalid continuation byte',
@@ -185,7 +189,7 @@
   'unexpected end of data',
   s, pos, pos+2)
 result.append(r)
-break
+continue
 elif n == 4:
 # 4-bytes seq with 1 or 2 continuation bytes
 if (ordch2>>6 != 0x2 or# 0b10
@@ -210,7 +214,8 @@
   'unexpected end of data',
   s, pos, pos+charsleft+1)
 result.append(r)
-break
+continue
+raise AssertionError("unreachable")
 
 if n == 0:
 r, pos = errorhandler(errors, 'utf8',
diff --git a/rpython/rlib/test/test_runicode.py 
b/rpython/rlib/test/test_runicode.py
--- a/rpython/rlib/test/test_runicode.py
+++ b/rpython/rlib/test/test_runicode.py
@@ -289,6 +289,12 @@
 def setup_method(self, meth):
 self.decoder = self.getdecoder('utf-8')
 
+def custom_replace(self, errors, encoding, msg, s, startingpos, endingpos):
+assert errors == 'custom'
+# returns FOO, but consumes only one character (not up to endingpos)
+FOO = u'\u1234'
+return FOO, startingpos + 1
+
 def to_bytestring(self, bytes):
 return ''.join(chr(int(c, 16)) for c in bytes.split())
 
@@ -309,6 +315,7 @@
 E.g. <80> is a continuation byte and can appear only after a start 
byte.
 """
 FFFD = u'\ufffd'
+FOO = u'\u1234'
 for byte in '\x80\xA0\x9F\xBF\xC0\xC1\xF5\xFF':
 py.test.raises(UnicodeDecodeError, self.decoder, byte, 1, None, 
final=True)
 self.checkdecodeerror(byte, 'utf-8', 0, 1, addstuff=False,
@@ -320,6 +327,11 @@
 assert self.decoder(byte, 1, 'ignore', final=True) == (u'', 1)
 assert (self.decoder('' + byte + '', 9, 'ignore',
 final=True) == (u'', 9))
+assert self.decoder(byte, 1, 'custom', final=True,
+errorhandler=self.custom_replace) == (FOO, 1)
+assert (self.decoder('' + byte + '', 9, 'custom',
+final=True, errorhandler=self.custom_replace) ==
+(u''+ FOO + u'', 9))
 
 def test_unexpected_end_of_data(self):
 """
@@ -343,6 +355,7 @@
 'F4 80', 'F4 8F', 'F4 80 80', 'F4 80 BF', 'F4 8F 80', 'F4 8F BF'
 ]
 FFFD = u'\ufffd'
+FOO = u'\u1234'
 for seq in sequences:
 seq = self.to_bytestring(seq)
 py.test.raises(UnicodeDecodeError, self.decoder, seq, len(seq),
@@ -358,6 +371,12 @@
 ) == (u'', len(seq))
 assert (self.decoder('' + seq + '', len(seq) + 8, 'ignore',
 final=True) == (u'', len(seq) + 8))
+assert (self.decoder(seq, len(seq), 'custom'

[pypy-commit] pypy default: Move the bit checking inside helpers, share it from the two places

2016-09-01 Thread arigo
Author: Armin Rigo 
Branch: 
Changeset: r86817:ee3a2fbec01a
Date: 2016-09-01 12:36 +0200
http://bitbucket.org/pypy/pypy/changeset/ee3a2fbec01a/

Log:Move the bit checking inside helpers, share it from the two places

diff --git a/rpython/rlib/runicode.py b/rpython/rlib/runicode.py
--- a/rpython/rlib/runicode.py
+++ b/rpython/rlib/runicode.py
@@ -137,6 +137,25 @@
  result=result)
 return result.build(), pos
 
+def _invalid_cont_byte(ordch):
+return ordch>>6 != 0x2# 0b10
+
+_invalid_byte_2_of_2 = _invalid_cont_byte
+_invalid_byte_3_of_3 = _invalid_cont_byte
+_invalid_byte_3_of_4 = _invalid_cont_byte
+_invalid_byte_4_of_4 = _invalid_cont_byte
+
+def _invalid_byte_2_of_3(ordch1, ordch2, allow_surrogates):
+return (ordch2>>6 != 0x2 or# 0b10
+(ordch1 == 0xe0 and ordch2 < 0xa0)
+# surrogates shouldn't be valid UTF-8!
+or (not allow_surrogates and ordch1 == 0xed and ordch2 > 0x9f))
+
+def _invalid_byte_2_of_4(ordch1, ordch2):
+return (ordch2>>6 != 0x2 or# 0b10
+(ordch1 == 0xf0 and ordch2 < 0x90) or
+(ordch1 == 0xf4 and ordch2 > 0x8f))
+
 @specialize.argtype(6)
 def str_decode_utf_8_impl(s, size, errors, final, errorhandler,
   allow_surrogates, result):
@@ -173,10 +192,7 @@
 ordch2 = ord(s[pos+1])
 if n == 3:
 # 3-bytes seq with only a continuation byte
-if (ordch2>>6 != 0x2 or   # 0b10
-(ordch1 == 0xe0 and ordch2 < 0xa0)
-or (not allow_surrogates and ordch1 == 0xed and ordch2 > 0x9f)
-):
+if _invalid_byte_2_of_3(ordch1, ordch2, allow_surrogates):
 # second byte invalid, take the first and continue
 r, pos = errorhandler(errors, 'utf8',
   'invalid continuation byte',
@@ -192,16 +208,14 @@
 continue
 elif n == 4:
 # 4-bytes seq with 1 or 2 continuation bytes
-if (ordch2>>6 != 0x2 or# 0b10
-(ordch1 == 0xf0 and ordch2 < 0x90) or
-(ordch1 == 0xf4 and ordch2 > 0x8f)):
+if _invalid_byte_2_of_4(ordch1, ordch2):
 # second byte invalid, take the first and continue
 r, pos = errorhandler(errors, 'utf8',
   'invalid continuation byte',
   s, pos, pos+1)
 result.append(r)
 continue
-elif charsleft == 2 and ord(s[pos+2])>>6 != 0x2:   # 0b10
+elif charsleft == 2 and _invalid_byte_3_of_4(ord(s[pos+2])):
 # third byte invalid, take the first two and continue
 r, pos = errorhandler(errors, 'utf8',
   'invalid continuation byte',
@@ -228,7 +242,7 @@
 
 elif n == 2:
 ordch2 = ord(s[pos+1])
-if ordch2>>6 != 0x2:   # 0b10
+if _invalid_byte_2_of_2(ordch2):
 r, pos = errorhandler(errors, 'utf8',
   'invalid continuation byte',
   s, pos, pos+1)
@@ -242,17 +256,13 @@
 elif n == 3:
 ordch2 = ord(s[pos+1])
 ordch3 = ord(s[pos+2])
-if (ordch2>>6 != 0x2 or# 0b10
-(ordch1 == 0xe0 and ordch2 < 0xa0)
-# surrogates shouldn't be valid UTF-8!
-or (not allow_surrogates and ordch1 == 0xed and ordch2 > 0x9f)
-):
+if _invalid_byte_2_of_3(ordch1, ordch2, allow_surrogates):
 r, pos = errorhandler(errors, 'utf8',
   'invalid continuation byte',
   s, pos, pos+1)
 result.append(r)
 continue
-elif ordch3>>6 != 0x2: # 0b10
+elif _invalid_byte_3_of_3(ordch3):
 r, pos = errorhandler(errors, 'utf8',
   'invalid continuation byte',
   s, pos, pos+2)
@@ -268,21 +278,19 @@
 ordch2 = ord(s[pos+1])
 ordch3 = ord(s[pos+2])
 ordch4 = ord(s[pos+3])
-if (ordch2>>6 != 0x2 or # 0b10
-(ordch1 == 0xf0 and ordch2 < 0x90) or
-(ordch1 == 0xf4 and ordch2 > 0x8f)):
+if _invalid_byte_2_of_4(ordch1, ordch2):
 r, pos = errorhandler(errors, 'utf8',
   'invalid continuation byte',
   s, pos, pos+1)
 result.append(r)
 continue
-elif ordch3>>6 != 0x2: # 0b10
+elif _invalid_byte_3_of_4(ordch3):
 r, pos = error

[pypy-commit] pypy buffer-interface: extend and fix the already-existing test for __array_interfac__

2016-09-01 Thread mattip
Author: Matti Picus 
Branch: buffer-interface
Changeset: r86819:8c587f75370f
Date: 2016-09-01 17:56 +0300
http://bitbucket.org/pypy/pypy/changeset/8c587f75370f/

Log:extend and fix the already-existing test for __array_interfac__

diff --git a/pypy/module/micronumpy/ctors.py b/pypy/module/micronumpy/ctors.py
--- a/pypy/module/micronumpy/ctors.py
+++ b/pypy/module/micronumpy/ctors.py
@@ -43,7 +43,7 @@
 raise oefmt(space.w_ValueError,
 "object __array__ method not producing an array")
 
-def try_interface_method(space, w_object):
+def try_interface_method(space, w_object, copy):
 try:
 w_interface = space.getattr(w_object, 
space.wrap("__array_interface__"))
 if w_interface is None:
@@ -86,7 +86,7 @@
space.isinstance_w(w_data, space.w_list)):
 data_w = space.listview(w_data)
 w_data = rffi.cast(RAW_STORAGE_PTR, space.int_w(data_w[0]))
-read_only = space.is_true(data_w[1])
+read_only = space.is_true(data_w[1]) or copy
 offset = 0
 w_base = w_object
 if read_only:
@@ -203,7 +203,7 @@
 # use buffer interface
 w_object = _array_from_buffer_3118(space, w_object, dtype)
 if not isinstance(w_object, W_NDimArray):
-w_array, _copy = try_interface_method(space, w_object)
+w_array, _copy = try_interface_method(space, w_object, copy)
 if w_array is not None:
 w_object = w_array
 copy = _copy
diff --git a/pypy/module/micronumpy/test/test_ndarray.py 
b/pypy/module/micronumpy/test/test_ndarray.py
--- a/pypy/module/micronumpy/test/test_ndarray.py
+++ b/pypy/module/micronumpy/test/test_ndarray.py
@@ -3215,7 +3215,9 @@
 raises(TypeError, array, Dummy({'version': 3, 'typestr': 'f8', 
'shape': ('a', 3)}))
 
 a = array([1, 2, 3])
-b = array(Dummy(a.__array_interface__))
+d = Dummy(a.__array_interface__)
+b = array(d)
+assert b.base is None
 b[1] = 200
 assert a[1] == 2 # upstream compatibility, is this a bug?
 interface_a = a.__array_interface__
@@ -3226,6 +3228,8 @@
 interface_b.pop('data')
 interface_a.pop('data')
 assert interface_a == interface_b
+b = array(d, copy=False)
+assert b.base is d
 
 b = array(Dummy({'version':3, 'shape': (50,), 'typestr': 'u1',
  'data': 'a'*100}))
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy buffer-interface: implement view of __array_interface__, fixes issue #52, #53 on pypy/numpy

2016-09-01 Thread mattip
Author: Matti Picus 
Branch: buffer-interface
Changeset: r86818:4916eb438de5
Date: 2016-09-01 16:50 +0300
http://bitbucket.org/pypy/pypy/changeset/4916eb438de5/

Log:implement view of __array_interface__, fixes issue #52, #53 on
pypy/numpy

diff --git a/pypy/module/micronumpy/ctors.py b/pypy/module/micronumpy/ctors.py
--- a/pypy/module/micronumpy/ctors.py
+++ b/pypy/module/micronumpy/ctors.py
@@ -82,13 +82,18 @@
 raise oefmt(space.w_ValueError,
 "__array_interface__ could not decode dtype %R", w_dtype
 )
-if w_data is not None and (space.isinstance_w(w_data, space.w_tuple) 
or space.isinstance_w(w_data, space.w_list)):
+if w_data is not None and (space.isinstance_w(w_data, space.w_tuple) or
+   space.isinstance_w(w_data, space.w_list)):
 data_w = space.listview(w_data)
 w_data = rffi.cast(RAW_STORAGE_PTR, space.int_w(data_w[0]))
-read_only = True # XXX why not space.is_true(data_w[1])
+read_only = space.is_true(data_w[1])
 offset = 0
+w_base = w_object
+if read_only:
+w_base = None
 return W_NDimArray.from_shape_and_storage(space, shape, w_data, 
-dtype, strides=strides, start=offset), 
read_only
+dtype, w_base=w_base, strides=strides,
+start=offset), read_only
 if w_data is None:
 w_data = w_object
 w_offset = space.finditem(w_interface, space.wrap('offset'))
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy redirect-assembler-jitlog: new tag tmp_callback to correctly make the connection between call_assembler <-> trace

2016-09-01 Thread plan_rich
Author: Richard Plangger 
Branch: redirect-assembler-jitlog
Changeset: r86821:a2f692a70b2d
Date: 2016-09-01 17:44 +0200
http://bitbucket.org/pypy/pypy/changeset/a2f692a70b2d/

Log:new tag tmp_callback to correctly make the connection between
call_assembler <-> trace

diff --git a/rpython/jit/metainterp/compile.py 
b/rpython/jit/metainterp/compile.py
--- a/rpython/jit/metainterp/compile.py
+++ b/rpython/jit/metainterp/compile.py
@@ -7,6 +7,7 @@
 from rpython.rlib import rstack
 from rpython.rlib.jit import JitDebugInfo, Counters, dont_look_inside
 from rpython.rlib.rjitlog import rjitlog as jl
+from rpython.rlib.objectmodel import compute_unique_id
 from rpython.conftest import option
 
 from rpython.jit.metainterp.resoperation import ResOperation, rop,\
@@ -1156,6 +1157,9 @@
 operations[1].setfailargs([])
 operations = get_deep_immutable_oplist(operations)
 cpu.compile_loop(inputargs, operations, jitcell_token, log=False)
+
+jl.tmp_callback(looptoken)
+
 if memory_manager is not None:# for tests
 memory_manager.keep_loop_alive(jitcell_token)
 return jitcell_token
diff --git a/rpython/rlib/rjitlog/rjitlog.py b/rpython/rlib/rjitlog/rjitlog.py
--- a/rpython/rlib/rjitlog/rjitlog.py
+++ b/rpython/rlib/rjitlog/rjitlog.py
@@ -212,7 +212,7 @@
 return method
 return decor
 
-JITLOG_VERSION = 3
+JITLOG_VERSION = 4
 JITLOG_VERSION_16BIT_LE = struct.pack("https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy redirect-assembler-jitlog: merge default

2016-09-01 Thread plan_rich
Author: Richard Plangger 
Branch: redirect-assembler-jitlog
Changeset: r86820:a8a56628fefe
Date: 2016-09-01 15:57 +0200
http://bitbucket.org/pypy/pypy/changeset/a8a56628fefe/

Log:merge default

diff too long, truncating to 2000 out of 212851 lines

diff --git a/.hgtags b/.hgtags
--- a/.hgtags
+++ b/.hgtags
@@ -27,3 +27,6 @@
 40497617ae91caa1a394d8be6f9cd2de31cb0628 release-pypy3.3-v5.2
 c09c19272c990a0611b17569a0085ad1ab00c8ff release-pypy2.7-v5.3
 7e8df3df96417c16c2d55b41352ec82c9c69c978 release-pypy2.7-v5.3.1
+68bb3510d8212ae9efb687e12e58c09d29e74f87 release-pypy2.7-v5.4.0
+68bb3510d8212ae9efb687e12e58c09d29e74f87 release-pypy2.7-v5.4.0
+77392ad263504df011ccfcabf6a62e21d04086d0 release-pypy2.7-v5.4.0
diff --git a/LICENSE b/LICENSE
--- a/LICENSE
+++ b/LICENSE
@@ -74,6 +74,7 @@
   Seo Sanghyeon
   Ronny Pfannschmidt
   Justin Peel
+  Raffael Tfirst
   David Edelsohn
   Anders Hammarquist
   Jakub Gustak
@@ -117,7 +118,6 @@
   Wenzhu Man
   John Witulski
   Laurence Tratt
-  Raffael Tfirst
   Ivan Sichmann Freitas
   Greg Price
   Dario Bertini
@@ -141,6 +141,7 @@
   tav
   Taavi Burns
   Georg Brandl
+  Nicolas Truessel
   Bert Freudenberg
   Stian Andreassen
   Wanja Saatkamp
@@ -211,6 +212,7 @@
   Vaibhav Sood
   Alan McIntyre
   Alexander Sedov
+  p_ziesch...@yahoo.de
   Attila Gobi
   Jasper.Schulz
   Christopher Pope
@@ -221,6 +223,7 @@
   Arjun Naik
   Valentina Mukhamedzhanova
   Stefano Parmesan
+  touilleMan
   Alexis Daboville
   Jens-Uwe Mager
   Carl Meyer
@@ -229,12 +232,14 @@
   Gabriel
   Lukas Vacek
   Kunal Grover
+  Aaron Gallagher
   Andrew Dalke
   Sylvain Thenault
   Jakub Stasiak
   Nathan Taylor
   Vladimir Kryachko
   Omer Katz
+  Mark Williams
   Jacek Generowicz
   Alejandro J. Cura
   Jacob Oscarson
@@ -355,115 +360,12 @@
   yasirs
   Michael Chermside
   Anna Ravencroft
+  pizi
   Andrey Churin
   Dan Crosta
+  Eli Stevens
   Tobias Diaz
   Julien Phalip
   Roman Podoliaka
   Dan Loewenherz
-
-  Heinrich-Heine University, Germany 
-  Open End AB (formerly AB Strakt), Sweden
-  merlinux GmbH, Germany 
-  tismerysoft GmbH, Germany 
-  Logilab Paris, France 
-  DFKI GmbH, Germany 
-  Impara, Germany
-  Change Maker, Sweden 
-  University of California Berkeley, USA
-  Google Inc.
-  King's College London
-
-The PyPy Logo as used by http://speed.pypy.org and others was created
-by Samuel Reis and is distributed on terms of Creative Commons Share Alike
-License.
- 
-License for 'lib-python/2.7'
-
-
-Except when otherwise stated (look for LICENSE files or copyright/license
-information at the beginning of each file) the files in the 'lib-python/2.7'
-directory are all copyrighted by the Python Software Foundation and licensed
-under the terms that you can find here: https://docs.python.org/2/license.html
-
-License for 'pypy/module/unicodedata/'
-==
-
-The following files are from the website of The Unicode Consortium
-at http://www.unicode.org/.  For the terms of use of these files, see
-http://www.unicode.org/terms_of_use.html .  Or they are derived from
-files from the above website, and the same terms of use apply.
-
-CompositionExclusions-*.txt
-EastAsianWidth-*.txt
-LineBreak-*.txt
-UnicodeData-*.txt
-UnihanNumeric-*.txt
-
-License for 'dotviewer/font/'
-=
-
-Copyright (C) 2008 The Android Open Source Project
-
-Licensed under the Apache License, Version 2.0 (the "License");
-you may not use this file except in compliance with the License.
-You may obtain a copy of the License at
-  
- http://www.apache.org/licenses/LICENSE-2.0
-  
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
-
-Detailed license information is contained in the NOTICE file in the
-directory.
-
-
-Licenses and Acknowledgements for Incorporated Software
-===
-
-This section is an incomplete, but growing list of licenses and
-acknowledgements for third-party software incorporated in the PyPy
-distribution.
-
-License for 'Tcl/Tk'
-
-
-This copy of PyPy contains library code that may, when used, result in
-the Tcl/Tk library to be loaded.  PyPy also includes code that may be
-regarded as being a copy of some parts of the Tcl/Tk header files.
-You may see a copy of the License for Tcl/Tk in the file
-`lib_pypy/_tkinter/license.terms` included here.
-
-License for 'bzip2'

-
-This copy of PyPy may be linked (dynamically or statically) with the
-bzip2 library.  You may see a copy of the License for bzip2/libbzip2 at
-
-http://www.bzip.org/1.0.5/bzip2-manual-1.0.5.html
-
-License for 'openssl'
--
-
-This copy of PyPy may be lin

[pypy-commit] pypy asmmemmgr-for-code-only: Fix translation.

2016-09-01 Thread vext01
Author: Edd Barrett 
Branch: asmmemmgr-for-code-only
Changeset: r86822:f777170ec79b
Date: 2016-09-01 17:00 +0100
http://bitbucket.org/pypy/pypy/changeset/f777170ec79b/

Log:Fix translation.

diff --git a/rpython/rlib/rmmap.py b/rpython/rlib/rmmap.py
--- a/rpython/rlib/rmmap.py
+++ b/rpython/rlib/rmmap.py
@@ -746,20 +746,20 @@
 def set_pages_executable(addr, size):
 assert lltype.typeOf(addr) == rffi.CCHARP
 assert isinstance(size, int)
-#assert size >= 0
 rv = mprotect(addr, size, PROT_EXEC | PROT_READ)
 if int(rv) < 0:
 from rpython.rlib import debug
 debug.fatalerror_notb("set_pages_executable failed")
+set_pages_executable._annenforceargs_ = (None, int)
 
 def set_pages_writable(addr, size):
 assert lltype.typeOf(addr) == rffi.CCHARP
 assert isinstance(size, int)
-#assert size >= 0
 rv = mprotect(addr, size, PROT_WRITE | PROT_READ)
 if int(rv) < 0:
 from rpython.rlib import debug
 debug.fatalerror_notb("set_pages_writable failed")
+set_pages_writable._annenforceargs_ = (None, int)
 
 def clear_large_memory_chunk_aligned(addr, map_size):
 addr = rffi.cast(PTR, addr)
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: Improve error message when attempting to modify annotations in a fixed graph

2016-09-01 Thread rlamy
Author: Ronan Lamy 
Branch: 
Changeset: r86823:30767c452330
Date: 2016-09-01 18:39 +0100
http://bitbucket.org/pypy/pypy/changeset/30767c452330/

Log:Improve error message when attempting to modify annotations in a
fixed graph

diff --git a/rpython/annotator/annrpython.py b/rpython/annotator/annrpython.py
--- a/rpython/annotator/annrpython.py
+++ b/rpython/annotator/annrpython.py
@@ -164,8 +164,13 @@
 # annotations that are passed in, and don't annotate the old
 # graph -- it's already low-level operations!
 for a, s_newarg in zip(block.inputargs, cells):
-s_oldarg = self.binding(a)
-assert annmodel.unionof(s_oldarg, s_newarg) == s_oldarg
+s_oldarg = a.annotation
+if not s_oldarg.contains(s_newarg):
+raise annmodel.AnnotatorError(
+"Late-stage annotation is not allowed to modify the "
+"existing annotation for variable %s: %s" %
+(a, s_oldarg))
+
 else:
 assert not self.frozen
 if block not in self.annotated:
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy redirect-assembler-jitlog: translation issue, assigning unique number to tmp_callback jit cell token

2016-09-01 Thread plan_rich
Author: Richard Plangger 
Branch: redirect-assembler-jitlog
Changeset: r86824:cd97133d768d
Date: 2016-09-01 21:18 +0200
http://bitbucket.org/pypy/pypy/changeset/cd97133d768d/

Log:translation issue, assigning unique number to tmp_callback jit cell
token

diff --git a/rpython/jit/backend/x86/assembler.py 
b/rpython/jit/backend/x86/assembler.py
--- a/rpython/jit/backend/x86/assembler.py
+++ b/rpython/jit/backend/x86/assembler.py
@@ -540,9 +540,9 @@
 looptoken._x86_ops_offset = ops_offset
 looptoken._ll_function_addr = rawstart + functionpos
 
-if logger:
-log = logger.log_trace(jl.MARK_TRACE_ASM, None, self.mc)
-log.write(inputargs, operations, ops_offset=ops_offset)
+if log and logger:
+l = logger.log_trace(jl.MARK_TRACE_ASM, None, self.mc)
+l.write(inputargs, operations, ops_offset=ops_offset)
 
 # legacy
 if logger.logger_ops:
diff --git a/rpython/jit/metainterp/compile.py 
b/rpython/jit/metainterp/compile.py
--- a/rpython/jit/metainterp/compile.py
+++ b/rpython/jit/metainterp/compile.py
@@ -1122,6 +1122,11 @@
 version of the code may end up replacing it.
 """
 jitcell_token = make_jitcell_token(jitdriver_sd)
+#
+logger = jitdriver_sd.metainterp_sd.jitlog
+jitcell_token.number = logger.next_id()
+jl.tmp_callback(jitcell_token)
+#
 nb_red_args = jitdriver_sd.num_red_args
 assert len(redargtypes) == nb_red_args
 inputargs = []
@@ -1158,8 +1163,6 @@
 operations = get_deep_immutable_oplist(operations)
 cpu.compile_loop(inputargs, operations, jitcell_token, log=False)
 
-jl.tmp_callback(looptoken)
-
 if memory_manager is not None:# for tests
 memory_manager.keep_loop_alive(jitcell_token)
 return jitcell_token
diff --git a/rpython/rlib/rjitlog/rjitlog.py b/rpython/rlib/rjitlog/rjitlog.py
--- a/rpython/rlib/rjitlog/rjitlog.py
+++ b/rpython/rlib/rjitlog/rjitlog.py
@@ -350,6 +350,10 @@
 def finish(self):
 jitlog_teardown()
 
+def next_id(self):
+self.trace_id += 1
+return self.trace_id
+
 def start_new_trace(self, metainterp_sd, faildescr=None, 
entry_bridge=False, jd_name=""):
 # even if the logger is not enabled, increment the trace id
 self.trace_id += 1
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy.org extradoc: update the values

2016-09-01 Thread arigo
Author: Armin Rigo 
Branch: extradoc
Changeset: r784:8cea640f2073
Date: 2016-09-01 23:45 +0200
http://bitbucket.org/pypy/pypy.org/changeset/8cea640f2073/

Log:update the values

diff --git a/don1.html b/don1.html
--- a/don1.html
+++ b/don1.html
@@ -9,13 +9,13 @@
 
   $(function() {
 $("#progressbar").progressbar({
-  value: 61.8
+  value: 61.9
});
   });
 
 

-   $64931 of $105000 (61.8%)
+   $64959 of $105000 (61.9%)


 
@@ -23,7 +23,7 @@
   
   This donation goes towards supporting Python 3 in 
PyPy.
   Current status:
-we have $5400 left
+we have $5426 left
   in the account. Read proposal
   
   
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: Fix translation and add a warning in annmodel.unionof

2016-09-01 Thread rlamy
Author: Ronan Lamy 
Branch: 
Changeset: r86825:82980a978280
Date: 2016-09-01 23:02 +0100
http://bitbucket.org/pypy/pypy/changeset/82980a978280/

Log:Fix translation and add a warning in annmodel.unionof

diff --git a/rpython/annotator/annrpython.py b/rpython/annotator/annrpython.py
--- a/rpython/annotator/annrpython.py
+++ b/rpython/annotator/annrpython.py
@@ -165,7 +165,9 @@
 # graph -- it's already low-level operations!
 for a, s_newarg in zip(block.inputargs, cells):
 s_oldarg = a.annotation
-if not s_oldarg.contains(s_newarg):
+# XXX: Should use s_oldarg.contains(s_newarg) but that breaks
+# PyPy translation
+if annmodel.unionof(s_oldarg, s_newarg) != s_oldarg:
 raise annmodel.AnnotatorError(
 "Late-stage annotation is not allowed to modify the "
 "existing annotation for variable %s: %s" %
diff --git a/rpython/annotator/model.py b/rpython/annotator/model.py
--- a/rpython/annotator/model.py
+++ b/rpython/annotator/model.py
@@ -750,6 +750,7 @@
 s1 = pair(s1, s2).union()
 else:
 # this is just a performance shortcut
+# XXX: This is a lie! Grep for no_side_effects_in_union and weep.
 if s1 != s2:
 s1 = pair(s1, s2).union()
 return s1
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy force-virtual-state: Merge

2016-09-01 Thread sbauman
Author: Spenser Andrew Bauman 
Branch: force-virtual-state
Changeset: r86826:5649730037a2
Date: 2016-09-01 15:17 -0400
http://bitbucket.org/pypy/pypy/changeset/5649730037a2/

Log:Merge

diff too long, truncating to 2000 out of 213792 lines

diff --git a/.hgtags b/.hgtags
--- a/.hgtags
+++ b/.hgtags
@@ -27,3 +27,6 @@
 40497617ae91caa1a394d8be6f9cd2de31cb0628 release-pypy3.3-v5.2
 c09c19272c990a0611b17569a0085ad1ab00c8ff release-pypy2.7-v5.3
 7e8df3df96417c16c2d55b41352ec82c9c69c978 release-pypy2.7-v5.3.1
+68bb3510d8212ae9efb687e12e58c09d29e74f87 release-pypy2.7-v5.4.0
+68bb3510d8212ae9efb687e12e58c09d29e74f87 release-pypy2.7-v5.4.0
+77392ad263504df011ccfcabf6a62e21d04086d0 release-pypy2.7-v5.4.0
diff --git a/LICENSE b/LICENSE
--- a/LICENSE
+++ b/LICENSE
@@ -74,6 +74,7 @@
   Seo Sanghyeon
   Ronny Pfannschmidt
   Justin Peel
+  Raffael Tfirst
   David Edelsohn
   Anders Hammarquist
   Jakub Gustak
@@ -117,7 +118,6 @@
   Wenzhu Man
   John Witulski
   Laurence Tratt
-  Raffael Tfirst
   Ivan Sichmann Freitas
   Greg Price
   Dario Bertini
@@ -141,6 +141,7 @@
   tav
   Taavi Burns
   Georg Brandl
+  Nicolas Truessel
   Bert Freudenberg
   Stian Andreassen
   Wanja Saatkamp
@@ -211,6 +212,7 @@
   Vaibhav Sood
   Alan McIntyre
   Alexander Sedov
+  p_ziesch...@yahoo.de
   Attila Gobi
   Jasper.Schulz
   Christopher Pope
@@ -221,6 +223,7 @@
   Arjun Naik
   Valentina Mukhamedzhanova
   Stefano Parmesan
+  touilleMan
   Alexis Daboville
   Jens-Uwe Mager
   Carl Meyer
@@ -229,12 +232,14 @@
   Gabriel
   Lukas Vacek
   Kunal Grover
+  Aaron Gallagher
   Andrew Dalke
   Sylvain Thenault
   Jakub Stasiak
   Nathan Taylor
   Vladimir Kryachko
   Omer Katz
+  Mark Williams
   Jacek Generowicz
   Alejandro J. Cura
   Jacob Oscarson
@@ -355,115 +360,12 @@
   yasirs
   Michael Chermside
   Anna Ravencroft
+  pizi
   Andrey Churin
   Dan Crosta
+  Eli Stevens
   Tobias Diaz
   Julien Phalip
   Roman Podoliaka
   Dan Loewenherz
-
-  Heinrich-Heine University, Germany 
-  Open End AB (formerly AB Strakt), Sweden
-  merlinux GmbH, Germany 
-  tismerysoft GmbH, Germany 
-  Logilab Paris, France 
-  DFKI GmbH, Germany 
-  Impara, Germany
-  Change Maker, Sweden 
-  University of California Berkeley, USA
-  Google Inc.
-  King's College London
-
-The PyPy Logo as used by http://speed.pypy.org and others was created
-by Samuel Reis and is distributed on terms of Creative Commons Share Alike
-License.
- 
-License for 'lib-python/2.7'
-
-
-Except when otherwise stated (look for LICENSE files or copyright/license
-information at the beginning of each file) the files in the 'lib-python/2.7'
-directory are all copyrighted by the Python Software Foundation and licensed
-under the terms that you can find here: https://docs.python.org/2/license.html
-
-License for 'pypy/module/unicodedata/'
-==
-
-The following files are from the website of The Unicode Consortium
-at http://www.unicode.org/.  For the terms of use of these files, see
-http://www.unicode.org/terms_of_use.html .  Or they are derived from
-files from the above website, and the same terms of use apply.
-
-CompositionExclusions-*.txt
-EastAsianWidth-*.txt
-LineBreak-*.txt
-UnicodeData-*.txt
-UnihanNumeric-*.txt
-
-License for 'dotviewer/font/'
-=
-
-Copyright (C) 2008 The Android Open Source Project
-
-Licensed under the Apache License, Version 2.0 (the "License");
-you may not use this file except in compliance with the License.
-You may obtain a copy of the License at
-  
- http://www.apache.org/licenses/LICENSE-2.0
-  
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
-
-Detailed license information is contained in the NOTICE file in the
-directory.
-
-
-Licenses and Acknowledgements for Incorporated Software
-===
-
-This section is an incomplete, but growing list of licenses and
-acknowledgements for third-party software incorporated in the PyPy
-distribution.
-
-License for 'Tcl/Tk'
-
-
-This copy of PyPy contains library code that may, when used, result in
-the Tcl/Tk library to be loaded.  PyPy also includes code that may be
-regarded as being a copy of some parts of the Tcl/Tk header files.
-You may see a copy of the License for Tcl/Tk in the file
-`lib_pypy/_tkinter/license.terms` included here.
-
-License for 'bzip2'

-
-This copy of PyPy may be linked (dynamically or statically) with the
-bzip2 library.  You may see a copy of the License for bzip2/libbzip2 at
-
-http://www.bzip.org/1.0.5/bzip2-manual-1.0.5.html
-
-License for 'openssl'
--
-
-This copy of PyPy may be linked (dyna

[pypy-commit] pypy release-5.x: Bump recursionlimit, for translating with cpython

2016-09-01 Thread stefanor
Author: Stefano Rivera 
Branch: release-5.x
Changeset: r86830:a5db0f4359ab
Date: 2016-09-01 20:35 -0700
http://bitbucket.org/pypy/pypy/changeset/a5db0f4359ab/

Log:Bump recursionlimit, for translating with cpython

diff --git a/rpython/translator/goal/translate.py 
b/rpython/translator/goal/translate.py
--- a/rpython/translator/goal/translate.py
+++ b/rpython/translator/goal/translate.py
@@ -213,6 +213,7 @@
 log.WARNING(warning)
 
 def main():
+sys.setrecursionlimit(2000)  # PyPy can't translate within cpython's 1k 
limit
 targetspec_dic, translateconfig, config, args = 
parse_options_and_load_target()
 from rpython.translator import translator
 from rpython.translator import driver
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy release-5.x: Avoid blowing up with results that are ~0 but <0 due to floating point imprecision

2016-09-01 Thread stefanor
Author: Stefano Rivera 
Branch: release-5.x
Changeset: r86831:5169ca3e696d
Date: 2016-09-01 20:35 -0700
http://bitbucket.org/pypy/pypy/changeset/5169ca3e696d/

Log:Avoid blowing up with results that are ~0 but <0 due to floating
point imprecision

diff --git a/rpython/translator/backendopt/inline.py 
b/rpython/translator/backendopt/inline.py
--- a/rpython/translator/backendopt/inline.py
+++ b/rpython/translator/backendopt/inline.py
@@ -532,8 +532,7 @@
 return sys.maxint
 else:
 res = Solution[blockmap[graph.startblock]]
-assert res >= 0
-return res
+return max(res, 0.0)
 
 def static_instruction_count(graph):
 count = 0
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy release-5.x: haaaack on top of previous hacks

2016-09-01 Thread arigo
Author: Armin Rigo 
Branch: release-5.x
Changeset: r86827:12bd393e0411
Date: 2016-09-01 20:35 -0700
http://bitbucket.org/pypy/pypy/changeset/12bd393e0411/

Log:hck on top of previous hacks

diff --git a/rpython/rlib/rdynload.py b/rpython/rlib/rdynload.py
--- a/rpython/rlib/rdynload.py
+++ b/rpython/rlib/rdynload.py
@@ -98,8 +98,15 @@
 try:
 ctypes.CDLL(name)
 except OSError as e:
+# common case: ctypes fails too, with the real dlerror()
+# message in str(e).  Return that error message.
 return str(e)
 else:
+# uncommon case: may happen if 'name' is a linker script
+# (which the C-level dlopen() can't handle) and we are
+# directly running on pypy (whose implementation of ctypes
+# or cffi will resolve linker scripts).  In that case, 
+# unsure what we can do.
 return ("opening %r with ctypes.CDLL() works, "
 "but not with c_dlopen()??" % (name,))
 
@@ -160,6 +167,13 @@
 mode = _dlopen_default_mode()
 elif (mode & (RTLD_LAZY | RTLD_NOW)) == 0:
 mode |= RTLD_NOW
+#
+# hck for 'pypy py.test -A' if libm.so is a linker script
+# (see reason in _dlerror_on_dlopen_untranslated())
+if not we_are_translated() and platform.name == "linux":
+if rffi.charp2str(name) == 'libm.so':
+name = rffi.str2charp('libm.so.6', track_allocation=False)
+#
 res = c_dlopen(name, rffi.cast(rffi.INT, mode))
 if not res:
 if not we_are_translated():
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy release-5.x: name can be None

2016-09-01 Thread stefanor
Author: Stefano Rivera 
Branch: release-5.x
Changeset: r86828:3806b361cac3
Date: 2016-09-01 20:35 -0700
http://bitbucket.org/pypy/pypy/changeset/3806b361cac3/

Log:name can be None

diff --git a/rpython/rlib/rdynload.py b/rpython/rlib/rdynload.py
--- a/rpython/rlib/rdynload.py
+++ b/rpython/rlib/rdynload.py
@@ -171,7 +171,7 @@
 # hck for 'pypy py.test -A' if libm.so is a linker script
 # (see reason in _dlerror_on_dlopen_untranslated())
 if not we_are_translated() and platform.name == "linux":
-if rffi.charp2str(name) == 'libm.so':
+if name and rffi.charp2str(name) == 'libm.so':
 name = rffi.str2charp('libm.so.6', track_allocation=False)
 #
 res = c_dlopen(name, rffi.cast(rffi.INT, mode))
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy release-5.x: Add a failing (skipped) whitebox test and a test about ctypes that fails

2016-09-01 Thread arigo
Author: Armin Rigo 
Branch: release-5.x
Changeset: r86829:2cab10de65ad
Date: 2016-09-01 20:35 -0700
http://bitbucket.org/pypy/pypy/changeset/2cab10de65ad/

Log:Add a failing (skipped) whitebox test and a test about ctypes that
fails on -A (xfailed)

diff --git a/pypy/module/test_lib_pypy/ctypes_tests/test_numbers.py 
b/pypy/module/test_lib_pypy/ctypes_tests/test_numbers.py
--- a/pypy/module/test_lib_pypy/ctypes_tests/test_numbers.py
+++ b/pypy/module/test_lib_pypy/ctypes_tests/test_numbers.py
@@ -195,6 +195,29 @@
 _fields_ = [('t', enum)]
 assert isinstance(S().t, enum)
 
+def test_no_missing_shape_to_ffi_type(self):
+# whitebox test
+import sys
+if '__pypy__' not in sys.builtin_module_names:
+skip("only for pypy's ctypes")
+skip("re-enable after adding 'g' to _shape_to_ffi_type.typemap, "
+ "which I think needs fighting all the way up from "
+ "rpython.rlib.libffi")
+from _ctypes.basics import _shape_to_ffi_type
+from _rawffi import Array
+for i in range(1, 256):
+try:
+Array(chr(i))
+except ValueError:
+pass
+else:
+assert chr(i) in _shape_to_ffi_type.typemap
+
+@py.test.mark.xfail
+def test_pointer_to_long_double(self):
+import ctypes
+ctypes.POINTER(ctypes.c_longdouble)
+
 ##def test_perf(self):
 ##check_perf()
 
diff --git a/rpython/rlib/libffi.py b/rpython/rlib/libffi.py
--- a/rpython/rlib/libffi.py
+++ b/rpython/rlib/libffi.py
@@ -47,6 +47,8 @@
 cls.ulonglong = clibffi.cast_type_to_ffitype(rffi.ULONGLONG)
 cls.signed = clibffi.cast_type_to_ffitype(rffi.SIGNED)
 cls.wchar_t = clibffi.cast_type_to_ffitype(lltype.UniChar)
+# XXX long double support: clibffi.ffi_type_longdouble, but then
+# XXX fix the whole rest of this file to add a case for long double
 del cls._import
 
 @staticmethod
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy release-5.x: pfff another hack on top of this pile of hacks

2016-09-01 Thread mattip
Author: Matti Picus 
Branch: release-5.x
Changeset: r86832:3e411b32904e
Date: 2016-09-02 08:10 +0300
http://bitbucket.org/pypy/pypy/changeset/3e411b32904e/

Log:pfff another hack on top of this pile of hacks (grafted from
76e37b5f30ae446c64388d1d7cd2d2f01999621e)

diff --git a/rpython/rlib/rdynload.py b/rpython/rlib/rdynload.py
--- a/rpython/rlib/rdynload.py
+++ b/rpython/rlib/rdynload.py
@@ -170,11 +170,15 @@
 #
 # hck for 'pypy py.test -A' if libm.so is a linker script
 # (see reason in _dlerror_on_dlopen_untranslated())
+must_free = False
 if not we_are_translated() and platform.name == "linux":
 if name and rffi.charp2str(name) == 'libm.so':
-name = rffi.str2charp('libm.so.6', track_allocation=False)
+name = rffi.str2charp('libm.so.6')
+must_free = True
 #
 res = c_dlopen(name, rffi.cast(rffi.INT, mode))
+if must_free:
+rffi.free_charp(name)
 if not res:
 if not we_are_translated():
 err = _dlerror_on_dlopen_untranslated(name)
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy release-5.x: fix b127faf95f86 which updated contributors but removed the rest of LICENSE

2016-09-01 Thread mattip
Author: Matti Picus 
Branch: release-5.x
Changeset: r86834:d68da509772b
Date: 2016-09-02 08:43 +0300
http://bitbucket.org/pypy/pypy/changeset/d68da509772b/

Log:fix b127faf95f86 which updated contributors but removed the rest of
LICENSE (grafted from d6a8fc8b6b278362d6a4c7602135354b91ac2e9a)

diff --git a/LICENSE b/LICENSE
--- a/LICENSE
+++ b/LICENSE
@@ -369,3 +369,109 @@
   Roman Podoliaka
   Dan Loewenherz
   werat
+
+  Heinrich-Heine University, Germany 
+  Open End AB (formerly AB Strakt), Sweden
+  merlinux GmbH, Germany 
+  tismerysoft GmbH, Germany 
+  Logilab Paris, France 
+  DFKI GmbH, Germany 
+  Impara, Germany
+  Change Maker, Sweden 
+  University of California Berkeley, USA
+  Google Inc.
+  King's College London
+
+The PyPy Logo as used by http://speed.pypy.org and others was created
+by Samuel Reis and is distributed on terms of Creative Commons Share Alike
+License.
+ 
+License for 'lib-python/2.7'
+
+
+Except when otherwise stated (look for LICENSE files or copyright/license
+information at the beginning of each file) the files in the 'lib-python/2.7'
+directory are all copyrighted by the Python Software Foundation and licensed
+under the terms that you can find here: https://docs.python.org/2/license.html
+
+License for 'pypy/module/unicodedata/'
+==
+
+The following files are from the website of The Unicode Consortium
+at http://www.unicode.org/.  For the terms of use of these files, see
+http://www.unicode.org/terms_of_use.html .  Or they are derived from
+files from the above website, and the same terms of use apply.
+
+CompositionExclusions-*.txt
+EastAsianWidth-*.txt
+LineBreak-*.txt
+UnicodeData-*.txt
+UnihanNumeric-*.txt
+
+License for 'dotviewer/font/'
+=
+
+Copyright (C) 2008 The Android Open Source Project
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+  
+ http://www.apache.org/licenses/LICENSE-2.0
+  
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+
+Detailed license information is contained in the NOTICE file in the
+directory.
+
+
+Licenses and Acknowledgements for Incorporated Software
+===
+
+This section is an incomplete, but growing list of licenses and
+acknowledgements for third-party software incorporated in the PyPy
+distribution.
+
+License for 'Tcl/Tk'
+
+
+This copy of PyPy contains library code that may, when used, result in
+the Tcl/Tk library to be loaded.  PyPy also includes code that may be
+regarded as being a copy of some parts of the Tcl/Tk header files.
+You may see a copy of the License for Tcl/Tk in the file
+`lib_pypy/_tkinter/license.terms` included here.
+
+License for 'bzip2'
+---
+
+This copy of PyPy may be linked (dynamically or statically) with the
+bzip2 library.  You may see a copy of the License for bzip2/libbzip2 at
+
+http://www.bzip.org/1.0.5/bzip2-manual-1.0.5.html
+
+License for 'openssl'
+-
+
+This copy of PyPy may be linked (dynamically or statically) with the
+openssl library.  You may see a copy of the License for OpenSSL at
+
+https://www.openssl.org/source/license.html
+
+License for 'gdbm'
+--
+
+The gdbm module includes code from gdbm.h, which is distributed under
+the terms of the GPL license version 2 or any later version.  Thus the
+gdbm module, provided in the file lib_pypy/gdbm.py, is redistributed
+under the terms of the GPL license as well.
+
+License for 'rpython/rlib/rvmprof/src'
+--
+
+The code is based on gperftools. You may see a copy of the License for it at
+
+https://github.com/gperftools/gperftools/blob/master/COPYING
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: fix b127faf95f86 which updated contributors but removed the rest of LICENSE

2016-09-01 Thread mattip
Author: Matti Picus 
Branch: 
Changeset: r86833:d6a8fc8b6b27
Date: 2016-09-02 08:42 +0300
http://bitbucket.org/pypy/pypy/changeset/d6a8fc8b6b27/

Log:fix b127faf95f86 which updated contributors but removed the rest of
LICENSE

diff --git a/LICENSE b/LICENSE
--- a/LICENSE
+++ b/LICENSE
@@ -369,3 +369,109 @@
   Roman Podoliaka
   Dan Loewenherz
   werat
+
+  Heinrich-Heine University, Germany 
+  Open End AB (formerly AB Strakt), Sweden
+  merlinux GmbH, Germany 
+  tismerysoft GmbH, Germany 
+  Logilab Paris, France 
+  DFKI GmbH, Germany 
+  Impara, Germany
+  Change Maker, Sweden 
+  University of California Berkeley, USA
+  Google Inc.
+  King's College London
+
+The PyPy Logo as used by http://speed.pypy.org and others was created
+by Samuel Reis and is distributed on terms of Creative Commons Share Alike
+License.
+ 
+License for 'lib-python/2.7'
+
+
+Except when otherwise stated (look for LICENSE files or copyright/license
+information at the beginning of each file) the files in the 'lib-python/2.7'
+directory are all copyrighted by the Python Software Foundation and licensed
+under the terms that you can find here: https://docs.python.org/2/license.html
+
+License for 'pypy/module/unicodedata/'
+==
+
+The following files are from the website of The Unicode Consortium
+at http://www.unicode.org/.  For the terms of use of these files, see
+http://www.unicode.org/terms_of_use.html .  Or they are derived from
+files from the above website, and the same terms of use apply.
+
+CompositionExclusions-*.txt
+EastAsianWidth-*.txt
+LineBreak-*.txt
+UnicodeData-*.txt
+UnihanNumeric-*.txt
+
+License for 'dotviewer/font/'
+=
+
+Copyright (C) 2008 The Android Open Source Project
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+  
+ http://www.apache.org/licenses/LICENSE-2.0
+  
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+
+Detailed license information is contained in the NOTICE file in the
+directory.
+
+
+Licenses and Acknowledgements for Incorporated Software
+===
+
+This section is an incomplete, but growing list of licenses and
+acknowledgements for third-party software incorporated in the PyPy
+distribution.
+
+License for 'Tcl/Tk'
+
+
+This copy of PyPy contains library code that may, when used, result in
+the Tcl/Tk library to be loaded.  PyPy also includes code that may be
+regarded as being a copy of some parts of the Tcl/Tk header files.
+You may see a copy of the License for Tcl/Tk in the file
+`lib_pypy/_tkinter/license.terms` included here.
+
+License for 'bzip2'
+---
+
+This copy of PyPy may be linked (dynamically or statically) with the
+bzip2 library.  You may see a copy of the License for bzip2/libbzip2 at
+
+http://www.bzip.org/1.0.5/bzip2-manual-1.0.5.html
+
+License for 'openssl'
+-
+
+This copy of PyPy may be linked (dynamically or statically) with the
+openssl library.  You may see a copy of the License for OpenSSL at
+
+https://www.openssl.org/source/license.html
+
+License for 'gdbm'
+--
+
+The gdbm module includes code from gdbm.h, which is distributed under
+the terms of the GPL license version 2 or any later version.  Thus the
+gdbm module, provided in the file lib_pypy/gdbm.py, is redistributed
+under the terms of the GPL license as well.
+
+License for 'rpython/rlib/rvmprof/src'
+--
+
+The code is based on gperftools. You may see a copy of the License for it at
+
+https://github.com/gperftools/gperftools/blob/master/COPYING
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy buffer-interface: fix micronumpy test_zjit by adding _attrs_ to the class

2016-09-01 Thread mattip
Author: Matti Picus 
Branch: buffer-interface
Changeset: r86835:6cebc47b780b
Date: 2016-09-02 09:47 +0300
http://bitbucket.org/pypy/pypy/changeset/6cebc47b780b/

Log:fix micronumpy test_zjit by adding _attrs_ to the class

diff --git a/pypy/objspace/std/memoryobject.py 
b/pypy/objspace/std/memoryobject.py
--- a/pypy/objspace/std/memoryobject.py
+++ b/pypy/objspace/std/memoryobject.py
@@ -14,6 +14,7 @@
 """Implement the built-in 'memoryview' type as a wrapper around
 an interp-level buffer.
 """
+_attrs_ = ['buf']
 
 def __init__(self, buf):
 assert isinstance(buf, Buffer)
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy buffer-interface: merge default into branch

2016-09-01 Thread mattip
Author: Matti Picus 
Branch: buffer-interface
Changeset: r86836:802bf4e38a0d
Date: 2016-09-02 09:48 +0300
http://bitbucket.org/pypy/pypy/changeset/802bf4e38a0d/

Log:merge default into branch

diff too long, truncating to 2000 out of 210666 lines

diff --git a/.hgtags b/.hgtags
--- a/.hgtags
+++ b/.hgtags
@@ -27,3 +27,6 @@
 40497617ae91caa1a394d8be6f9cd2de31cb0628 release-pypy3.3-v5.2
 c09c19272c990a0611b17569a0085ad1ab00c8ff release-pypy2.7-v5.3
 7e8df3df96417c16c2d55b41352ec82c9c69c978 release-pypy2.7-v5.3.1
+68bb3510d8212ae9efb687e12e58c09d29e74f87 release-pypy2.7-v5.4.0
+68bb3510d8212ae9efb687e12e58c09d29e74f87 release-pypy2.7-v5.4.0
+77392ad263504df011ccfcabf6a62e21d04086d0 release-pypy2.7-v5.4.0
diff --git a/LICENSE b/LICENSE
--- a/LICENSE
+++ b/LICENSE
@@ -74,6 +74,7 @@
   Seo Sanghyeon
   Ronny Pfannschmidt
   Justin Peel
+  Raffael Tfirst
   David Edelsohn
   Anders Hammarquist
   Jakub Gustak
@@ -117,7 +118,6 @@
   Wenzhu Man
   John Witulski
   Laurence Tratt
-  Raffael Tfirst
   Ivan Sichmann Freitas
   Greg Price
   Dario Bertini
@@ -141,6 +141,7 @@
   tav
   Taavi Burns
   Georg Brandl
+  Nicolas Truessel
   Bert Freudenberg
   Stian Andreassen
   Wanja Saatkamp
@@ -211,6 +212,7 @@
   Vaibhav Sood
   Alan McIntyre
   Alexander Sedov
+  p_ziesch...@yahoo.de
   Attila Gobi
   Jasper.Schulz
   Christopher Pope
@@ -221,6 +223,7 @@
   Arjun Naik
   Valentina Mukhamedzhanova
   Stefano Parmesan
+  touilleMan
   Alexis Daboville
   Jens-Uwe Mager
   Carl Meyer
@@ -229,12 +232,14 @@
   Gabriel
   Lukas Vacek
   Kunal Grover
+  Aaron Gallagher
   Andrew Dalke
   Sylvain Thenault
   Jakub Stasiak
   Nathan Taylor
   Vladimir Kryachko
   Omer Katz
+  Mark Williams
   Jacek Generowicz
   Alejandro J. Cura
   Jacob Oscarson
@@ -355,12 +360,15 @@
   yasirs
   Michael Chermside
   Anna Ravencroft
+  pizi
   Andrey Churin
   Dan Crosta
+  Eli Stevens
   Tobias Diaz
   Julien Phalip
   Roman Podoliaka
   Dan Loewenherz
+  werat
 
   Heinrich-Heine University, Germany 
   Open End AB (formerly AB Strakt), Sweden
diff --git a/_pytest/python.py b/_pytest/python.py
--- a/_pytest/python.py
+++ b/_pytest/python.py
@@ -498,7 +498,10 @@
 """ Collector for test methods. """
 def collect(self):
 if hasinit(self.obj):
-pytest.skip("class %s.%s with __init__ won't get collected" % (
+# XXX used to be skip(), but silently skipping classes
+# XXX just because they have been written long ago is
+# XXX imho a very, very, very bad idea
+pytest.fail("class %s.%s with __init__ won't get collected" % (
 self.obj.__module__,
 self.obj.__name__,
 ))
diff --git a/lib-python/2.7/distutils/sysconfig_pypy.py 
b/lib-python/2.7/distutils/sysconfig_pypy.py
--- a/lib-python/2.7/distutils/sysconfig_pypy.py
+++ b/lib-python/2.7/distutils/sysconfig_pypy.py
@@ -122,22 +122,24 @@
 """Dummy method to let some easy_install packages that have
 optional C speedup components.
 """
+def customize(executable, flags):
+command = compiler.executables[executable] + flags
+setattr(compiler, executable, command)
+
 if compiler.compiler_type == "unix":
 compiler.compiler_so.extend(['-O2', '-fPIC', '-Wimplicit'])
 compiler.shared_lib_extension = get_config_var('SO')
 if "CPPFLAGS" in os.environ:
 cppflags = shlex.split(os.environ["CPPFLAGS"])
-compiler.compiler.extend(cppflags)
-compiler.compiler_so.extend(cppflags)
-compiler.linker_so.extend(cppflags)
+for executable in ('compiler', 'compiler_so', 'linker_so'):
+customize(executable, cppflags)
 if "CFLAGS" in os.environ:
 cflags = shlex.split(os.environ["CFLAGS"])
-compiler.compiler.extend(cflags)
-compiler.compiler_so.extend(cflags)
-compiler.linker_so.extend(cflags)
+for executable in ('compiler', 'compiler_so', 'linker_so'):
+customize(executable, cflags)
 if "LDFLAGS" in os.environ:
 ldflags = shlex.split(os.environ["LDFLAGS"])
-compiler.linker_so.extend(ldflags)
+customize('linker_so', ldflags)
 
 
 from sysconfig_cpython import (
diff --git a/lib_pypy/_ctypes/function.py b/lib_pypy/_ctypes/function.py
--- a/lib_pypy/_ctypes/function.py
+++ b/lib_pypy/_ctypes/function.py
@@ -342,7 +342,7 @@
 thisarg = cast(thisvalue, POINTER(POINTER(c_void_p)))
 keepalives, newargs, argtypes, outargs, errcheckargs = (
 self._convert_args(argtypes, args[1:], kwargs))
-newargs.insert(0, thisvalue.value)
+newargs.insert(0, thisarg)
 argtypes.insert(0, c_void_p)
 else:
 thisarg = None
diff --git a/pypy/doc/contributor.rst b/pypy/doc/contributor.rst
--- a/pypy/doc/contributor.rst
+++ b/pypy/doc/contributor.rst
@@ -44,6 +44,7 @@
   Seo Sanghyeon