[pypy-commit] pypy default: fix translation (why does the same code work on py3.6?)

2020-02-08 Thread cfbolz
Author: Carl Friedrich Bolz-Tereick 
Branch: 
Changeset: r98686:57362e78ee31
Date: 2020-02-08 13:31 +0100
http://bitbucket.org/pypy/pypy/changeset/57362e78ee31/

Log:fix translation (why does the same code work on py3.6?)

diff --git a/pypy/objspace/std/unicodeobject.py 
b/pypy/objspace/std/unicodeobject.py
--- a/pypy/objspace/std/unicodeobject.py
+++ b/pypy/objspace/std/unicodeobject.py
@@ -131,7 +131,7 @@
 
 def listview_ascii(self):
 if self.is_ascii():
-return list(self._utf8)
+return _create_list_from_unicode(self._utf8)
 return None
 
 def ord(self, space):
@@ -1808,6 +1808,10 @@
 )
 W_UnicodeObject.typedef.flag_sequence_bug_compat = True
 
+def _create_list_from_unicode(value):
+# need this helper function to allow the jit to look inside and inline
+# listview_ascii
+return [s for s in value]
 
 W_UnicodeObject.EMPTY = W_UnicodeObject('', 0)
 
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: fix failing win32 test

2020-02-02 Thread mattip
Author: Matti Picus 
Branch: 
Changeset: r98629:c14832883def
Date: 2020-01-31 12:11 +0200
http://bitbucket.org/pypy/pypy/changeset/c14832883def/

Log:fix failing win32 test

diff --git a/pypy/module/posix/test/test_posix2.py 
b/pypy/module/posix/test/test_posix2.py
--- a/pypy/module/posix/test/test_posix2.py
+++ b/pypy/module/posix/test/test_posix2.py
@@ -615,10 +615,10 @@
 def test__getfullpathname(self):
 # nt specific
 posix = self.posix
-sysdrv = posix.getenv("SystemDrive", "C:")
+sysdrv = posix.environ.get("SystemDrive", "C:")
 # just see if it does anything
 path = sysdrv + 'hubber'
-assert posix.sep in posix._getfullpathname(path)
+assert '\\' in posix._getfullpathname(path)
 
 def test_utime(self):
 os = self.posix
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: fix curses tests and make sure ffi.string returns str for python3

2020-01-26 Thread mattip
Author: Matti Picus 
Branch: 
Changeset: r98585:cad029326210
Date: 2020-01-26 08:36 +0200
http://bitbucket.org/pypy/pypy/changeset/cad029326210/

Log:fix curses tests and make sure ffi.string returns str for python3

diff --git a/lib-python/2.7/test/test_curses.py 
b/lib-python/2.7/test/test_curses.py
--- a/lib-python/2.7/test/test_curses.py
+++ b/lib-python/2.7/test/test_curses.py
@@ -15,7 +15,8 @@
 import tempfile
 import unittest
 
-from test.test_support import requires, import_module, verbose, run_unittest
+from test.test_support import (requires, import_module, verbose, run_unittest,
+cpython_only)
 
 # Optionally test curses module.  This currently requires that the
 # 'curses' resource be given on the regrtest command line using the -u
@@ -276,6 +277,7 @@
msg='userptr should fail since not set'):
 p.userptr()
 
+@cpython_only
 def test_userptr_memory_leak(self):
 w = curses.newwin(10, 10)
 p = curses.panel.new_panel(w)
@@ -288,6 +290,7 @@
 self.assertEqual(sys.getrefcount(obj), nrefs,
  "set_userptr leaked references")
 
+@cpython_only
 def test_userptr_segfault(self):
 panel = curses.panel.new_panel(self.stdscr)
 class A:
diff --git a/lib_pypy/_curses.py b/lib_pypy/_curses.py
--- a/lib_pypy/_curses.py
+++ b/lib_pypy/_curses.py
@@ -57,7 +57,7 @@
 if key_n == b"UNKNOWN KEY":
 continue
 if not isinstance(key_n, str):   # python 3
-key_n = key_n.decode()
+key_n = key_n.decode('utf-8')
 key_n = key_n.replace('(', '').replace(')', '')
 globals()[key_n] = key
 
@@ -83,7 +83,9 @@
 
 
 def _ensure_initialised_color():
-if not _initialised and _initialised_color:
+if not _initialised:
+raise error("must call initscr() first")
+if not _initialised_color:
 raise error("must call start_color() first")
 
 
@@ -420,11 +422,16 @@
 val = lib.keyname(val)
 if val == ffi.NULL:
 return ""
-return ffi.string(val)
+key_n = ffi.string(val)
+if not isinstance(key_n, str):
+key_n = key_n.decode('utf-8')
+return key_n
 
 @_argspec(0, 1, 2)
 def getstr(self, y, x, n=1023):
 n = min(n, 1023)
+if n < 0:
+raise ValueError("'n' must be nonnegative")
 buf = ffi.new("char[1024]")  # /* This should be big enough.. I hope */
 
 if y is None:
@@ -467,6 +474,8 @@
 @_argspec(0, 1, 2)
 def instr(self, y, x, n=1023):
 n = min(n, 1023)
+if n < 0:
+raise ValueError("'n' must be nonnegative")
 buf = ffi.new("char[1024]")  # /* This should be big enough.. I hope */
 if y is None:
 code = lib.winnstr(self._win, buf, n)
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: Fix a corner case in multibytecodec: for stateful codecs, when encoding fails

2020-01-23 Thread arigo
Author: Armin Rigo 
Branch: 
Changeset: r98571:2ed84f7866b6
Date: 2020-01-23 11:37 +0100
http://bitbucket.org/pypy/pypy/changeset/2ed84f7866b6/

Log:Fix a corner case in multibytecodec: for stateful codecs, when
encoding fails and we use replacement, the replacement string must
be written in the output preserving the state.

diff --git a/pypy/module/_multibytecodec/c_codecs.py 
b/pypy/module/_multibytecodec/c_codecs.py
--- a/pypy/module/_multibytecodec/c_codecs.py
+++ b/pypy/module/_multibytecodec/c_codecs.py
@@ -194,17 +194,23 @@
rffi.SSIZE_T)
 pypy_cjk_enc_getcodec = llexternal('pypy_cjk_enc_getcodec',
[ENCODEBUF_P], MULTIBYTECODEC_P)
+pypy_cjk_enc_copystate = llexternal('pypy_cjk_enc_copystate',
+[ENCODEBUF_P, ENCODEBUF_P], lltype.Void)
 MBENC_FLUSH = 1
 MBENC_RESET = 2
 
 def encode(codec, unicodedata, length, errors="strict", errorcb=None,
-   namecb=None):
+   namecb=None, copystate=lltype.nullptr(ENCODEBUF_P.TO)):
 encodebuf = pypy_cjk_enc_new(codec)
 if not encodebuf:
 raise MemoryError
+if copystate:
+pypy_cjk_enc_copystate(encodebuf, copystate)
 try:
 return encodeex(encodebuf, unicodedata, length, errors, errorcb, 
namecb)
 finally:
+if copystate:
+pypy_cjk_enc_copystate(copystate, encodebuf)
 pypy_cjk_enc_free(encodebuf)
 
 def encodeex(encodebuf, utf8data, length, errors="strict", errorcb=None,
@@ -258,18 +264,18 @@
 elif errors == "ignore":
 replace = ""
 elif errors == "replace":
-codec = pypy_cjk_enc_getcodec(encodebuf)
-try:
-replace = encode(codec, "?", 1)
-except EncodeDecodeError:
-replace = "?"
+replace = "?"# utf-8 unicode
 else:
 assert errorcb
-rets, end = errorcb(errors, namecb, reason,
+replace, end = errorcb(errors, namecb, reason,
 unicodedata, start, end)
+if len(replace) > 0:
 codec = pypy_cjk_enc_getcodec(encodebuf)
-lgt = rutf8.codepoints_in_utf8(rets)
-replace = encode(codec, rets, lgt, "strict", errorcb, namecb)
+lgt = rutf8.codepoints_in_utf8(replace)
+replace = encode(codec, replace, lgt, copystate=encodebuf)
+#else:
+#   replace is an empty utf-8 unicode, which we directly consider to
+#   encode as an empty byte string.
 with rffi.scoped_nonmovingbuffer(replace) as inbuf:
 r = pypy_cjk_enc_replace_on_error(encodebuf, inbuf, len(replace), end)
 if r == MBERR_NOMEMORY:
diff --git a/pypy/module/_multibytecodec/src/cjkcodecs/multibytecodec.c 
b/pypy/module/_multibytecodec/src/cjkcodecs/multibytecodec.c
--- a/pypy/module/_multibytecodec/src/cjkcodecs/multibytecodec.c
+++ b/pypy/module/_multibytecodec/src/cjkcodecs/multibytecodec.c
@@ -135,6 +135,11 @@
   return d;
 }
 
+void pypy_cjk_enc_copystate(struct pypy_cjk_enc_s *dst, struct pypy_cjk_enc_s 
*src)
+{
+dst->state = src->state;
+}
+
 Py_ssize_t pypy_cjk_enc_init(struct pypy_cjk_enc_s *d,
  Py_UNICODE *inbuf, Py_ssize_t inlen)
 {
diff --git a/pypy/module/_multibytecodec/src/cjkcodecs/multibytecodec.h 
b/pypy/module/_multibytecodec/src/cjkcodecs/multibytecodec.h
--- a/pypy/module/_multibytecodec/src/cjkcodecs/multibytecodec.h
+++ b/pypy/module/_multibytecodec/src/cjkcodecs/multibytecodec.h
@@ -146,6 +146,8 @@
   char *, pypymbc_ssize_t, 
pypymbc_ssize_t);
 RPY_EXTERN
 const MultibyteCodec *pypy_cjk_enc_getcodec(struct pypy_cjk_enc_s *);
+RPY_EXTERN
+void pypy_cjk_enc_copystate(struct pypy_cjk_enc_s *dst, struct pypy_cjk_enc_s 
*src);
 
 /* list of codecs defined in the .c files */
 
diff --git a/pypy/module/_multibytecodec/test/test_app_codecs.py 
b/pypy/module/_multibytecodec/test/test_app_codecs.py
--- a/pypy/module/_multibytecodec/test/test_app_codecs.py
+++ b/pypy/module/_multibytecodec/test/test_app_codecs.py
@@ -110,3 +110,33 @@
   lambda e: ('\xc3', e.end))
 raises(TypeError, u"\uDDA1".encode, "gbk",
"test.test_encode_custom_error_handler_type")
+
+def test_encode_replacement_with_state(self):
+import codecs
+s = u'\u4ee4\u477c\u4ee4'.encode("iso-2022-jp", errors="replace")
+assert s == '\x1b$BNa\x1b(B?\x1b$BNa\x1b(B'
+
+def test_streaming_codec(self):
+test_0 = u'\uc5fc\u76d0\u5869\u9e7d\u477c\u4e3d/\u3012'
+test_1 = 
u'\u4ee4\u477c\u3080\u304b\u3057\u3080\u304b\u3057\u3042\u308b\u3068\u3053\u308d\u306b'
+test_2 = u' foo = "Quoted string \u4ee4\u477c" '
+
+ereplace = {'errors': 'replace'}
+exml = {'errors': 'xmlcharrefreplace'}
+for codec in ("iso-2022-jp", "iso-2022-jp-ext", "iso-2022-jp-1",
+  "iso-2022-jp-2", "iso-2022-jp-3", "iso-2022-jp-2004",
+  

[pypy-commit] pypy default: Fix comment after looking more in the CPython 3.x situation

2020-01-10 Thread arigo
Author: Armin Rigo 
Branch: 
Changeset: r98509:038f81a04a45
Date: 2020-01-10 13:16 +0100
http://bitbucket.org/pypy/pypy/changeset/038f81a04a45/

Log:Fix comment after looking more in the CPython 3.x situation

diff --git a/pypy/module/__builtin__/abstractinst.py 
b/pypy/module/__builtin__/abstractinst.py
--- a/pypy/module/__builtin__/abstractinst.py
+++ b/pypy/module/__builtin__/abstractinst.py
@@ -228,9 +228,10 @@
 return False
 #
 # The rest is the rare slow case.  Use the general logic of issubclass()
-# (issue #3149).  CPython 3.x doesn't do that, but there is a many-years
-# issue report: https://bugs.python.org/issue12029.  In PyPy3 we try to
-# fix the issue with the same code, as long as no CPython3 test fails.
+# (issue #3149).  CPython 3.x doesn't do that (but there is a
+# many-years issue report: https://bugs.python.org/issue12029), and
+# there are probably tests, so we won't call abstract_issubclass_w()
+# either in PyPy3.
 return abstract_issubclass_w(space, w_cls1, w_cls2, True)
 
 # 
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: fix issue #3137: rsplit of unicode strings that end with a non-ascii char was broken

2019-12-31 Thread cfbolz
Author: Carl Friedrich Bolz-Tereick 
Branch: 
Changeset: r98430:742d3ed68d7d
Date: 2019-12-31 21:04 +0100
http://bitbucket.org/pypy/pypy/changeset/742d3ed68d7d/

Log:fix issue #3137: rsplit of unicode strings that end with a non-ascii
char was broken

diff --git a/pypy/objspace/std/test/test_unicodeobject.py 
b/pypy/objspace/std/test/test_unicodeobject.py
--- a/pypy/objspace/std/test/test_unicodeobject.py
+++ b/pypy/objspace/std/test/test_unicodeobject.py
@@ -359,6 +359,9 @@
 assert u''.rsplit('aaa') == [u'']
 assert u'a\nb\u1680c'.rsplit() == [u'a', u'b', u'c']
 
+def test_rsplit_bug(self):
+assert u'Vestur- og Mi'.rsplit() == [u'Vestur-', u'og', 
u'Mi']
+
 def test_split_rsplit_str_unicode(self):
 x = 'abc'.split(u'b')
 assert x == [u'a', u'c']
diff --git a/rpython/rlib/rstring.py b/rpython/rlib/rstring.py
--- a/rpython/rlib/rstring.py
+++ b/rpython/rlib/rstring.py
@@ -139,7 +139,7 @@
 if by is None:
 res = []
 
-i = len(value) - 1
+i = _decr(value, len(value), isutf8)
 while True:
 # starting from the end, find the end of the next word
 while i >= 0:
diff --git a/rpython/rlib/test/test_rstring.py 
b/rpython/rlib/test/test_rstring.py
--- a/rpython/rlib/test/test_rstring.py
+++ b/rpython/rlib/test/test_rstring.py
@@ -88,6 +88,7 @@
 assert rsplit('baba', 'a', isutf8=1) == ['b', 'b', '']
 assert rsplit('b b', isutf8=1) == ['b', 'b']
 assert rsplit('b\xe1\x9a\x80b', isutf8=1) == ['b', 'b']
+assert rsplit('b\xe1\x9a\x80', isutf8=1) == ['b']
 
 def test_string_replace():
 def check_replace(value, sub, *args, **kwargs):
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: fix backport 826708d0c629

2019-12-14 Thread mattip
Author: Matti Picus 
Branch: 
Changeset: r98288:994c42529580
Date: 2019-12-15 06:31 +0200
http://bitbucket.org/pypy/pypy/changeset/994c42529580/

Log:fix backport 826708d0c629

diff --git a/lib_pypy/_cffi_ssl/_stdssl/__init__.py 
b/lib_pypy/_cffi_ssl/_stdssl/__init__.py
--- a/lib_pypy/_cffi_ssl/_stdssl/__init__.py
+++ b/lib_pypy/_cffi_ssl/_stdssl/__init__.py
@@ -113,6 +113,7 @@
 PROTOCOL_TLSv1_2 = 5
 # PROTOCOL_TLS_CLIENT = 0x10
 # PROTOCOL_TLS_SERVER = 0x11
+HAS_TLSv1_3 = bool(lib.Cryptography_HAS_TLSv1_3)
 
 _PROTOCOL_NAMES = (name for name in dir(lib) if name.startswith('PROTOCOL_'))
 
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: Fix for pypy.module._file.test.test_large_file on 32bit

2019-12-13 Thread arigo
Author: Armin Rigo 
Branch: 
Changeset: r98285:f1ac06bafd45
Date: 2019-12-13 13:49 +0100
http://bitbucket.org/pypy/pypy/changeset/f1ac06bafd45/

Log:Fix for pypy.module._file.test.test_large_file on 32bit

diff --git a/rpython/rlib/streamio.py b/rpython/rlib/streamio.py
--- a/rpython/rlib/streamio.py
+++ b/rpython/rlib/streamio.py
@@ -317,7 +317,8 @@
 os.lseek(self.fd, offset, whence)
 
 def tell(self):
-return os.lseek(self.fd, 0, 1)
+result = os.lseek(self.fd, 0, 1)
+return r_longlong(result)
 
 def read(self, n):
 assert isinstance(n, int)
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: fix ncurses include/lib discovery: add from_config_tool("ncursesw6-config"), reverse order

2019-12-07 Thread mattip
Author: Matti Picus 
Branch: 
Changeset: r98247:838c25e04d2a
Date: 2019-12-07 19:35 +0200
http://bitbucket.org/pypy/pypy/changeset/838c25e04d2a/

Log:fix ncurses include/lib discovery: add
from_config_tool("ncursesw6-config"), reverse order

diff --git a/pypy/module/_minimal_curses/fficurses.py 
b/pypy/module/_minimal_curses/fficurses.py
--- a/pypy/module/_minimal_curses/fficurses.py
+++ b/pypy/module/_minimal_curses/fficurses.py
@@ -5,13 +5,6 @@
 from rpython.rtyper.tool import rffi_platform
 from rpython.translator.tool.cbuild import ExternalCompilationInfo
 
-# We cannot trust ncurses5-config, it's broken in various ways in
-# various versions.  For example it might not list -ltinfo even though
-# it's needed, or --cflags might be completely empty. Crap.
-
-except IOError:
-pass
-
 def try_cflags():
 yield ExternalCompilationInfo(includes=['curses.h', 'term.h'])
 yield ExternalCompilationInfo(includes=['curses.h', 'term.h'],
@@ -33,7 +26,11 @@
 
 def try_tools():
 try:
-yield ExternalCompilationInfo.from_pkg_config("ncurses")
+yield ExternalCompilationInfo.from_config_tool("ncursesw6-config")
+except Exception:
+pass
+try:
+yield ExternalCompilationInfo.from_config_tool("ncurses5-config")
 except Exception:
 pass
 try:
@@ -41,7 +38,7 @@
 except Exception:
 pass
 try:
-yield ExternalCompilationInfo.from_config_tool("ncurses5-config")
+yield ExternalCompilationInfo.from_pkg_config("ncursesw")
 except Exception:
 pass
 
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: Fix issue #3120, do restore traceback in PyErr_Restore.

2019-11-21 Thread Stian Andreassen
Author: Stian Andreassen
Branch: 
Changeset: r98125:3b12b6935197
Date: 2019-11-21 15:46 +0100
http://bitbucket.org/pypy/pypy/changeset/3b12b6935197/

Log:Fix issue #3120, do restore traceback in PyErr_Restore.

diff --git a/pypy/module/cpyext/pyerrors.py b/pypy/module/cpyext/pyerrors.py
--- a/pypy/module/cpyext/pyerrors.py
+++ b/pypy/module/cpyext/pyerrors.py
@@ -88,7 +88,7 @@
 if w_type is None:
 state.clear_exception()
 return
-state.set_exception(OperationError(w_type, w_value))
+state.set_exception(OperationError(w_type, w_value, w_traceback))
 
 @cpython_api([PyObjectP, PyObjectP, PyObjectP], lltype.Void)
 def PyErr_NormalizeException(space, exc_p, val_p, tb_p):
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: Fix some failures of test_pypy_c on aarch64

2019-11-16 Thread arigo
Author: Armin Rigo 
Branch: 
Changeset: r98072:8fc092d343a0
Date: 2019-11-16 14:28 +0100
http://bitbucket.org/pypy/pypy/changeset/8fc092d343a0/

Log:Fix some failures of test_pypy_c on aarch64

diff --git a/pypy/module/pypyjit/test_pypy_c/test_micronumpy.py 
b/pypy/module/pypyjit/test_pypy_c/test_micronumpy.py
--- a/pypy/module/pypyjit/test_pypy_c/test_micronumpy.py
+++ b/pypy/module/pypyjit/test_pypy_c/test_micronumpy.py
@@ -18,6 +18,20 @@
 return not detect_simd_z()
 return True
 
+def align_check(input):
+if platform.machine().startswith('x86'):
+return ""
+if sys.maxsize > 2**32:
+mask = 7
+else:
+mask = 3
+return """
+i10096 = int_and(%s, %d)
+i10097 = int_is_zero(i10096)
+guard_true(i10097, descr=...)
+""" % (input, mask)
+
+
 class TestMicroNumPy(BaseTestPyPyC):
 
 arith_comb = [('+','float','float', 4*3427,   3427, 1.0,3.0),
@@ -310,6 +324,7 @@
 guard_not_invalidated(descr=...)
 i88 = int_ge(i87, i59)
 guard_false(i88, descr=...)
+%(align_check)s
 f90 = raw_load_f(i67, i89, descr=)
 i91 = int_add(i87, 1)
 i93 = int_add(i89, 8)
@@ -320,7 +335,7 @@
 i96 = int_lt(i95, 0)
 guard_false(i96, descr=...)
 jump(..., descr=...)
-""")
+""" % {"align_check": align_check('i89')})
 
 def test_array_flatiter_getitem_single(self):
 def main():
@@ -342,6 +357,7 @@
 guard_true(i126, descr=...)
 i128 = int_mul(i117, i59)
 i129 = int_add(i55, i128)
+%(align_check)s
 f149 = raw_load_f(i100, i129, descr=)
 i151 = int_add(i117, 1)
 setfield_gc(p156, i55, descr=)
@@ -349,7 +365,7 @@
 setarrayitem_gc(p150, 0, 0, descr=)
 --TICK--
 jump(..., descr=...)
-""")
+""" % {'align_check': align_check('i129')})
 
 def test_array_flatiter_setitem_single(self):
 def main():
@@ -372,6 +388,7 @@
 i131 = int_mul(i120, i57)
 i132 = int_add(i53, i131)
 guard_not_invalidated(descr=...)
+%(align_check)s
 raw_store(i103, i132, 42.00, descr=)
 i153 = int_add(i120, 1)
 i154 = getfield_raw_i(#, descr=)
@@ -381,7 +398,7 @@
 i157 = int_lt(i154, 0)
 guard_false(i157, descr=...)
 jump(..., descr=...)
-""")
+""" % {'align_check': align_check('i132')})
 
 def test_mixed_div(self):
 N = 1500
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: fix 2c98ee4a95b3

2019-11-15 Thread mattip
Author: Matti Picus 
Branch: 
Changeset: r98056:1ad4f44a62a4
Date: 2019-11-15 07:51 -0500
http://bitbucket.org/pypy/pypy/changeset/1ad4f44a62a4/

Log:fix 2c98ee4a95b3

diff --git a/lib-python/2.7/sysconfig.py b/lib-python/2.7/sysconfig.py
--- a/lib-python/2.7/sysconfig.py
+++ b/lib-python/2.7/sysconfig.py
@@ -383,9 +383,10 @@
 vars['VERSION'] = _PY_VERSION_SHORT_NO_DOT
 vars['BINDIR'] = os.path.dirname(_safe_realpath(sys.executable))
 # pypy only: give us control over the ABI tag in a wheel name
-import _imp
-so_ext = _imp.get_suffixes()[0][0]
-vars['SOABI']= '-'.join(so_ext.split('.')[1].split('-')[:2])
+if '__pypy__' in sys.builtin_module_names:
+import imp
+so_ext = imp.get_suffixes()[0][0]
+vars['SOABI']= '-'.join(so_ext.split('.')[1].split('-')[:2])
 
 #
 # public APIs
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: Fix the error message: point to the right "cd" directory

2019-11-09 Thread arigo
Author: Armin Rigo 
Branch: 
Changeset: r98008:789b5384030f
Date: 2019-11-10 08:38 +0100
http://bitbucket.org/pypy/pypy/changeset/789b5384030f/

Log:Fix the error message: point to the right "cd" directory

diff --git a/lib_pypy/_cffi_ssl/_stdssl/__init__.py 
b/lib_pypy/_cffi_ssl/_stdssl/__init__.py
--- a/lib_pypy/_cffi_ssl/_stdssl/__init__.py
+++ b/lib_pypy/_cffi_ssl/_stdssl/__init__.py
@@ -10,7 +10,7 @@
 import os
 msg = "\n\nThe _ssl cffi module either doesn't exist or is incompatible 
with your machine's shared libraries.\n" + \
   "If you have a compiler installed, you can try to rebuild it by 
running:\n" + \
-  "cd %s\n" % 
os.path.abspath(os.path.dirname(os.path.dirname(__file__))) + \
+  "cd %s\n" % 
os.path.abspath(os.path.dirname(os.path.dirname(os.path.dirname(__file__ + \
   "%s _ssl_build.py\n" % sys.executable
 raise ImportError(str(e) + msg)
 
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: fix failing test, remove tab

2019-10-31 Thread mattip
Author: Matti Picus 
Branch: 
Changeset: r97925:d91b02c62beb
Date: 2019-11-01 05:01 +0200
http://bitbucket.org/pypy/pypy/changeset/d91b02c62beb/

Log:fix failing test, remove tab

diff --git a/lib_pypy/_curses_build.py b/lib_pypy/_curses_build.py
--- a/lib_pypy/_curses_build.py
+++ b/lib_pypy/_curses_build.py
@@ -21,7 +21,7 @@
 if os.path.exists('/usr/include/ncurses'):
 return ['/usr/include/ncurses']
 if os.path.exists('/usr/include/ncursesw'):
-   return ['/usr/include/ncursesw']
+return ['/usr/include/ncursesw']
 return []
 
 
diff --git a/pypy/module/cpyext/test/test_typeobject.py 
b/pypy/module/cpyext/test/test_typeobject.py
--- a/pypy/module/cpyext/test/test_typeobject.py
+++ b/pypy/module/cpyext/test/test_typeobject.py
@@ -1296,7 +1296,8 @@
 except TypeError as e:
 import sys
 if '__pypy__' in sys.builtin_module_names:
-assert str(e) == 'instance layout conflicts in multiple 
inheritance'
+print(str(e))
+assert 'instance layout conflicts in multiple inheritance' in 
str(e)
 
 else:
 assert str(e) == ('Error when calling the metaclass bases\n'
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: fix #3108: the map based parser didn't deal with json dicts with repeated keys

2019-10-31 Thread cfbolz
Author: Carl Friedrich Bolz-Tereick 
Branch: 
Changeset: r97924:86da6cb357f1
Date: 2019-10-31 21:07 +0100
http://bitbucket.org/pypy/pypy/changeset/86da6cb357f1/

Log:fix #3108: the map based parser didn't deal with json dicts with
repeated keys correctly

diff --git a/pypy/module/_pypyjson/interp_decoder.py 
b/pypy/module/_pypyjson/interp_decoder.py
--- a/pypy/module/_pypyjson/interp_decoder.py
+++ b/pypy/module/_pypyjson/interp_decoder.py
@@ -342,7 +342,14 @@
 currmap = self.startmap
 while True:
 # parse a key: value
-currmap = self.decode_key_map(i, currmap)
+newmap = self.decode_key_map(i, currmap)
+if newmap is None:
+# We've seen a repeated value, switch to dict-based storage.
+dict_w = self._switch_to_dict(currmap, values_w, nextindex)
+# We re-parse the last key, to get the correct overwriting
+# effect. Pointless to care for performance here.
+return self.decode_object_dict(i, start, dict_w)
+currmap = newmap
 i = self.skip_whitespace(self.pos)
 ch = self.ll_chars[i]
 if ch != ':':
@@ -610,6 +617,8 @@
 """ Given the current map currmap of an object, decode the next key at
 position i. This returns the new map of the object. """
 newmap = self._decode_key_map(i, currmap)
+if newmap is None:
+return None
 currmap.observe_transition(newmap, self.startmap)
 return newmap
 
@@ -789,6 +798,11 @@
 self.nextmap_first._check_invariants()
 
 def get_next(self, w_key, string, start, stop, terminator):
+""" Returns the next map, given a wrapped key w_key, the json input
+string with positions start and stop, as well as a terminator.
+
+Returns None if the key already appears somewhere in the map chain.
+"""
 from pypy.objspace.std.dictmultiobject import unicode_hash, unicode_eq
 if isinstance(self, JSONMap):
 assert not self.state == MapBase.BLOCKED
@@ -803,6 +817,8 @@
 if nextmap_first is None:
 # first transition ever seen, don't initialize nextmap_all
 next = self._make_next_map(w_key, string[start:stop])
+if next is None:
+return None
 self.nextmap_first = next
 else:
 if self.nextmap_all is None:
@@ -817,6 +833,8 @@
 # if we are at this point we didn't find the transition yet, so
 # create a new one
 next = self._make_next_map(w_key, string[start:stop])
+if next is None:
+return None
 self.nextmap_all[w_key] = next
 
 # one new leaf has been created
@@ -859,6 +877,14 @@
 self.mark_useful(terminator)
 
 def _make_next_map(self, w_key, key_repr):
+# Check whether w_key is already part of the self.prev chain
+# to prevent strangeness in the json dict implementation.
+# This is slow, but it should be rare to call this function.
+check = self
+while isinstance(check, JSONMap):
+if check.w_key._utf8 == w_key._utf8:
+return None
+check = check.prev
 return JSONMap(self.space, self, w_key, key_repr)
 
 def fill_dict(self, dict_w, values_w):
diff --git a/pypy/module/_pypyjson/test/test__pypyjson.py 
b/pypy/module/_pypyjson/test/test__pypyjson.py
--- a/pypy/module/_pypyjson/test/test__pypyjson.py
+++ b/pypy/module/_pypyjson/test/test__pypyjson.py
@@ -74,6 +74,17 @@
 m3.fill_dict(d, [space.w_None, space.w_None, space.w_None])
 assert list(d) == [w_a, w_b, w_c]
 
+def test_repeated_key_get_next(self):
+m = Terminator(self.space)
+w_a = self.space.newutf8("a", 1)
+w_b = self.space.newutf8("b", 1)
+w_c = self.space.newutf8("c", 1)
+m1 = m.get_next(w_a, '"a"', 0, 3, m)
+m1 = m1.get_next(w_b, '"b"', 0, 3, m)
+m1 = m1.get_next(w_c, '"c"', 0, 3, m)
+m2 = m1.get_next(w_a, '"a"', 0, 3, m)
+assert m2 is None
+
 
 def test_decode_key_map(self):
 m = Terminator(self.space)
@@ -519,3 +530,11 @@
 exc = raises(ValueError, _pypyjson.loads, inputtext)
 assert str(exc.value) == errmsg
 
+def test_repeated_key(self):
+import _pypyjson
+a = '{"abc": "4", "k": 1, "k": 2}'
+d = _pypyjson.loads(a)
+assert d == {u"abc": u"4", u"k": 2}
+a = '{"abc": "4", "k": 1, "k": 1.5, "c": null, "k": 2}'
+d = _pypyjson.loads(a)
+assert d == {u"abc": u"4", u"c": None, u"k": 2}
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: Fix uses of raises()

2019-10-30 Thread rlamy
Author: Ronan Lamy 
Branch: 
Changeset: r97897:ef97a01d2e01
Date: 2019-10-30 21:15 +
http://bitbucket.org/pypy/pypy/changeset/ef97a01d2e01/

Log:Fix uses of raises()

diff --git a/pypy/interpreter/test/test_function.py 
b/pypy/interpreter/test/test_function.py
--- a/pypy/interpreter/test/test_function.py
+++ b/pypy/interpreter/test/test_function.py
@@ -76,7 +76,8 @@
 return x
 return f
 f = g(42)
-raises(TypeError, FuncType, f.func_code, f.func_globals, 'f2', None, 
None)
+with raises(TypeError):
+FuncType(f.func_code, f.func_globals, 'f2', None, None)
 
 def test_write_code(self):
 def f():
@@ -134,8 +135,10 @@
 assert res[1] == 22
 assert res[2] == 333
 
-raises(TypeError, func)
-raises(TypeError, func, 1, 2, 3, 4)
+with raises(TypeError):
+func()
+with raises(TypeError):
+func(1, 2, 3, 4)
 
 def test_simple_varargs(self):
 def func(arg1, *args):
@@ -162,7 +165,8 @@
 def test_kwargs_sets_wrong_positional_raises(self):
 def func(arg1):
 pass
-raises(TypeError, func, arg2=23)
+with raises(TypeError):
+func(arg2=23)
 
 def test_kwargs_sets_positional(self):
 def func(arg1):
@@ -180,8 +184,8 @@
 def test_kwargs_sets_positional_twice(self):
 def func(arg1, **kw):
 return arg1, kw
-raises(
-TypeError, func, 42, {'arg1': 23})
+with raises(TypeError):
+func(42, {'arg1': 23})
 
 def test_kwargs_nondict_mapping(self):
 class Mapping:
@@ -194,9 +198,10 @@
 res = func(23, **Mapping())
 assert res[0] == 23
 assert res[1] == {'a': 'a', 'b': 'b'}
-error = raises(TypeError, lambda: func(42, **[]))
-assert error.value.message == ('argument after ** must be a mapping, '
-   'not list')
+with raises(TypeError) as excinfo:
+func(42, **[])
+assert excinfo.value.message == (
+'argument after ** must be a mapping, not list')
 
 def test_default_arg(self):
 def func(arg1,arg2=42):
@@ -215,12 +220,14 @@
 def test_defaults_keyword_override_but_leaves_empty_positional(self):
 def func(arg1,arg2=42):
 return arg1, arg2
-raises(TypeError, func, arg2=23)
+with raises(TypeError):
+func(arg2=23)
 
 def test_kwargs_disallows_same_name_twice(self):
 def func(arg1, **kw):
 return arg1, kw
-raises(TypeError, func, 42, **{'arg1': 23})
+with raises(TypeError):
+func(42, **{'arg1': 23})
 
 def test_kwargs_bound_blind(self):
 class A(object):
@@ -269,15 +276,21 @@
 
 def test_call_builtin(self):
 s = 'hello'
-raises(TypeError, len)
+with raises(TypeError):
+len()
 assert len(s) == 5
-raises(TypeError, len, s, s)
-raises(TypeError, len, s, s, s)
+with raises(TypeError):
+len(s, s)
+with raises(TypeError):
+len(s, s, s)
 assert len(*[s]) == 5
 assert len(s, *[]) == 5
-raises(TypeError, len, some_unknown_keyword=s)
-raises(TypeError, len, s, some_unknown_keyword=s)
-raises(TypeError, len, s, s, some_unknown_keyword=s)
+with raises(TypeError):
+len(some_unknown_keyword=s)
+with raises(TypeError):
+len(s, some_unknown_keyword=s)
+with raises(TypeError):
+len(s, s, some_unknown_keyword=s)
 
 def test_call_error_message(self):
 try:
@@ -310,8 +323,10 @@
 # cannot subclass 'function' or 'builtin_function'
 def f():
 pass
-raises(TypeError, type, 'Foo', (type(f),), {})
-raises(TypeError, type, 'Foo', (type(len),), {})
+with raises(TypeError):
+type('Foo', (type(f),), {})
+with raises(TypeError):
+type('Foo', (type(len),), {})
 
 def test_lambda_docstring(self):
 # Like CPython, (lambda:"foo") has a docstring of "foo".
@@ -324,7 +339,8 @@
 f = lambda: 42
 # not sure what it should raise, since CPython doesn't have setstate
 # on function types
-raises(ValueError, type(f).__setstate__, f, (1, 2, 3))
+with raises(ValueError):
+type(f).__setstate__(f, (1, 2, 3))
 
 class AppTestMethod:
 def test_simple_call(self):
@@ -471,14 +487,13 @@
 
 assert A.foo(A(), 42) == (42,)
 assert A.foo(B(), 42) == (42,)
-raises(TypeError, A.foo, 5)
-raises(TypeError, B.foo, C())
-try:
+with raises(TypeError):
+A.foo(5)
+with raises(TypeError):
+B.foo(C())
+with raises(TypeError):
 class Fun:
 __metaclass__ = A.foo
-assert 0  # should have raised
- 

[pypy-commit] pypy default: Fix in the aarch64 backend for a rare case where a register would be overridden

2019-10-28 Thread arigo
Author: Armin Rigo 
Branch: 
Changeset: r97874:81c30ab04ab4
Date: 2019-10-28 13:45 +0100
http://bitbucket.org/pypy/pypy/changeset/81c30ab04ab4/

Log:Fix in the aarch64 backend for a rare case where a register would be
overridden

diff --git a/rpython/jit/backend/aarch64/opassembler.py 
b/rpython/jit/backend/aarch64/opassembler.py
--- a/rpython/jit/backend/aarch64/opassembler.py
+++ b/rpython/jit/backend/aarch64/opassembler.py
@@ -986,7 +986,8 @@
 loc_index = arglocs[1]
 assert loc_index.is_core_reg()
 tmp1 = r.ip1
-tmp2 = arglocs[-1]  # the last item is a preallocated tmp
+#tmp2 = arglocs[-1]  -- the last item is a preallocated tmp on arm,
+#   but not here on aarch64
 # lr = byteofs
 s = 3 + descr.jit_wb_card_page_shift
 mc.MVN_rr_shifted(r.lr.value, loc_index.value, s, 
shifttype=shift.LSR)
@@ -997,10 +998,10 @@
 descr.jit_wb_card_page_shift, shifttype=shift.LSR)
 
 # set the bit
-mc.MOVZ_r_u16(tmp2.value, 1, 0)
+mc.MOVZ_r_u16(r.ip0.value, 1, 0)
+mc.LSL_rr(tmp1.value, r.ip0.value, tmp1.value)
 mc.LDRB_rr(r.ip0.value, loc_base.value, r.lr.value)
-mc.LSL_rr(tmp2.value, tmp2.value, tmp1.value)
-mc.ORR_rr(r.ip0.value, r.ip0.value, tmp2.value)
+mc.ORR_rr(r.ip0.value, r.ip0.value, tmp1.value)
 mc.STR_size_rr(0, r.ip0.value, loc_base.value, r.lr.value)
 # done
 #
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: fix prefix

2019-09-15 Thread mattip
Author: Matti Picus 
Branch: 
Changeset: r97478:424cd7425b6d
Date: 2019-09-15 13:35 +0300
http://bitbucket.org/pypy/pypy/changeset/424cd7425b6d/

Log:fix prefix

diff --git a/pypy/tool/build_cffi_imports.py b/pypy/tool/build_cffi_imports.py
--- a/pypy/tool/build_cffi_imports.py
+++ b/pypy/tool/build_cffi_imports.py
@@ -27,7 +27,7 @@
 cffi_dependencies = {
 '_ssl': ('https://www.openssl.org/source/openssl-1.1.1c.tar.gz',
  
'f6fb3079ad15076154eda9413fed42877d668e7069d9b87396d0804fdb3f4c90',
- [['./config', 'no-shared'],
+ [['./config', '--prefix=/usr', 'no-shared'],
   ['make', '-s', '-j', str(multiprocessing.cpu_count())],
   ['make', 'install', 'DESTDIR={}/'.format(deps_destdir)],
  ]),
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: fix indent

2019-09-14 Thread mattip
Author: Matti Picus 
Branch: 
Changeset: r97476:7d1812d13cdf
Date: 2019-09-14 15:32 +0300
http://bitbucket.org/pypy/pypy/changeset/7d1812d13cdf/

Log:fix indent

diff --git a/pypy/tool/build_cffi_imports.py b/pypy/tool/build_cffi_imports.py
--- a/pypy/tool/build_cffi_imports.py
+++ b/pypy/tool/build_cffi_imports.py
@@ -112,7 +112,7 @@
 cwd=sources,)
 if status != 0:
 break
-return status, stdout, stderr
+return status, stdout, stderr
 
 def create_cffi_import_libraries(pypy_c, options, basedir, only=None,
  embed_dependencies=False, rebuild=False):
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: fix corner case about readline with limit that goes beyond the end of the string

2019-09-13 Thread cfbolz
Author: Carl Friedrich Bolz-Tereick 
Branch: 
Changeset: r97471:6e25c50447f0
Date: 2019-09-13 11:21 +0200
http://bitbucket.org/pypy/pypy/changeset/6e25c50447f0/

Log:fix corner case about readline with limit that goes beyond the end
of the string

diff --git a/pypy/module/_io/interp_textio.py b/pypy/module/_io/interp_textio.py
--- a/pypy/module/_io/interp_textio.py
+++ b/pypy/module/_io/interp_textio.py
@@ -429,10 +429,9 @@
 assert 0 <= ord(marker) < 128
 # ascii fast path
 if self.ulen == len(self.text):
-if limit < 0:
-end = len(self.text)
-else:
-end = self.pos + limit
+end = len(self.text)
+if limit >= 0:
+end = min(end, self.pos + limit)
 pos = self.pos
 assert pos >= 0
 assert end >= 0
diff --git a/pypy/module/_io/test/test_interp_textio.py 
b/pypy/module/_io/test/test_interp_textio.py
--- a/pypy/module/_io/test/test_interp_textio.py
+++ b/pypy/module/_io/test/test_interp_textio.py
@@ -35,6 +35,7 @@
 @given(data=st_readline(),
mode=st.sampled_from(['\r', '\n', '\r\n', '']))
 @settings(deadline=None, database=None)
+@example(data=(u'\n\r\n', [0, -1, 2, -1, 0, -1]), mode='\r')
 def test_readline(space, data, mode):
 txt, limits = data
 w_stream = W_BytesIO(space)
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: fix translation

2019-09-12 Thread cfbolz
Author: Carl Friedrich Bolz-Tereick 
Branch: 
Changeset: r97460:ba849ddc5eaf
Date: 2019-09-12 15:50 +0200
http://bitbucket.org/pypy/pypy/changeset/ba849ddc5eaf/

Log:fix translation

diff --git a/pypy/module/_io/interp_textio.py b/pypy/module/_io/interp_textio.py
--- a/pypy/module/_io/interp_textio.py
+++ b/pypy/module/_io/interp_textio.py
@@ -433,7 +433,10 @@
 end = len(self.text)
 else:
 end = self.pos + limit
-pos = self.text.find(marker, self.pos, end)
+pos = self.pos
+assert pos >= 0
+assert end >= 0
+pos = self.text.find(marker, pos, end)
 if pos >= 0:
 self.pos = self.upos = pos + 1
 return True
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: fix untested rewind method

2019-08-27 Thread cfbolz
Author: Carl Friedrich Bolz-Tereick 
Branch: 
Changeset: r97303:0d2efab3484a
Date: 2019-08-27 13:09 +0200
http://bitbucket.org/pypy/pypy/changeset/0d2efab3484a/

Log:fix untested rewind method

diff --git a/rpython/rlib/rarithmetic.py b/rpython/rlib/rarithmetic.py
--- a/rpython/rlib/rarithmetic.py
+++ b/rpython/rlib/rarithmetic.py
@@ -877,6 +877,8 @@
 characters of 's'.  Raises ParseStringError in case of error.
 Raises ParseStringOverflowError in case the result does not fit.
 """
+if "9" in s:
+import pdb; pdb.set_trace()
 from rpython.rlib.rstring import (
 NumberStringParser, ParseStringOverflowError)
 p = NumberStringParser(s, s, base, 'int',
diff --git a/rpython/rlib/rstring.py b/rpython/rlib/rstring.py
--- a/rpython/rlib/rstring.py
+++ b/rpython/rlib/rstring.py
@@ -568,7 +568,7 @@
 self.end = q
 
 def rewind(self):
-self.i = 0
+self.i = self.start
 
 def next_digit(self): # -1 => exhausted
 if self.i < self.end:
diff --git a/rpython/rlib/test/test_rbigint.py 
b/rpython/rlib/test/test_rbigint.py
--- a/rpython/rlib/test/test_rbigint.py
+++ b/rpython/rlib/test/test_rbigint.py
@@ -356,6 +356,30 @@
 assert rbigint.fromstr('123L', 21).tolong() == 441 + 42 + 3
 assert rbigint.fromstr('1891234174197319').tolong() == 1891234174197319
 
+def test__from_numberstring_parser_rewind_bug(self):
+from rpython.rlib.rstring import NumberStringParser
+s = "-99"
+p = NumberStringParser(s, s, 10, 'int')
+import pdb; pdb.set_trace()
+assert p.sign == -1
+res = p.next_digit()
+assert res == 9
+res = p.next_digit()
+assert res == 9
+res = p.next_digit()
+assert res == -1
+p.rewind()
+res = p.next_digit()
+assert res == 9
+res = p.next_digit()
+assert res == 9
+res = p.next_digit()
+assert res == -1
+
+@given(longs)
+def test_fromstr_hypothesis(self, l):
+assert rbigint.fromstr(str(l)).tolong() == l
+
 def test_from_numberstring_parser(self):
 from rpython.rlib.rstring import NumberStringParser
 parser = NumberStringParser("1231231241", "1231231241", 10, "long")
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: fix (uh, why support instance_ptr_eq but miss instance_ptr_ne??)

2019-08-18 Thread arigo
Author: Armin Rigo 
Branch: 
Changeset: r97205:7200528f8f4d
Date: 2019-08-18 08:47 +0200
http://bitbucket.org/pypy/pypy/changeset/7200528f8f4d/

Log:fix (uh, why support instance_ptr_eq but miss instance_ptr_ne??)

diff --git a/rpython/jit/backend/aarch64/regalloc.py 
b/rpython/jit/backend/aarch64/regalloc.py
--- a/rpython/jit/backend/aarch64/regalloc.py
+++ b/rpython/jit/backend/aarch64/regalloc.py
@@ -419,7 +419,7 @@
 prepare_comp_op_int_ne = prepare_int_cmp
 prepare_comp_op_int_eq = prepare_int_cmp
 prepare_comp_op_ptr_eq = prepare_comp_op_instance_ptr_eq = prepare_int_cmp
-prepare_comp_op_ptr_ne = prepare_int_cmp
+prepare_comp_op_ptr_ne = prepare_comp_op_instance_ptr_ne = prepare_int_cmp
 prepare_comp_op_uint_lt = prepare_int_cmp
 prepare_comp_op_uint_le = prepare_int_cmp
 prepare_comp_op_uint_ge = prepare_int_cmp
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: fix tests for win32

2019-08-12 Thread mattip
Author: Matti Picus 
Branch: 
Changeset: r97160:d08393b13818
Date: 2019-08-12 11:54 +0300
http://bitbucket.org/pypy/pypy/changeset/d08393b13818/

Log:fix tests for win32

diff --git a/extra_tests/ctypes_tests/test_win32.py 
b/extra_tests/ctypes_tests/test_win32.py
--- a/extra_tests/ctypes_tests/test_win32.py
+++ b/extra_tests/ctypes_tests/test_win32.py
@@ -5,7 +5,7 @@
 import pytest
 
 @pytest.mark.skipif("sys.platform != 'win32'")
-def test_VARIANT(self):
+def test_VARIANT():
 from ctypes import wintypes
 a = wintypes.VARIANT_BOOL()
 assert a.value is False
diff --git a/extra_tests/test_datetime.py b/extra_tests/test_datetime.py
--- a/extra_tests/test_datetime.py
+++ b/extra_tests/test_datetime.py
@@ -128,7 +128,7 @@
 import os
 import time
 if os.name == 'nt':
-skip("setting os.environ['TZ'] ineffective on windows")
+pytest.skip("setting os.environ['TZ'] ineffective on windows")
 try:
 prev_tz = os.environ.get("TZ")
 os.environ["TZ"] = "GMT"
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: fix test_buffer for platforms which refuse misaligned accesses

2019-08-12 Thread arigo
Author: Armin Rigo 
Branch: 
Changeset: r97159:8dd6a15f4357
Date: 2019-08-12 07:44 +
http://bitbucket.org/pypy/pypy/changeset/8dd6a15f4357/

Log:fix test_buffer for platforms which refuse misaligned accesses

diff --git a/rpython/rlib/test/test_buffer.py b/rpython/rlib/test/test_buffer.py
--- a/rpython/rlib/test/test_buffer.py
+++ b/rpython/rlib/test/test_buffer.py
@@ -125,8 +125,8 @@
 class TestSubBufferTypedReadDirect(BaseTypedReadTest):
 
 def read(self, TYPE, data, offset):
-buf = StringBuffer('xx' + data)
-subbuf = SubBuffer(buf, 2, len(data))
+buf = StringBuffer('x' * 16 + data)
+subbuf = SubBuffer(buf, 16, len(data))
 return subbuf.typed_read(TYPE, offset)
 
 
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: Fix test collection on windows and s390x

2019-08-11 Thread rlamy
Author: Ronan Lamy 
Branch: 
Changeset: r97146:597f4be1ae97
Date: 2019-08-11 17:51 +0100
http://bitbucket.org/pypy/pypy/changeset/597f4be1ae97/

Log:Fix test collection on windows and s390x

diff --git a/pypy/module/_cppyy/test/conftest.py 
b/pypy/module/_cppyy/test/conftest.py
--- a/pypy/module/_cppyy/test/conftest.py
+++ b/pypy/module/_cppyy/test/conftest.py
@@ -5,7 +5,7 @@
 
 @py.test.mark.tryfirst
 def pytest_runtest_setup(item):
-if py.path.local.sysfind('genreflex') is None:
+if not disabled and py.path.local.sysfind('genreflex') is None:
 import pypy.module._cppyy.capi.loadable_capi as lcapi
 if 'dummy' in lcapi.backend_library:
 # run only tests that are covered by the dummy backend and tests
@@ -33,16 +33,18 @@
 
 def pytest_ignore_collect(path, config):
 path = str(path)
-if py.path.local.sysfind('genreflex') is None and 
config.option.runappdirect:
-return commonprefix([path, THIS_DIR]) == THIS_DIR
 if disabled:
-return commonprefix([path, THIS_DIR]) == THIS_DIR
+if commonprefix([path, THIS_DIR]) == THIS_DIR:  # workaround for bug 
in pytest<3.0.5
+return True
 
 disabled = None
 
 def pytest_configure(config):
+global disabled
 if config.getoption('runappdirect') or config.getoption('direct_apptest'):
-return   # "can't run dummy tests in -A"
+if py.path.local.sysfind('genreflex') is None:
+disabled = True  # can't run dummy tests in -A
+return
 if py.path.local.sysfind('genreflex') is None:
 import pypy.module._cppyy.capi.loadable_capi as lcapi
 try:
@@ -77,7 +79,6 @@
 standalone=False)
 except CompilationError as e:
 if '-std=c++14' in str(e):
-global disabled
 disabled = str(e)
 return
 raise
diff --git a/pypy/module/_vmprof/conftest.py b/pypy/module/_vmprof/conftest.py
--- a/pypy/module/_vmprof/conftest.py
+++ b/pypy/module/_vmprof/conftest.py
@@ -1,8 +1,13 @@
-import py, platform, sys
+import pytest
+import platform
+import sys
+from os.path import commonprefix, dirname
 
-def pytest_collect_directory(path, parent):
-if platform.machine() == 's390x':
-py.test.skip("_vmprof tests skipped")
-if sys.platform == 'win32':
-py.test.skip("_vmprof tests skipped")
-pytest_collect_file = pytest_collect_directory
+THIS_DIR = dirname(__file__)
+
+@pytest.hookimpl(tryfirst=True)
+def pytest_ignore_collect(path, config):
+path = str(path)
+if sys.platform == 'win32' or platform.machine() == 's390x':
+if commonprefix([path, THIS_DIR]) == THIS_DIR:  # workaround for bug 
in pytest<3.0.5
+return True
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: fix for latest virtualenv HEAD

2019-08-10 Thread mattip
Author: Matti Picus 
Branch: 
Changeset: r97141:adc92f0ac6c1
Date: 2019-08-10 21:41 +0300
http://bitbucket.org/pypy/pypy/changeset/adc92f0ac6c1/

Log:fix for latest virtualenv HEAD

diff --git a/testrunner/get_info.py b/testrunner/get_info.py
--- a/testrunner/get_info.py
+++ b/testrunner/get_info.py
@@ -10,9 +10,10 @@
 BASE_DIR = os.path.abspath(os.path.dirname(os.path.dirname(__file__)))
 if sys.platform.startswith('win'):
 TARGET_NAME = r'pypy-c.exe'
-TARGET_DIR = 'Scripts'
+# PyPy uses bin as of PR https://github.com/pypa/virtualenv/pull/1400
+TARGET_DIR = 'bin'
 else:
-TARGET_NAME = 'pypy-c'
+TARGET_NAME = 'pypy3-c'
 TARGET_DIR = 'bin'
 VENV_DIR = 'pypy-venv'
 
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: Fix for 19e211d4c76b (oops, sorry)

2019-07-25 Thread arigo
Author: Armin Rigo 
Branch: 
Changeset: r97025:2315521d2c5d
Date: 2019-07-25 14:07 +0200
http://bitbucket.org/pypy/pypy/changeset/2315521d2c5d/

Log:Fix for 19e211d4c76b (oops, sorry)

diff --git a/rpython/rtyper/lltypesystem/rffi.py 
b/rpython/rtyper/lltypesystem/rffi.py
--- a/rpython/rtyper/lltypesystem/rffi.py
+++ b/rpython/rtyper/lltypesystem/rffi.py
@@ -1365,12 +1365,11 @@
 
 class scoped_nonmoving_unicodebuffer:
 def __init__(self, data):
-self.data = data
+self.buf, self.llobj, self.flag = get_nonmoving_unicodebuffer_ll(data)
 def __enter__(self):
-self.buf, self.flag = get_nonmoving_unicodebuffer(self.data)
 return self.buf
 def __exit__(self, *args):
-free_nonmoving_unicodebuffer(self.data, self.buf, self.flag)
+free_nonmoving_unicodebuffer_ll(self.buf, self.llobj, self.flag)
 __init__._always_inline_ = 'try'
 __enter__._always_inline_ = 'try'
 __exit__._always_inline_ = 'try'
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
@@ -917,6 +917,15 @@
 assert buf[2] == 'r'
 assert buf[3] == '\x00'
 
+def test_scoped_nonmoving_unicodebuffer():
+s = u'bar'
+with scoped_nonmoving_unicodebuffer(s) as buf:
+assert buf[0] == u'b'
+assert buf[1] == u'a'
+assert buf[2] == u'r'
+with py.test.raises(IndexError):
+buf[3]
+
 def test_wcharp2utf8n():
 w = 'hello\x00\x00\x00\x00'
 u, i = wcharp2utf8n(w, len(w))
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: fix tabs, whatsnew

2019-07-16 Thread mattip
Author: Matti Picus 
Branch: 
Changeset: r97007:624e331a6fa0
Date: 2019-07-16 06:57 -0500
http://bitbucket.org/pypy/pypy/changeset/624e331a6fa0/

Log:fix tabs, whatsnew

diff --git a/pypy/doc/whatsnew-head.rst b/pypy/doc/whatsnew-head.rst
--- a/pypy/doc/whatsnew-head.rst
+++ b/pypy/doc/whatsnew-head.rst
@@ -45,3 +45,12 @@
 Instead, replace it in ``rewrite.py`` with a direct call to ``memcpy()`` and
 new basic operation, ``load_effective_address``, which the backend can
 even decide not to implement.
+
+.. branch: arm64
+Add a JIT backend for ARM64 (aarch64)
+
+.. branch: fix-test-vmprof-closed-file
+
+
+.. branch: fix_darwin_list_dir_test
+
diff --git a/rpython/jit/backend/aarch64/assembler.py 
b/rpython/jit/backend/aarch64/assembler.py
--- a/rpython/jit/backend/aarch64/assembler.py
+++ b/rpython/jit/backend/aarch64/assembler.py
@@ -980,9 +980,9 @@
 
 def reserve_gcref_table(self, allgcrefs):
 gcref_table_size = len(allgcrefs) * WORD
-   # align to a multiple of 16 and reserve space at the beginning
-   # of the machine code for the gc table.  This lets us write
-   # machine code with relative addressing (LDR literal).
+# align to a multiple of 16 and reserve space at the beginning
+# of the machine code for the gc table.  This lets us write
+# machine code with relative addressing (LDR literal).
 gcref_table_size = (gcref_table_size + 15) & ~15
 mc = self.mc
 assert mc.get_relative_pos() == 0
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: fix test_unicode_outofrange in case itemsize == 2

2019-07-14 Thread joac...@bitbucket.org
Author: joachim-ballm...@bitbucket.org
Branch: 
Changeset: r96996:961477b88452
Date: 2019-07-14 12:40 +0200
http://bitbucket.org/pypy/pypy/changeset/961477b88452/

Log:fix test_unicode_outofrange in case itemsize == 2

diff --git a/pypy/module/array/test/test_array.py 
b/pypy/module/array/test/test_array.py
--- a/pypy/module/array/test/test_array.py
+++ b/pypy/module/array/test/test_array.py
@@ -860,16 +860,22 @@
 b.byteswap()
 assert b[2] == u'\u'
 assert a != b
-e = raises(ValueError, "b[0]")# doesn't work
-assert str(e.value) == (
-"cannot operate on this array('u') because it contains"
-" character U+100 not in range [U+; U+10]"
-" at index 0")
+if b.itemsize == 4:
+e = raises(ValueError, "b[0]")# doesn't work
+assert str(e.value) == (
+"cannot operate on this array('u') because it contains"
+" character U+100 not in range [U+; U+10]"
+" at index 0")
+assert str(b) == ("array('u', )")
+raises(ValueError, b.tounicode)   # doesn't work
+elif b.itemsize == 2:
+assert b[0] == u'\u0100'
+byteswaped_unicode = u'\u0100\u3a26\x00\ufffe'
+assert str(b) == "array('u', %r)" % (byteswaped_unicode,)
+assert b.tounicode() == byteswaped_unicode
 assert str(a) == "array('u', %r)" % (input_unicode,)
-assert str(b) == ("array('u', )")
 assert a.tounicode() == input_unicode
-raises(ValueError, b.tounicode)   # doesn't work
 
 def test_unicode_surrogate(self):
 a = self.array('u', u'\ud800')
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: Fix the test and the implementation of gcd_binary()

2019-07-14 Thread arigo
Author: Armin Rigo 
Branch: 
Changeset: r96988:c79c569bdd04
Date: 2019-07-14 10:50 +0200
http://bitbucket.org/pypy/pypy/changeset/c79c569bdd04/

Log:Fix the test and the implementation of gcd_binary()

diff --git a/rpython/rlib/rbigint.py b/rpython/rlib/rbigint.py
--- a/rpython/rlib/rbigint.py
+++ b/rpython/rlib/rbigint.py
@@ -2971,15 +2971,15 @@
 def gcd_binary(a, b):
 """ Compute the greatest common divisor of non-negative integers a and b
 using the binary GCD algorithm. Raises ValueError on negative input. """
+if a < 0 or b < 0:
+raise ValueError
+
 if a == 0:
 return b
 
 if b == 0:
 return a
 
-if a < 0 or b < 0:
-raise ValueError
-
 shift = 0
 while (a | b) & 1 == 0:
 a >>= 1
diff --git a/rpython/rlib/test/test_rbigint.py 
b/rpython/rlib/test/test_rbigint.py
--- a/rpython/rlib/test/test_rbigint.py
+++ b/rpython/rlib/test/test_rbigint.py
@@ -839,7 +839,7 @@
 
 def test_gcd(self):
 assert gcd_binary(2*3*7**2, 2**2*7) == 2*7
-assert gcd_binary(2*3*7**2, -2**2*7) == 2*7
+pytest.raises(ValueError, gcd_binary, 2*3*7**2, -2**2*7)
 assert gcd_binary(1234, 5678) == 2
 assert gcd_binary(13, 13**6) == 13
 assert gcd_binary(12, 0) == 12
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: fix vmprof for 32 bit linux

2019-06-18 Thread mattip
Author: Matti Picus 
Branch: 
Changeset: r96816:c3622918429e
Date: 2019-06-18 10:01 +0300
http://bitbucket.org/pypy/pypy/changeset/c3622918429e/

Log:fix vmprof for 32 bit linux

diff --git a/rpython/rlib/rvmprof/src/shared/vmp_stack.c 
b/rpython/rlib/rvmprof/src/shared/vmp_stack.c
--- a/rpython/rlib/rvmprof/src/shared/vmp_stack.c
+++ b/rpython/rlib/rvmprof/src/shared/vmp_stack.c
@@ -280,7 +280,7 @@
 // this is possible because compiler align to 8 bytes.
 //
 if (func_addr != 0x0) {
-depth = _write_native_stack((void*)(((uint64_t)func_addr) | 
0x1), result, depth, max_depth);
+depth = _write_native_stack((void*)(((intptr_t)func_addr) | 
0x1), result, depth, max_depth);
 }
 }
 
diff --git a/rpython/rlib/rvmprof/test/test_file.py 
b/rpython/rlib/rvmprof/test/test_file.py
--- a/rpython/rlib/rvmprof/test/test_file.py
+++ b/rpython/rlib/rvmprof/test/test_file.py
@@ -11,10 +11,11 @@
 def get_list_of_files(shared):
 files = list(shared.visit('*.[ch]'))
 # in PyPy we checkin the result of ./configure; as such, these files are
-# not in github and can be skipped
+# not in github or different and can be skipped
 files.remove(shared.join('libbacktrace', 'config-x86_32.h'))
 files.remove(shared.join('libbacktrace', 'config-x86_64.h'))
 files.remove(shared.join('libbacktrace', 'gstdint.h'))
+files.remove(shared.join('libbacktrace', 'config.h'))
 return files
 
 def test_same_file():
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: fix translation on arm

2019-06-17 Thread arigo
Author: Armin Rigo 
Branch: 
Changeset: r96810:c82849260828
Date: 2019-06-17 10:27 +0200
http://bitbucket.org/pypy/pypy/changeset/c82849260828/

Log:fix translation on arm

diff --git a/rpython/jit/backend/arm/opassembler.py 
b/rpython/jit/backend/arm/opassembler.py
--- a/rpython/jit/backend/arm/opassembler.py
+++ b/rpython/jit/backend/arm/opassembler.py
@@ -835,8 +835,9 @@
 assert 0
 
 def emit_op_load_effective_address(self, op, arglocs, regalloc, fcond):
-self._gen_address(arglocs[4], arglocs[0], arglocs[1], arglocs[3].value,
-  arglocs[2].value)
+static_ofs = op.getarg(2).getint()
+scale = op.getarg(3).getint()
+self._gen_address(arglocs[2], arglocs[0], arglocs[1], scale, 
static_ofs)
 return fcond
 
# result = base_loc  + (scaled_loc << scale) + static_offset
diff --git a/rpython/jit/backend/arm/regalloc.py 
b/rpython/jit/backend/arm/regalloc.py
--- a/rpython/jit/backend/arm/regalloc.py
+++ b/rpython/jit/backend/arm/regalloc.py
@@ -902,7 +902,7 @@
 arg0 = self.make_sure_var_in_reg(args[0], args)
 arg1 = self.make_sure_var_in_reg(args[1], args)
 res = self.force_allocate_reg(op)
-return [arg0, arg1, args[2], args[3], res]
+return [arg0, arg1, res]
 
 def prepare_op_call_malloc_nursery(self, op, fcond):
 size_box = op.getarg(0)
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: fix test as well

2019-06-12 Thread rlamy
Author: Ronan Lamy 
Branch: 
Changeset: r96801:e53c20a6841a
Date: 2019-06-12 15:28 +0100
http://bitbucket.org/pypy/pypy/changeset/e53c20a6841a/

Log:fix test as well

diff --git a/lib-python/2.7/test/test_timeit.py 
b/lib-python/2.7/test/test_timeit.py
--- a/lib-python/2.7/test/test_timeit.py
+++ b/lib-python/2.7/test/test_timeit.py
@@ -317,9 +317,9 @@
 def test_main_recommends_perf(self):
 s = self.run_main(seconds_per_increment=2.0, switches=['-n35', '-s', 
'print("CustomSetup")'])
 self.assertIn(dedent("""\
-WARNING: timeit is a very unreliable tool. use perf or something 
else for real measurements
+WARNING: timeit is a very unreliable tool. use pyperf or something 
else for real measurements
 """), s)
-self.assertIn("-m pip install perf", s)
+self.assertIn("-m pip install pyperf", s)
 
 
 
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: fix bug: when a newdict(instance=True) was switching its strategy, it lost its

2019-05-28 Thread cfbolz
Author: Carl Friedrich Bolz-Tereick 
Branch: 
Changeset: r96711:e19e79b1385f
Date: 2019-05-28 12:22 +0200
http://bitbucket.org/pypy/pypy/changeset/e19e79b1385f/

Log:fix bug: when a newdict(instance=True) was switching its strategy,
it lost its content

diff --git a/pypy/objspace/std/dictmultiobject.py 
b/pypy/objspace/std/dictmultiobject.py
--- a/pypy/objspace/std/dictmultiobject.py
+++ b/pypy/objspace/std/dictmultiobject.py
@@ -78,8 +78,9 @@
 W_ModuleDictObject.__init__(w_obj, space, strategy, storage)
 return w_obj
 elif instance:
-from pypy.objspace.std.mapdict import MapDictStrategy
-strategy = space.fromcache(MapDictStrategy)
+from pypy.objspace.std.mapdict import make_instance_dict
+assert w_type is None
+return make_instance_dict(space)
 elif strdict or module:
 assert w_type is None
 strategy = space.fromcache(BytesDictStrategy)
diff --git a/pypy/objspace/std/mapdict.py b/pypy/objspace/std/mapdict.py
--- a/pypy/objspace/std/mapdict.py
+++ b/pypy/objspace/std/mapdict.py
@@ -753,6 +753,7 @@
 self.space = space
 
 def get_empty_storage(self):
+# mainly used for tests
 w_result = Object()
 terminator = self.space.fromcache(get_terminator_for_dicts)
 w_result._mapdict_init_empty(terminator)
@@ -865,6 +866,11 @@
 def iteritems(self, w_dict):
 return MapDictIteratorItems(self.space, self, w_dict)
 
+def make_instance_dict(space):
+w_fake_object = Object()
+terminator = space.fromcache(get_terminator_for_dicts)
+w_fake_object._mapdict_init_empty(terminator)
+return w_fake_object.getdict(space)
 
 def materialize_r_dict(space, obj, dict_w):
 map = obj._get_mapdict_map()
diff --git a/pypy/objspace/std/test/test_mapdict.py 
b/pypy/objspace/std/test/test_mapdict.py
--- a/pypy/objspace/std/test/test_mapdict.py
+++ b/pypy/objspace/std/test/test_mapdict.py
@@ -897,6 +897,17 @@
 d = x.__dict__
 assert list(__pypy__.reversed_dict(d)) == d.keys()[::-1]
 
+def test_bug_materialize_huge_dict(self):
+import __pypy__
+d = __pypy__.newdict("instance")
+for i in range(100):
+d[str(i)] = i
+assert len(d) == 100
+
+for key in d:
+assert d[key] == int(key)
+
+
 
 class AppTestWithMapDictAndCounters(object):
 spaceconfig = {"objspace.std.withmethodcachecounter": True}
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: fix test for extra ops after shadowstack-issue2722

2019-05-26 Thread mattip
Author: Matti Picus 
Branch: 
Changeset: r96697:597a4f90a1b1
Date: 2019-05-27 08:53 +0300
http://bitbucket.org/pypy/pypy/changeset/597a4f90a1b1/

Log:fix test for extra ops after shadowstack-issue2722

diff --git a/pypy/module/pypyjit/test_pypy_c/test_ffi.py 
b/pypy/module/pypyjit/test_pypy_c/test_ffi.py
--- a/pypy/module/pypyjit/test_pypy_c/test_ffi.py
+++ b/pypy/module/pypyjit/test_pypy_c/test_ffi.py
@@ -425,9 +425,11 @@
 setarrayitem_raw(i153, 0, i106, descr=...)
 p156 = getfield_gc_r(p48, descr=...)
 i158 = getfield_raw_i(..., descr=...)
+i160 = int_sub(i158, 16)
+setfield_raw(#, i160, descr=...)
 setfield_gc(p48, p49, descr=...)
 setfield_gc(p134, ConstPtr(null), descr=...)
-i160 = int_lt(i158, 0)
+i160 = int_lt(i160, 0)
 guard_false(i160, descr=...)
 jump(..., descr=...)
 """)
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: fix more tests

2019-05-25 Thread mattip
Author: Matti Picus 
Branch: 
Changeset: r96674:48ae5caa94b0
Date: 2019-05-25 09:45 +0300
http://bitbucket.org/pypy/pypy/changeset/48ae5caa94b0/

Log:fix more tests

diff --git a/lib_pypy/_hashlib/__init__.py b/lib_pypy/_hashlib/__init__.py
--- a/lib_pypy/_hashlib/__init__.py
+++ b/lib_pypy/_hashlib/__init__.py
@@ -57,7 +57,7 @@
 
 def update(self, string):
 if isinstance(string, unicode):
-buf = ffi.from_buffer(string.encode('utf-8'))
+buf = ffi.from_buffer(string.encode('ascii'))
 else:
 buf = ffi.from_buffer(string)
 with self.lock:
diff --git a/pypy/module/_md5/test/test_md5.py 
b/pypy/module/_md5/test/test_md5.py
--- a/pypy/module/_md5/test/test_md5.py
+++ b/pypy/module/_md5/test/test_md5.py
@@ -24,7 +24,8 @@
 assert self.md5.md5().digest_size == 16
 if sys.version_info >= (2, 5):
 assert self.md5.blocksize == 1
-assert self.md5.md5().digestsize == 16
+# implementation detail, not part of the API
+# assert self.md5.md5().digestsize == 16
 
 def test_MD5Type(self):
 """
diff --git a/pypy/module/_sha/test/test_sha.py 
b/pypy/module/_sha/test/test_sha.py
--- a/pypy/module/_sha/test/test_sha.py
+++ b/pypy/module/_sha/test/test_sha.py
@@ -23,7 +23,8 @@
 assert self.sha.digestsize == 20
 d = self.sha.sha()
 assert d.digest_size == 20
-assert d.digestsize == 20
+# implementation detail, not part of the API
+# assert d.digestsize == 20
 
 def test_SHAType(self):
 """
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: fix translation for MSVC which doesn't like void* arithmetic

2019-05-10 Thread mattip
Author: Matti Picus 
Branch: 
Changeset: r96592:d4c7063c42e8
Date: 2019-05-10 06:14 -0700
http://bitbucket.org/pypy/pypy/changeset/d4c7063c42e8/

Log:fix translation for MSVC which doesn't like void* arithmetic

diff --git a/rpython/translator/c/gc.py b/rpython/translator/c/gc.py
--- a/rpython/translator/c/gc.py
+++ b/rpython/translator/c/gc.py
@@ -461,10 +461,10 @@
 raise Exception("gc_pop_roots should be removed by postprocess_graph")
 
 def OP_GC_ENTER_ROOTS_FRAME(self, funcgen, op):
-return '%s += sizeof(pypy_ss_t);' % (funcgen.gcpol_ss,)
+return '(char *)(%s) += sizeof(pypy_ss_t);' % (funcgen.gcpol_ss,)
 
 def OP_GC_LEAVE_ROOTS_FRAME(self, funcgen, op):
-return '%s -= sizeof(pypy_ss_t);' % (funcgen.gcpol_ss,)
+return 'char *)(%s) -= sizeof(pypy_ss_t);' % (funcgen.gcpol_ss,)
 
 def OP_GC_SAVE_ROOT(self, funcgen, op):
 num = op.args[0].value
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: fix for issue #3012, if no \r no need to translate

2019-05-06 Thread mattip
Author: Matti Picus 
Branch: 
Changeset: r96572:436eebe7adb1
Date: 2019-05-06 21:52 -0400
http://bitbucket.org/pypy/pypy/changeset/436eebe7adb1/

Log:fix for issue #3012, if no \r no need to translate

diff --git a/pypy/module/_io/interp_textio.py b/pypy/module/_io/interp_textio.py
--- a/pypy/module/_io/interp_textio.py
+++ b/pypy/module/_io/interp_textio.py
@@ -105,16 +105,10 @@
 # desired, all in one pass.
 seennl = self.seennl
 
-# If, up to now, newlines are consistently \n, do a quick check
-# for the \r
-only_lf = False
-if seennl == SEEN_LF or seennl == 0:
-only_lf = (output.find('\r') < 0)
-
-if only_lf:
-# If not already seen, quick scan for a possible "\n" character.
+if output.find('\r') < 0:
+# If no \r, quick scan for a possible "\n" character.
 # (there's nothing else to be done, even when in translation mode)
-if seennl == 0 and output.find('\n') >= 0:
+if output.find('\n') >= 0:
 seennl |= SEEN_LF
 # Finished: we have scanned for newlines, and none of them
 # need translating.
diff --git a/pypy/module/_io/test/test_textio.py 
b/pypy/module/_io/test/test_textio.py
--- a/pypy/module/_io/test/test_textio.py
+++ b/pypy/module/_io/test/test_textio.py
@@ -377,3 +377,13 @@
 _check(dec)
 dec = _io.IncrementalNewlineDecoder(None, translate=True)
 _check(dec)
+
+def test_newlines2(self):
+import _io, codecs
+inner_decoder = codecs.getincrementaldecoder("utf-8")()
+decoder = _io.IncrementalNewlineDecoder(inner_decoder, translate=True)
+msg = b"abc\r\n\n\r\r\n\n"
+decoded = ''
+for ch in msg:
+decoded += decoder.decode(ch)
+assert set(decoder.newlines) == {"\r", "\n", "\r\n"}
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: fix semaphore deadlock in issue 2953

2019-04-30 Thread mattip
Author: Matti Picus 
Branch: 
Changeset: r96566:6187f28f2baf
Date: 2019-04-30 09:32 -0400
http://bitbucket.org/pypy/pypy/changeset/6187f28f2baf/

Log:fix semaphore deadlock in issue 2953

diff --git a/pypy/doc/whatsnew-head.rst b/pypy/doc/whatsnew-head.rst
--- a/pypy/doc/whatsnew-head.rst
+++ b/pypy/doc/whatsnew-head.rst
@@ -16,3 +16,8 @@
 .. branch: datetime_api_27
 
 Add ``DateTime_FromTimestamp`` and ``Date_FromTimestamp``
+
+.. branch: semlock-deadlock
+
+Test and reduce the probability of a deadlock when acquiring a semaphore by
+moving global state changes closer to the actual aquire.
diff --git a/pypy/module/_multiprocessing/interp_semaphore.py 
b/pypy/module/_multiprocessing/interp_semaphore.py
--- a/pypy/module/_multiprocessing/interp_semaphore.py
+++ b/pypy/module/_multiprocessing/interp_semaphore.py
@@ -46,7 +46,8 @@
 eci = ExternalCompilationInfo(
 includes = ['sys/time.h',
 'limits.h',
-'semaphore.h'],
+'semaphore.h',
+],
 libraries = libraries,
 )
 
@@ -259,6 +260,8 @@
 res = rwin32.WaitForSingleObject(self.handle, 0)
 
 if res != rwin32.WAIT_TIMEOUT:
+self.last_tid = rthread.get_ident()
+self.count += 1
 return True
 
 msecs = full_msecs
@@ -291,6 +294,8 @@
 
 # handle result
 if res != rwin32.WAIT_TIMEOUT:
+self.last_tid = rthread.get_ident()
+self.count += 1
 return True
 return False
 
@@ -369,8 +374,9 @@
 elif e.errno in (errno.EAGAIN, errno.ETIMEDOUT):
 return False
 raise
-_check_signals(space)
-
+_check_signals(space)
+self.last_tid = rthread.get_ident()
+self.count += 1
 return True
 finally:
 if deadline:
@@ -439,6 +445,7 @@
 self.count = 0
 self.maxvalue = maxvalue
 self.register_finalizer(space)
+self.last_tid = -1
 
 def kind_get(self, space):
 return space.newint(self.kind)
@@ -476,15 +483,15 @@
 if self.kind == RECURSIVE_MUTEX and self._ismine():
 self.count += 1
 return space.w_True
-
 try:
+# sets self.last_tid and increments self.count
+# those steps need to be as close as possible to
+# acquiring the semlock for self._ismine() to support
+# multiple threads 
 got = semlock_acquire(self, space, block, w_timeout)
 except OSError as e:
 raise wrap_oserror(space, e)
-
 if got:
-self.last_tid = rthread.get_ident()
-self.count += 1
 return space.w_True
 else:
 return space.w_False
@@ -501,10 +508,10 @@
 
 try:
 semlock_release(self, space)
+self.count -= 1
 except OSError as e:
 raise wrap_oserror(space, e)
 
-self.count -= 1
 
 def after_fork(self):
 self.count = 0
diff --git a/pypy/module/_multiprocessing/test/test_semaphore.py 
b/pypy/module/_multiprocessing/test/test_semaphore.py
--- a/pypy/module/_multiprocessing/test/test_semaphore.py
+++ b/pypy/module/_multiprocessing/test/test_semaphore.py
@@ -17,6 +17,7 @@
 def setup_class(cls):
 cls.w_SEMAPHORE = cls.space.wrap(SEMAPHORE)
 cls.w_RECURSIVE = cls.space.wrap(RECURSIVE_MUTEX)
+cls.w_runappdirect = cls.space.wrap(cls.runappdirect)
 
 def test_semaphore(self):
 from _multiprocessing import SemLock
@@ -108,3 +109,25 @@
 with sem:
 assert sem._count() == 1
 assert sem._count() == 0
+
+def test_in_threads(self):
+from _multiprocessing import SemLock
+from threading import Thread
+from time import sleep
+l = SemLock(0, 1, 1)
+if self.runappdirect:
+def f(id):
+for i in range(1):
+pass
+else:
+def f(id):
+for i in range(1000):
+# reduce the probability of thread switching
+# at exactly the wrong time in semlock_acquire
+for j in range(10):
+pass
+threads = [Thread(None, f, args=(i,)) for i in range(2)]
+[t.start() for t in threads]
+# if the RLock calls to sem_wait and sem_post do not match,
+# one of the threads will block and the call to join will fail
+[t.join() for t in threads]
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: fix test

2019-04-18 Thread arigo
Author: Armin Rigo 
Branch: 
Changeset: r96516:d7c51628e606
Date: 2019-04-18 11:19 +0200
http://bitbucket.org/pypy/pypy/changeset/d7c51628e606/

Log:fix test

diff --git a/pypy/module/pypyjit/test_pypy_c/test_string.py 
b/pypy/module/pypyjit/test_pypy_c/test_string.py
--- a/pypy/module/pypyjit/test_pypy_c/test_string.py
+++ b/pypy/module/pypyjit/test_pypy_c/test_string.py
@@ -43,9 +43,9 @@
 guard_no_exception(descr=...)
 i100 = int_lt(i98, 0)
 guard_true(i100, descr=...)
-i102 = 
call_i(ConstClass(_ll_4_str_eq_slice_char__rpy_stringPtr_Signed_Signed_Char), 
p55, i83, 1, i89, descr=)
+i102 = 
call_i(ConstClass(_ll_4_str_eq_slice_char__rpy_stringPtr_Signed_Signed_Char), 
p13, i83, 1, i89, descr=)
 guard_true(i102, descr=...)
-i104 = int_add(i74, 1)
+i104 = int_add(i6, 1)
 --TICK--
 jump(..., descr=...)
 """ % (-sys.maxint-1,))
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: fix formatting of release note

2019-04-14 Thread mattip
Author: Matti Picus 
Branch: 
Changeset: r96492:aad43009d972
Date: 2019-04-14 23:52 +0300
http://bitbucket.org/pypy/pypy/changeset/aad43009d972/

Log:fix formatting of release note

diff --git a/pypy/doc/release-v7.1.1.rst b/pypy/doc/release-v7.1.1.rst
--- a/pypy/doc/release-v7.1.1.rst
+++ b/pypy/doc/release-v7.1.1.rst
@@ -68,10 +68,11 @@
 Changelog
 =
 
-Changes shared across versions
-* improve performance of ``u''.append``
+Changes shared across versions:
+
+* Improve performance of ``u''.append``
 * Prevent a crash in ``zlib`` when flushing a closed stream
-* Fix a few corener cases when encountering unicode values above 0x11
+* Fix a few corner cases when encountering unicode values above 0x11
 * Teach the JIT how to handle very large constant lists, sets, or dicts
 * Fix building on ARM32 (issue 2984_)
 * Fix a bug in register assignment in ARM32
@@ -81,9 +82,9 @@
 * Fix memoryviews of ctype structures with padding, (cpython issue 32780_)
 * CFFI updated to as-yet-unreleased 1.12.3
 
-Python 3.6 only
+Python 3.6 only:
 
-* On win32, override some ``errno.E*`` values that were added to MSVC in v2010
+* Override some ``errno.E*`` values that were added to MSVC in v2010
   so that ``errno.E* == errno.WSAE*`` as in CPython
 * Do the same optimization that CPython does for ``(1, 2, 3, *a)`` (but at the
   AST level)
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: Fix the general testing for newstr(utf8, length_in_number_of_chars),

2019-04-13 Thread arigo
Author: Armin Rigo 
Branch: 
Changeset: r96454:1f16a5e43952
Date: 2019-04-13 15:36 +0200
http://bitbucket.org/pypy/pypy/changeset/1f16a5e43952/

Log:Fix the general testing for newstr(utf8, length_in_number_of_chars),
which *now* should work and complain if we give an invalid number of
chars.

Fix array.array for a place where invalid utf8 strings were still
being made, found by the above.

diff --git a/pypy/module/array/interp_array.py 
b/pypy/module/array/interp_array.py
--- a/pypy/module/array/interp_array.py
+++ b/pypy/module/array/interp_array.py
@@ -1053,21 +1053,17 @@
 code = r_uint(ord(item))
 # cpython will allow values > sys.maxunicode
 # while silently truncating the top bits
-if code <= r_uint(0x7F):
-# Encode ASCII
-item = chr(code)
-elif code <= r_uint(0x07FF):
-item = (chr((0xc0 | (code >> 6))) + 
-chr((0x80 | (code & 0x3f
-elif code <= r_uint(0x):
-item = (chr((0xe0 | (code >> 12))) +
-chr((0x80 | ((code >> 6) & 0x3f))) +
-chr((0x80 | (code & 0x3f
-else:
-item = (chr((0xf0 | (code >> 18)) & 0xff) +
-chr((0x80 | ((code >> 12) & 0x3f))) +
-chr((0x80 | ((code >> 6) & 0x3f))) +
-chr((0x80 | (code & 0x3f
+# For now I (arigo) am going to ignore that and
+# raise a ValueError always here, instead of getting
+# some invalid utf8-encoded string which makes things
+# potentially explode left and right.
+try:
+item = rutf8.unichr_as_utf8(code)
+except rutf8.OutOfRange:
+raise oefmt(space.w_ValueError,
+"cannot operate on this array('u') because it contains"
+" character %s not in range [U+; U+10]"
+" at index %d", 'U+%x' % code, idx)
 return space.newutf8(item, 1)
 assert 0, "unreachable"
 
diff --git a/pypy/module/array/test/test_array.py 
b/pypy/module/array/test/test_array.py
--- a/pypy/module/array/test/test_array.py
+++ b/pypy/module/array/test/test_array.py
@@ -851,7 +851,13 @@
 a = self.array('u', input_unicode)
 b = self.array('u', input_unicode)
 b.byteswap()
-assert a != b
+assert b[2] == u'\u'
+raises(ValueError, "b[1]")# doesn't work
+e = raises(ValueError, "a != b")  # doesn't work
+assert str(e.value) == (
+"cannot operate on this array('u') because it contains"
+" character U+100 not in range [U+; U+10]"
+" at index 0")
 assert str(a) == "array('u', %r)" % (input_unicode,)
 assert str(b) == ("array('u', )")
diff --git a/pypy/objspace/std/unicodeobject.py 
b/pypy/objspace/std/unicodeobject.py
--- a/pypy/objspace/std/unicodeobject.py
+++ b/pypy/objspace/std/unicodeobject.py
@@ -42,13 +42,10 @@
 self._length = length
 self._index_storage = rutf8.null_storage()
 if not we_are_translated():
-try:
-# best effort, too expensive to handle surrogates
-ulength = rutf8.codepoints_in_utf(utf8str)
-except:
-ulength = length 
-assert ulength == length
-
+# utf8str must always be a valid utf8 string, except maybe with
+# explicit surrogate characters---which .decode('utf-8') doesn't
+# special-case in Python 2, which is exactly what we want here
+assert length == len(utf8str.decode('utf-8'))
 
 
 @staticmethod
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: fix comment

2019-03-27 Thread arigo
Author: Armin Rigo 
Branch: 
Changeset: r96364:edb40dc4f969
Date: 2019-03-27 15:46 +0100
http://bitbucket.org/pypy/pypy/changeset/edb40dc4f969/

Log:fix comment

diff --git a/rpython/memory/gc/base.py b/rpython/memory/gc/base.py
--- a/rpython/memory/gc/base.py
+++ b/rpython/memory/gc/base.py
@@ -22,7 +22,7 @@
 prebuilt_gc_objects_are_static_roots = True
 can_usually_pin_objects = False
 object_minimal_size = 0
-gcflag_extra = 0   # or a real GC flag that is always 0 when not collecting
+gcflag_extra = 0   # or a dedicated GC flag that the GC initializes to 0
 _totalroots_rpy = 0   # for inspector.py
 
 def __init__(self, config, chunk_size=DEFAULT_CHUNK_SIZE,
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: Fix the "not we_are_translated()" path, almost never used

2019-03-27 Thread arigo
Author: Armin Rigo 
Branch: 
Changeset: r96361:8fba932de88a
Date: 2019-03-27 13:15 +0100
http://bitbucket.org/pypy/pypy/changeset/8fba932de88a/

Log:Fix the "not we_are_translated()" path, almost never used

diff --git a/pypy/module/gc/referents.py b/pypy/module/gc/referents.py
--- a/pypy/module/gc/referents.py
+++ b/pypy/module/gc/referents.py
@@ -20,7 +20,7 @@
 # inherits from W_Root for internal reasons.  Such instances don't
 # have a typedef at all (or have a null typedef after translation).
 if not we_are_translated():
-if not hasattr(w_obj, 'typedef'):
+if getattr(w_obj, 'typedef', None) is None:
 return None
 else:
 if w_obj is None or not w_obj.typedef:
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: fix merge from grafting issue2968

2019-03-14 Thread mattip
Author: Matti Picus 
Branch: 
Changeset: r96313:d3aefbf6dae7
Date: 2019-03-14 17:15 +0200
http://bitbucket.org/pypy/pypy/changeset/d3aefbf6dae7/

Log:fix merge from grafting issue2968

diff --git a/pypy/module/cpyext/test/test_tupleobject.py 
b/pypy/module/cpyext/test/test_tupleobject.py
--- a/pypy/module/cpyext/test/test_tupleobject.py
+++ b/pypy/module/cpyext/test/test_tupleobject.py
@@ -231,7 +231,6 @@
 # issue 2968: creating a subclass of tuple in C led to recursion
 # since the default tp_new needs to build a w_obj, but that needs
 # to call space.len_w, which needs to call tp_new.
-module = self.import_module('THPSize')
 module = self.import_extension('foo', [
 ("get_size", "METH_NOARGS",
  """
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: fix test

2019-03-11 Thread mattip
Author: Matti Picus 
Branch: 
Changeset: r96270:c035c7de5e39
Date: 2019-03-11 09:12 +0200
http://bitbucket.org/pypy/pypy/changeset/c035c7de5e39/

Log:fix test

diff --git a/lib_pypy/_ctypes/array.py b/lib_pypy/_ctypes/array.py
--- a/lib_pypy/_ctypes/array.py
+++ b/lib_pypy/_ctypes/array.py
@@ -257,7 +257,7 @@
 try:
 itemsize = struct.calcsize(fmt[1:])
 except:
-itemsize = len(buffer(obj[0]))
+itemsize = sizeof(obj[0])
 return __pypy__.newmemoryview(memoryview(self._buffer), itemsize, fmt, 
shape)
 
 ARRAY_CACHE = {}
diff --git a/pypy/module/__pypy__/test/test_newmemoryview.py 
b/pypy/module/__pypy__/test/test_newmemoryview.py
--- a/pypy/module/__pypy__/test/test_newmemoryview.py
+++ b/pypy/module/__pypy__/test/test_newmemoryview.py
@@ -19,7 +19,7 @@
 from __pypy__ import bufferable, newmemoryview
 class B(bufferable.bufferable):
 def __init__(self):
-self.data = bytearray('abc')
+self.data = bytearray(b'abc')
 
 def __buffer__(self, flags):
 return newmemoryview(memoryview(self.data), 1, 'B')
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: fix test from 275fd99e1c23 - __args__.keywords can be None or an empty list

2019-03-01 Thread mattip
Author: Matti Picus 
Branch: 
Changeset: r96195:739b9c69e036
Date: 2019-02-28 23:25 +0200
http://bitbucket.org/pypy/pypy/changeset/739b9c69e036/

Log:fix test from 275fd99e1c23 - __args__.keywords can be None or an
empty list

diff --git a/pypy/module/cpyext/methodobject.py 
b/pypy/module/cpyext/methodobject.py
--- a/pypy/module/cpyext/methodobject.py
+++ b/pypy/module/cpyext/methodobject.py
@@ -46,15 +46,15 @@
 _dealloc(space, py_obj)
 
 def w_kwargs_from_args(space, __args__):
-w_kwargs = None
-if __args__.keywords:
-# CCC: we should probably have a @jit.look_inside_iff if the
-# keyword count is constant, as we do in Arguments.unpack
-w_kwargs = space.newdict()
-for i in range(len(__args__.keywords)):
-key = __args__.keywords[i]
-w_obj = __args__.keywords_w[i]
-space.setitem(w_kwargs, space.newtext(key), w_obj)
+if __args__.keywords is None:
+return None
+# CCC: we should probably have a @jit.look_inside_iff if the
+# keyword count is constant, as we do in Arguments.unpack
+w_kwargs = space.newdict()
+for i in range(len(__args__.keywords)):
+key = __args__.keywords[i]
+w_obj = __args__.keywords_w[i]
+space.setitem(w_kwargs, space.newtext(key), w_obj)
 return w_kwargs
 
 class W_PyCFunctionObject(W_Root):
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: fix return values

2019-02-24 Thread mattip
Author: Matti Picus 
Branch: 
Changeset: r96152:b7859ce44de0
Date: 2019-02-25 08:23 +0200
http://bitbucket.org/pypy/pypy/changeset/b7859ce44de0/

Log:fix return values

diff --git a/pypy/module/cpyext/dictobject.py b/pypy/module/cpyext/dictobject.py
--- a/pypy/module/cpyext/dictobject.py
+++ b/pypy/module/cpyext/dictobject.py
@@ -73,7 +73,7 @@
  result_borrowed=True)
 def PyDict_GetItem(space, w_dict, w_key):
 if not isinstance(w_dict, W_DictMultiObject):
-raise PyErr_BadInternalCall(space)
+return None
 # NOTE: this works so far because all our dict strategies store
 # *values* as full objects, which stay alive as long as the dict is
 # alive and not modified.  So we can return a borrowed ref.
@@ -83,14 +83,14 @@
 @cpython_api([PyObject, PyObject, PyObject], rffi.INT_real, error=-1)
 def PyDict_SetItem(space, w_dict, w_key, w_obj):
 if not isinstance(w_dict, W_DictMultiObject):
-raise PyErr_BadInternalCall(space)
+PyErr_BadInternalCall(space)
 w_dict.setitem(w_key, w_obj)
 return 0
 
 @cpython_api([PyObject, PyObject], rffi.INT_real, error=-1)
 def PyDict_DelItem(space, w_dict, w_key):
 if not isinstance(w_dict, W_DictMultiObject):
-raise PyErr_BadInternalCall(space)
+PyErr_BadInternalCall(space)
 w_dict.descr_delitem(space, w_key)
 return 0
 
@@ -98,7 +98,7 @@
 def PyDict_SetItemString(space, w_dict, key_ptr, w_obj):
 w_key = space.newtext(rffi.charp2str(key_ptr))
 if not isinstance(w_dict, W_DictMultiObject):
-raise PyErr_BadInternalCall(space)
+PyErr_BadInternalCall(space)
 w_dict.setitem(w_key, w_obj)
 return 0
 
@@ -109,7 +109,7 @@
 char*, rather than a PyObject*."""
 w_key = space.newtext(rffi.charp2str(key))
 if not isinstance(w_dict, W_DictMultiObject):
-raise PyErr_BadInternalCall(space)
+return None
 # NOTE: this works so far because all our dict strategies store
 # *values* as full objects, which stay alive as long as the dict is
 # alive and not modified.  So we can return a borrowed ref.
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: fix when malloc() returns an address with the last bit set (arigato)

2019-02-24 Thread mattip
Author: Matti Picus 
Branch: 
Changeset: r96149:0bfaff4207c3
Date: 2019-02-24 20:25 +0200
http://bitbucket.org/pypy/pypy/changeset/0bfaff4207c3/

Log:fix when malloc() returns an address with the last bit set (arigato)

diff --git a/rpython/rtyper/lltypesystem/llarena.py 
b/rpython/rtyper/lltypesystem/llarena.py
--- a/rpython/rtyper/lltypesystem/llarena.py
+++ b/rpython/rtyper/lltypesystem/llarena.py
@@ -252,7 +252,7 @@
 
 def _cast_to_int(self, symbolic=False):
 assert not symbolic
-return self.arena._getid() + self.offset
+return rffi.cast(lltype.Signed, self.arena._getid() + self.offset)
 
 
 def getfakearenaaddress(addr):
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: fix

2019-02-21 Thread mattip
Author: Matti Picus 
Branch: 
Changeset: r96122:789d5650e3af
Date: 2019-02-21 12:56 +0200
http://bitbucket.org/pypy/pypy/changeset/789d5650e3af/

Log:fix

diff --git a/rpython/rlib/test/test_rutf8.py b/rpython/rlib/test/test_rutf8.py
--- a/rpython/rlib/test/test_rutf8.py
+++ b/rpython/rlib/test/test_rutf8.py
@@ -200,7 +200,7 @@
 
 def test_utf8_string_builder_bad_code():
 s = rutf8.Utf8StringBuilder()
-with pytest.raises(ValueError):
+with pytest.raises(rutf8.OutOfRange):
 s.append_code(0x11)
 assert s.build() == ''
 assert s.getlength() == 0
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: fix typo

2019-02-20 Thread cfbolz
Author: Carl Friedrich Bolz-Tereick 
Branch: 
Changeset: r96109:5dd4d5699b26
Date: 2019-02-20 10:22 +0100
http://bitbucket.org/pypy/pypy/changeset/5dd4d5699b26/

Log:fix typo

diff --git a/rpython/rtyper/lltypesystem/rffi.py 
b/rpython/rtyper/lltypesystem/rffi.py
--- a/rpython/rtyper/lltypesystem/rffi.py
+++ b/rpython/rtyper/lltypesystem/rffi.py
@@ -1065,7 +1065,7 @@
 index += 1
 w[index] = unichr(0)
 return w
-utf82charp._annenforceargs_ = [str, int, bool]
+utf82wcharp._annenforceargs_ = [str, int, bool]
 
 # char**
 CCHARPP = lltype.Ptr(lltype.Array(CCHARP, hints={'nolength': True}))
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: fix, use unicodehelper.wcharpsize2utf8 more widely

2019-02-19 Thread mattip
Author: Matti Picus 
Branch: 
Changeset: r96104:9ece3d54c956
Date: 2019-02-20 09:04 +0200
http://bitbucket.org/pypy/pypy/changeset/9ece3d54c956/

Log:fix, use unicodehelper.wcharpsize2utf8 more widely

diff --git a/pypy/interpreter/unicodehelper.py 
b/pypy/interpreter/unicodehelper.py
--- a/pypy/interpreter/unicodehelper.py
+++ b/pypy/interpreter/unicodehelper.py
@@ -537,14 +537,14 @@
 def wcharpsize2utf8(space, wcharp, size):
 """Safe version of rffi.wcharpsize2utf8.
 
-Raises app-level ValueError if any wchar value is outside the valid
+Raises app-level rutf8.OutOfRange if any wchar value is outside the valid
 codepoint range.
 """
 try:
 return rffi.wcharpsize2utf8(wcharp, size)
-except ValueError:
+except rutf8.OutOfRange as e:
 raise oefmt(space.w_ValueError,
-"character is not in range [U+; U+10]")
+"character %s is not in range [U+; U+10]", 'U+%x' % e.code)
 
 
 # 
diff --git a/pypy/module/cpyext/unicodeobject.py 
b/pypy/module/cpyext/unicodeobject.py
--- a/pypy/module/cpyext/unicodeobject.py
+++ b/pypy/module/cpyext/unicodeobject.py
@@ -18,7 +18,6 @@
 from pypy.module.cpyext.bytesobject import PyString_Check
 from pypy.module.sys.interp_encoding import setdefaultencoding
 from pypy.module._codecs.interp_codecs import CodecState
-from pypy.interpreter import unicodehelper
 from pypy.objspace.std import unicodeobject
 import sys
 
@@ -618,7 +617,7 @@
 errors = None
 
 state = space.fromcache(CodecState)
-result, _,  length, byteorder = unicodehelper.str_decode_utf_32_helper(
+result, _,  length, byteorder = str_decode_utf_32_helper(
 string, errors, final=True, errorhandler=state.decode_error_handler,
 byteorder=byteorder)
 if pbyteorder is not None:
@@ -641,7 +640,7 @@
 
 Returns 0 on success, -1 on failure.
 """
-u = rffi.wcharpsize2utf8(s, length)
+u = wcharpsize2utf8(space, s, length)
 if llerrors:
 errors = rffi.charp2str(llerrors)
 else:
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: Fix for pyarrow calling invalid macros

2019-02-19 Thread arigo
Author: Armin Rigo 
Branch: 
Changeset: r96085:4d4e7569ddd5
Date: 2019-02-19 09:50 +0100
http://bitbucket.org/pypy/pypy/changeset/4d4e7569ddd5/

Log:Fix for pyarrow calling invalid macros

diff --git a/pypy/module/cpyext/cdatetime.py b/pypy/module/cpyext/cdatetime.py
--- a/pypy/module/cpyext/cdatetime.py
+++ b/pypy/module/cpyext/cdatetime.py
@@ -296,25 +296,41 @@
 def PyDateTime_DATE_GET_HOUR(space, w_obj):
 """Return the hour, as an int from 0 through 23.
 """
-return space.int_w(space.getattr(w_obj, space.newtext("hour")))
+# w_obj must be a datetime.timedate object.  However, I've seen libraries
+# call this macro with a datetime.date object.  I think it returns
+# nonsense in CPython, but it doesn't crash.  We'll just return zero
+# in case there is no field 'hour'.
+try:
+return space.int_w(space.getattr(w_obj, space.newtext("hour")))
+except OperationError:
+return 0
 
 @cpython_api([rffi.VOIDP], rffi.INT_real, error=CANNOT_FAIL)
 def PyDateTime_DATE_GET_MINUTE(space, w_obj):
 """Return the minute, as an int from 0 through 59.
 """
-return space.int_w(space.getattr(w_obj, space.newtext("minute")))
+try:
+return space.int_w(space.getattr(w_obj, space.newtext("minute")))
+except OperationError:
+return 0 # see comments in PyDateTime_DATE_GET_HOUR
 
 @cpython_api([rffi.VOIDP], rffi.INT_real, error=CANNOT_FAIL)
 def PyDateTime_DATE_GET_SECOND(space, w_obj):
 """Return the second, as an int from 0 through 59.
 """
-return space.int_w(space.getattr(w_obj, space.newtext("second")))
+try:
+return space.int_w(space.getattr(w_obj, space.newtext("second")))
+except OperationError:
+return 0 # see comments in PyDateTime_DATE_GET_HOUR
 
 @cpython_api([rffi.VOIDP], rffi.INT_real, error=CANNOT_FAIL)
 def PyDateTime_DATE_GET_MICROSECOND(space, w_obj):
 """Return the microsecond, as an int from 0 through 99.
 """
-return space.int_w(space.getattr(w_obj, space.newtext("microsecond")))
+try:
+return space.int_w(space.getattr(w_obj, space.newtext("microsecond")))
+except OperationError:
+return 0 # see comments in PyDateTime_DATE_GET_HOUR
 
 @cpython_api([rffi.VOIDP], rffi.INT_real, error=CANNOT_FAIL)
 def PyDateTime_TIME_GET_HOUR(space, w_obj):
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: fix test

2019-02-18 Thread arigo
Author: Armin Rigo 
Branch: 
Changeset: r96043:991f167e4663
Date: 2019-02-18 09:35 +0100
http://bitbucket.org/pypy/pypy/changeset/991f167e4663/

Log:fix test

diff --git a/pypy/module/pypyjit/test_pypy_c/test_string.py 
b/pypy/module/pypyjit/test_pypy_c/test_string.py
--- a/pypy/module/pypyjit/test_pypy_c/test_string.py
+++ b/pypy/module/pypyjit/test_pypy_c/test_string.py
@@ -43,7 +43,7 @@
 guard_no_exception(descr=...)
 i100 = int_lt(i98, 0)
 guard_true(i100, descr=...)
-i102 = 
call_i(ConstClass(_ll_4_str_eq_slice_char__rpy_stringPtr_Signed_Signed_Char), 
p55, i83, 1, i87, descr=)
+i102 = 
call_i(ConstClass(_ll_4_str_eq_slice_char__rpy_stringPtr_Signed_Signed_Char), 
p55, i83, 1, i89, descr=)
 guard_true(i102, descr=...)
 i104 = int_add(i74, 1)
 --TICK--
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: fix

2019-02-17 Thread cfbolz
Author: Carl Friedrich Bolz-Tereick 
Branch: 
Changeset: r96037:b42bf472ce7d
Date: 2019-02-17 12:52 +0100
http://bitbucket.org/pypy/pypy/changeset/b42bf472ce7d/

Log:fix

diff --git a/pypy/objspace/std/iterobject.py b/pypy/objspace/std/iterobject.py
--- a/pypy/objspace/std/iterobject.py
+++ b/pypy/objspace/std/iterobject.py
@@ -116,6 +116,7 @@
 end = rutf8.next_codepoint_pos(w_seq._utf8, start)
 w_res = W_UnicodeObject(w_seq._utf8[start:end], 1)
 self.byteindex = end
+self.index += 1
 return w_res
 
 
diff --git a/pypy/objspace/std/test/test_unicodeobject.py 
b/pypy/objspace/std/test/test_unicodeobject.py
--- a/pypy/objspace/std/test/test_unicodeobject.py
+++ b/pypy/objspace/std/test/test_unicodeobject.py
@@ -48,6 +48,7 @@
 w_iter = space.iter(w_uni)
 w_char1 = w_iter.descr_next(space)
 w_char2 = w_iter.descr_next(space)
+py.test.raises(OperationError, w_iter.descr_next, space)
 assert w_uni._index_storage is old_index_storage
 assert space.eq_w(w_char1, w_uni._getitem_result(space, 0))
 assert space.eq_w(w_char2, w_uni._getitem_result(space, 1))
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: Fix version number of _cffi_backend (thanks matti)

2019-02-16 Thread arigo
Author: Armin Rigo 
Branch: 
Changeset: r96033:e29ffd88da0a
Date: 2019-02-16 21:28 +0100
http://bitbucket.org/pypy/pypy/changeset/e29ffd88da0a/

Log:Fix version number of _cffi_backend (thanks matti)

diff --git a/pypy/module/_cffi_backend/__init__.py 
b/pypy/module/_cffi_backend/__init__.py
--- a/pypy/module/_cffi_backend/__init__.py
+++ b/pypy/module/_cffi_backend/__init__.py
@@ -3,7 +3,7 @@
 from rpython.rlib import rdynload, clibffi
 from rpython.rtyper.lltypesystem import rffi
 
-VERSION = "1.12.0"
+VERSION = "1.12.1"
 
 FFI_DEFAULT_ABI = clibffi.FFI_DEFAULT_ABI
 try:
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: Fix test

2019-02-16 Thread arigo
Author: Armin Rigo 
Branch: 
Changeset: r96028:63c291824396
Date: 2019-02-16 15:17 +0100
http://bitbucket.org/pypy/pypy/changeset/63c291824396/

Log:Fix test

diff --git a/pypy/module/cpyext/test/test_typeobject.py 
b/pypy/module/cpyext/test/test_typeobject.py
--- a/pypy/module/cpyext/test/test_typeobject.py
+++ b/pypy/module/cpyext/test/test_typeobject.py
@@ -528,7 +528,8 @@
 
 py_type = rffi.cast(PyTypeObjectPtr, ref)
 assert py_type.c_tp_alloc
-assert from_ref(space, py_type.c_tp_mro).wrappeditems is w_class.mro_w
+w_tup = from_ref(space, py_type.c_tp_mro)
+assert space.fixedview(w_tup) == w_class.mro_w
 
 decref(space, ref)
 
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: Fix test

2019-02-16 Thread arigo
Author: Armin Rigo 
Branch: 
Changeset: r96027:7fad2f4ca232
Date: 2019-02-16 14:30 +0100
http://bitbucket.org/pypy/pypy/changeset/7fad2f4ca232/

Log:Fix test

diff --git a/pypy/module/cpyext/test/test_sequence.py 
b/pypy/module/cpyext/test/test_sequence.py
--- a/pypy/module/cpyext/test/test_sequence.py
+++ b/pypy/module/cpyext/test/test_sequence.py
@@ -5,7 +5,7 @@
 from pypy.module.cpyext.sequence import (
 PySequence_Fast, PySequence_Contains, PySequence_Index,
 PySequence_GetItem, PySequence_SetItem, PySequence_DelItem)
-from pypy.module.cpyext.pyobject import get_w_obj_and_decref
+from pypy.module.cpyext.pyobject import get_w_obj_and_decref, from_ref
 from pypy.module.cpyext.state import State
 import pytest
 
@@ -22,7 +22,7 @@
 assert api.PySequence_Fast(w_l, "message") is w_l
 
 py_result = api.PySequence_Fast_GET_ITEM(w_l, 1)
-w_result = get_w_obj_and_decref(space, py_result)
+w_result = from_ref(space, py_result)
 assert space.int_w(w_result) == 2
 assert api.PySequence_Fast_GET_SIZE(w_l) == 4
 
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: fix rsre_core.py (hard to test for, as it was working in non-translated tests but accidentally killing the second half of the method after translation)

2019-02-15 Thread arigo
Author: Armin Rigo 
Branch: 
Changeset: r96015:8d12729e7465
Date: 2019-02-15 12:45 +0100
http://bitbucket.org/pypy/pypy/changeset/8d12729e7465/

Log:fix rsre_core.py (hard to test for, as it was working in non-
translated tests but accidentally killing the second half of the
method after translation)

diff --git a/rpython/rlib/rsre/rsre_core.py b/rpython/rlib/rsre/rsre_core.py
--- a/rpython/rlib/rsre/rsre_core.py
+++ b/rpython/rlib/rsre/rsre_core.py
@@ -151,7 +151,10 @@
 # The following methods are provided to be overriden in
 # Utf8MatchContext.  The non-utf8 implementation is provided
 # by the FixedMatchContext abstract subclass, in order to use
-# the same @not_rpython safety trick as above.
+# the same @not_rpython safety trick as above.  If you get a
+# "not_rpython" error during translation, either consider
+# calling the methods xxx_indirect() instead of xxx(), or if
+# applicable add the @specializectx decorator.
 ZERO = 0
 @not_rpython
 def next(self, position):
@@ -460,8 +463,7 @@
 ptr = self.start_ptr
 if not self.next_char_ok(ctx, pattern, ptr, self.ppos3):
 return
-assert not isinstance(ctx, AbstractMatchContext)
-self.start_ptr = ctx.next(ptr)
+self.start_ptr = ctx.next_indirect(ptr)
 return self.find_first_result(ctx, pattern)
 
 def next_char_ok(self, ctx, pattern, ptr, ppos):
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: fix test, logic was backwards

2019-02-15 Thread mattip
Author: Matti Picus 
Branch: 
Changeset: r96012:98b12ab55f09
Date: 2019-02-15 12:21 +0200
http://bitbucket.org/pypy/pypy/changeset/98b12ab55f09/

Log:fix test, logic was backwards

diff --git a/rpython/rlib/test/test_rutf8.py b/rpython/rlib/test/test_rutf8.py
--- a/rpython/rlib/test/test_rutf8.py
+++ b/rpython/rlib/test/test_rutf8.py
@@ -152,7 +152,7 @@
 @example([u'\ud800', u'\udc00'])
 def test_surrogate_in_utf8(unichars):
 uni = ''.join([u.encode('utf8') for u in unichars])
-result = rutf8.surrogate_in_utf8(uni) < 0
+result = rutf8.surrogate_in_utf8(uni) >= 0
 expected = any(uch for uch in unichars if u'\ud800' <= uch <= u'\udfff')
 assert result == expected
 
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: fix test for linux 32

2019-02-12 Thread mattip
Author: Matti Picus 
Branch: 
Changeset: r95968:20486c92ed2a
Date: 2019-02-12 12:54 +0200
http://bitbucket.org/pypy/pypy/changeset/20486c92ed2a/

Log:fix test for linux 32

diff --git a/rpython/memory/gc/test/test_direct.py 
b/rpython/memory/gc/test/test_direct.py
--- a/rpython/memory/gc/test/test_direct.py
+++ b/rpython/memory/gc/test/test_direct.py
@@ -781,7 +781,7 @@
 def large_malloc():
 # malloc an object which is large enough to trigger a major 
collection
 threshold = self.gc.next_major_collection_threshold
-self.malloc(VAR, int(threshold/8))
+self.malloc(VAR, int(threshold/4))
 summary = debuglog.summary()
 debuglog.reset()
 return summary
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: fix broken links

2019-02-11 Thread antocuni
Author: Antonio Cuni 
Branch: 
Changeset: r95936:7d3116e601d5
Date: 2019-02-11 11:50 +0100
http://bitbucket.org/pypy/pypy/changeset/7d3116e601d5/

Log:fix broken links

diff --git a/pypy/doc/release-v7.0.0.rst b/pypy/doc/release-v7.0.0.rst
--- a/pypy/doc/release-v7.0.0.rst
+++ b/pypy/doc/release-v7.0.0.rst
@@ -19,11 +19,12 @@
 Until we can work with downstream providers to distribute builds with PyPy, we
 have made packages for some common packages `available as wheels`_.
 
-The GC `hooks`_ , which can be used to gain more insights into its
+The `GC hooks`_ , which can be used to gain more insights into its
 performance, has been improved and it is now possible to manually manage the
 GC by using a combination of ``gc.disable`` and ``gc.collect_step``. See the
 `GC blog post`_.
 
+.. _`GC hooks`: 
http://doc.pypy.org/en/latest/gc_info.html#semi-manual-gc-management
 
 We updated the `cffi`_ module included in PyPy to version 1.12, and the
 `cppyy`_ backend to 1.4. Please use these to wrap your C and C++ code,
@@ -49,7 +50,7 @@
 
 We would also like to thank our contributors and encourage new people to join
 the project. PyPy has many layers and we need help with all of them: `PyPy`_
-and `RPython`_ documentation improvements, tweaking popular `modules`_ to run
+and `RPython`_ documentation improvements, tweaking popular modules to run
 on pypy, or general `help`_ with making RPython's JIT even better.
 
 .. _`PyPy`: index.html
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: fix version in the release announcement

2019-02-08 Thread antocuni
Author: Antonio Cuni 
Branch: 
Changeset: r95899:7ba58d0d1973
Date: 2019-02-08 12:10 +0100
http://bitbucket.org/pypy/pypy/changeset/7ba58d0d1973/

Log:fix version in the release announcement

diff --git a/pypy/doc/release-v7.0.0.rst b/pypy/doc/release-v7.0.0.rst
--- a/pypy/doc/release-v7.0.0.rst
+++ b/pypy/doc/release-v7.0.0.rst
@@ -39,7 +39,7 @@
 
 The utf8 branch that changes internal representation of unicode to utf8 did not
 make it into the release, so there is still more goodness coming.
-You can download the v6.0 releases here:
+You can download the v7.0 releases here:
 
 http://pypy.org/download.html
 
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: Fix for revdb (how to test??)

2019-01-30 Thread arigo
Author: Armin Rigo 
Branch: 
Changeset: r95754:04dfff1c783a
Date: 2019-01-31 00:42 +0100
http://bitbucket.org/pypy/pypy/changeset/04dfff1c783a/

Log:Fix for revdb (how to test??)

diff --git a/rpython/rlib/src/boehm-rawrefcount.c 
b/rpython/rlib/src/boehm-rawrefcount.c
--- a/rpython/rlib/src/boehm-rawrefcount.c
+++ b/rpython/rlib/src/boehm-rawrefcount.c
@@ -191,6 +191,7 @@
 #endif
 assert(result->ob_refcnt == REFCNT_FROM_PYPY);
 result->ob_refcnt = 1;
+result->ob_pypy_link = 0;
 p->pyobj = NULL;
 *pp = p->next_in_bucket;
 p->next_in_bucket = hash_free_list;
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: fix the version

2019-01-25 Thread antocuni
Author: Antonio Cuni 
Branch: 
Changeset: r95727:a5bef2990aeb
Date: 2019-01-25 16:36 +0100
http://bitbucket.org/pypy/pypy/changeset/a5bef2990aeb/

Log:fix the version

diff --git a/pypy/module/cpyext/include/patchlevel.h 
b/pypy/module/cpyext/include/patchlevel.h
--- a/pypy/module/cpyext/include/patchlevel.h
+++ b/pypy/module/cpyext/include/patchlevel.h
@@ -32,7 +32,7 @@
  * module/sys/version.py
  * doc/conf.py
  */
-#define PYPY_VERSION "7.1.0"
+#define PYPY_VERSION "7.1.0-alpha0"
 #define PYPY_VERSION_NUM  0x0701
 /* Defined to mean a PyPy where cpyext holds more regular references
to PyObjects, e.g. staying alive as long as the internal PyPy object
diff --git a/pypy/module/sys/version.py b/pypy/module/sys/version.py
--- a/pypy/module/sys/version.py
+++ b/pypy/module/sys/version.py
@@ -13,7 +13,7 @@
 # make sure to keep PYPY_VERSION in sync with:
 #module/cpyext/include/patchlevel.h
 #doc/conf.py
-PYPY_VERSION   = (7, 1, 0, "alpha0", 0)
+PYPY_VERSION   = (7, 1, 0, "alpha", 0)
 
 
 import pypy
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: fix the test to match 432d816c6d7b

2019-01-19 Thread arigo
Author: Armin Rigo 
Branch: 
Changeset: r95673:de85e0ef8bdc
Date: 2019-01-19 18:06 +0100
http://bitbucket.org/pypy/pypy/changeset/de85e0ef8bdc/

Log:fix the test to match 432d816c6d7b

diff --git a/rpython/memory/gc/test/test_direct.py 
b/rpython/memory/gc/test/test_direct.py
--- a/rpython/memory/gc/test/test_direct.py
+++ b/rpython/memory/gc/test/test_direct.py
@@ -774,7 +774,7 @@
 def test_collect_0(self, debuglog):
 self.gc.collect(1) # start a major
 debuglog.reset()
-self.gc.collect(0) # do ONLY a minor
+self.gc.collect(-1) # do ONLY a minor
 assert debuglog.summary() == {'gc-minor': 1}
 
 def test_enable_disable(self, debuglog):
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: Fix the tests for #2904

2019-01-13 Thread arigo
Author: Armin Rigo 
Branch: 
Changeset: r95628:d0187cf2f1b7
Date: 2019-01-13 19:21 +0100
http://bitbucket.org/pypy/pypy/changeset/d0187cf2f1b7/

Log:Fix the tests for #2904

diff --git a/pypy/module/pypyjit/test_pypy_c/test_containers.py 
b/pypy/module/pypyjit/test_pypy_c/test_containers.py
--- a/pypy/module/pypyjit/test_pypy_c/test_containers.py
+++ b/pypy/module/pypyjit/test_pypy_c/test_containers.py
@@ -20,7 +20,7 @@
 assert log.result % 1000 == 0
 loop, = log.loops_by_filename(self.filepath)
 ops = loop.ops_by_id('look')
-assert log.opnames(ops) == []
+assert log.opnames(ops) == ['guard_nonnull_class']
 
 def test_identitydict(self):
 def fn(n):
diff --git a/pypy/module/pypyjit/test_pypy_c/test_instance.py 
b/pypy/module/pypyjit/test_pypy_c/test_instance.py
--- a/pypy/module/pypyjit/test_pypy_c/test_instance.py
+++ b/pypy/module/pypyjit/test_pypy_c/test_instance.py
@@ -254,6 +254,7 @@
 guard_no_exception(descr=...)
 i29 = int_lt(i26, 0)
 guard_true(i29, descr=...)
+guard_nonnull_class(p58, ConstClass(W_IntObject), descr=...)
 ''')
 assert loop.match_by_id('loadattr2', "")   # completely folded away
 
diff --git a/pypy/module/pypyjit/test_pypy_c/test_micronumpy.py 
b/pypy/module/pypyjit/test_pypy_c/test_micronumpy.py
--- a/pypy/module/pypyjit/test_pypy_c/test_micronumpy.py
+++ b/pypy/module/pypyjit/test_pypy_c/test_micronumpy.py
@@ -243,6 +243,8 @@
 f80 = raw_load_f(i67, i79, descr=)
 i81 = int_add(i71, 1)
 --TICK--
+i92 = int_le(i33, _)
+guard_true(i92, descr=...)
 jump(..., descr=...)
 """)
 
@@ -282,6 +284,8 @@
 f86 = float_add(f74, f85)
 i87 = int_add(i76, 1)
 --TICK--
+i98 = int_le(i36, _)
+guard_true(i98, descr=...)
 jump(..., descr=...)
 """)
 
@@ -389,6 +393,8 @@
 assert log.result == [0.] * N
 loop, = log.loops_by_filename(self.filepath)
 assert loop.match("""
+i4 = int_lt(i91, 0)
+guard_false(i4, descr=...)
 i92 = int_ge(i91, i37)
 guard_false(i92, descr=...)
 i93 = int_add(i91, 1)
diff --git a/pypy/module/pypyjit/test_pypy_c/test_misc.py 
b/pypy/module/pypyjit/test_pypy_c/test_misc.py
--- a/pypy/module/pypyjit/test_pypy_c/test_misc.py
+++ b/pypy/module/pypyjit/test_pypy_c/test_misc.py
@@ -113,6 +113,7 @@
 i12 = int_is_true(i4)
 guard_true(i12, descr=...)
 guard_not_invalidated(descr=...)
+guard_nonnull_class(p10, ConstClass(W_IntObject), descr=...)
 i10p = getfield_gc_i(p10, descr=...)
 i10 = int_mul_ovf(2, i10p)
 guard_no_overflow(descr=...)
@@ -148,6 +149,8 @@
 setfield_gc(p9, i17, descr=<.* .*W_XRangeIterator.inst_current .*>)
 guard_not_invalidated(descr=...)
 i18 = force_token()
+i83 = int_lt(0, i14)
+guard_true(i83, descr=...)
 i84 = int_sub(i14, 1)
 i21 = int_lt(i10, 0)
 guard_false(i21, descr=...)
@@ -175,12 +178,16 @@
 loop, = log.loops_by_filename(self.filepath)
 assert loop.match("""
 guard_not_invalidated?
+i80 = int_lt(i11, 0)
+guard_false(i80, descr=...)
 i16 = int_ge(i11, i12)
 guard_false(i16, descr=...)
 i20 = int_add(i11, 1)
 setfield_gc(p4, i20, descr=<.* 
.*W_AbstractSeqIterObject.inst_index .*>)
 guard_not_invalidated?
 i21 = force_token()
+i89 = int_lt(0, i9)
+guard_true(i89, descr=...)
 i88 = int_sub(i9, 1)
 i25 = int_ge(i11, i9)
 guard_false(i25, descr=...)
@@ -214,6 +221,8 @@
 setfield_gc(p4, i20, descr=<.* 
.*W_AbstractSeqIterObject.inst_index .*>)
 guard_not_invalidated?
 i21 = force_token()
+i94 = int_lt(0, i9)
+guard_true(i94, descr=...)
 i95 = int_sub(i9, 1)
 i23 = int_lt(i18, 0)
 guard_false(i23, descr=...)
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: Fix test

2019-01-08 Thread arigo
Author: Armin Rigo 
Branch: 
Changeset: r95587:0916788c705e
Date: 2019-01-08 09:10 +0100
http://bitbucket.org/pypy/pypy/changeset/0916788c705e/

Log:Fix test

diff --git a/pypy/module/pypyjit/test_pypy_c/test_ffi.py 
b/pypy/module/pypyjit/test_pypy_c/test_ffi.py
--- a/pypy/module/pypyjit/test_pypy_c/test_ffi.py
+++ b/pypy/module/pypyjit/test_pypy_c/test_ffi.py
@@ -407,6 +407,7 @@
 i138 = call_i(ConstClass(_ll_1_raw_malloc_varsize_zero__Signed), 6, 
descr=...)
 check_memory_error(i138)
 setfield_gc(p132, i138, descr=...)
+setfield_gc(p132, 0, descr=...)
 setfield_gc(p132, ConstPtr(ptr139), descr=...)
 setfield_gc(p132, -1, descr=...)
 setfield_gc(p0, p133, descr=...)
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: Fix for 708fbffab6a0

2018-12-07 Thread arigo
Author: Armin Rigo 
Branch: 
Changeset: r95435:b010806d20bf
Date: 2018-12-07 11:19 +0200
http://bitbucket.org/pypy/pypy/changeset/b010806d20bf/

Log:Fix for 708fbffab6a0

diff --git a/rpython/jit/metainterp/optimizeopt/rewrite.py 
b/rpython/jit/metainterp/optimizeopt/rewrite.py
--- a/rpython/jit/metainterp/optimizeopt/rewrite.py
+++ b/rpython/jit/metainterp/optimizeopt/rewrite.py
@@ -389,6 +389,8 @@
 def optimize_GUARD_SUBCLASS(self, op):
 info = self.getptrinfo(op.getarg(0))
 optimizer = self.optimizer
+# must raise 'InvalidLoop' in all cases where 'info' shows the
+# class cannot possibly match (see test_issue2926)
 if info and info.is_constant():
 c = self.get_box_replacement(op.getarg(0))
 vtable = optimizer.cpu.ts.cls_of_box(c).getint()
@@ -398,13 +400,29 @@
 if info is not None and info.is_about_object():
 known_class = info.get_known_class(optimizer.cpu)
 if known_class:
+# Class of 'info' is exactly 'known_class'.
+# We know statically if the 'guard_subclass' will pass or fail.
 if optimizer._check_subclass(known_class.getint(),
  op.getarg(1).getint()):
 return
+else:
+raise InvalidLoop(
+"GUARD_SUBCLASS(known_class) proven to always fail")
 elif info.get_descr() is not None:
-if optimizer._check_subclass(info.get_descr().get_vtable(),
+# Class of 'info' is either get_descr() or a subclass of it.
+# We're keeping the 'guard_subclass' at runtime only in the
+# case where get_descr() is some strict parent class of
+# the argument to 'guard_subclass'.
+info_base_descr = info.get_descr().get_vtable()
+if optimizer._check_subclass(info_base_descr,
  op.getarg(1).getint()):
-return
+return# guard_subclass always passing
+elif optimizer._check_subclass(op.getarg(1).getint(),
+   info_base_descr):
+pass  # don't know, must keep the 'guard_subclass'
+else:
+raise InvalidLoop(
+"GUARD_SUBCLASS(base_class) proven to always fail")
 return self.emit(op)
 
 def optimize_GUARD_NONNULL(self, op):
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: fix weird fallout of 74c1f4c8363d

2018-12-03 Thread cfbolz
Author: Carl Friedrich Bolz-Tereick 
Branch: 
Changeset: r95405:52c3040f147b
Date: 2018-12-03 09:39 +0100
http://bitbucket.org/pypy/pypy/changeset/52c3040f147b/

Log:fix weird fallout of 74c1f4c8363d

diff --git a/rpython/translator/backendopt/test/test_mallocprediction.py 
b/rpython/translator/backendopt/test/test_mallocprediction.py
--- a/rpython/translator/backendopt/test/test_mallocprediction.py
+++ b/rpython/translator/backendopt/test/test_mallocprediction.py
@@ -179,7 +179,7 @@
 t, graph = rtype(entry_point, [int])
 total0 = preparation(t, t.graphs)
 total = clever_inlining_and_malloc_removal(t)
-assert total0 + total == 10
+assert total0 + total == 9
 
 def test_loop():
 l = [10, 12, 15, 1]
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: fix test

2018-11-30 Thread cfbolz
Author: Carl Friedrich Bolz-Tereick 
Branch: 
Changeset: r95389:a2d417aec82f
Date: 2018-11-30 16:15 +0100
http://bitbucket.org/pypy/pypy/changeset/a2d417aec82f/

Log:fix test

diff --git a/rpython/translator/c/test/test_standalone.py 
b/rpython/translator/c/test/test_standalone.py
--- a/rpython/translator/c/test/test_standalone.py
+++ b/rpython/translator/c/test/test_standalone.py
@@ -521,11 +521,9 @@
 assert path.check(file=0)
 
 def test_debug_start_stop_timestamp(self):
-import sys
-import time
 from rpython.rlib.rtimer import read_timestamp
 def entry_point(argv):
-timestamp = int(argv[1])
+timestamp = bool(int(argv[1]))
 ts1 = debug_start("foo", timestamp=timestamp)
 ts2 = read_timestamp()
 ts3 = debug_stop("foo", timestamp=timestamp)
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: fix tests to pass on win32

2018-11-11 Thread mattip
Author: Matti Picus 
Branch: 
Changeset: r95297:956dce5d3456
Date: 2018-11-11 00:25 -0800
http://bitbucket.org/pypy/pypy/changeset/956dce5d3456/

Log:fix tests to pass on win32

diff --git a/pypy/module/posix/test/test_posix2.py 
b/pypy/module/posix/test/test_posix2.py
--- a/pypy/module/posix/test/test_posix2.py
+++ b/pypy/module/posix/test/test_posix2.py
@@ -211,9 +211,9 @@
 def test_pickle(self):
 import pickle, os
 st = self.posix.stat(os.curdir)
-print type(st).__module__
+# print type(st).__module__
 s = pickle.dumps(st)
-print repr(s)
+# print repr(s)
 new = pickle.loads(s)
 assert new == st
 assert type(new) is type(st)
@@ -303,7 +303,7 @@
 try:
 fid = posix.fdopen(fd)
 fid.read(10)
-except OSError as e:
+except (IOError, OSError) as e:
 assert e.errno == errno.EBADF
 else:
 assert False, "using result of fdopen(fd) on closed file must 
raise"
@@ -576,6 +576,12 @@
 assert '\nOSError: [Errno 9]' in res
 else:
 assert res == 'test1\n'
+if sys.platform == "win32":
+# using startfile in app_startfile creates global state
+test_popen.dont_track_allocations = True
+test_popen_with.dont_track_allocations = True
+test_popen_child_fds.dont_track_allocations = True
+
 
 if hasattr(__import__(os.name), '_getfullpathname'):
 def test__getfullpathname(self):
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: fix test on win32, also cleanup uneeded export of function from libpypy

2018-11-10 Thread mattip
Author: Matti Picus 
Branch: 
Changeset: r95291:286138f59bc3
Date: 2018-11-10 20:55 -0800
http://bitbucket.org/pypy/pypy/changeset/286138f59bc3/

Log:fix test on win32, also cleanup uneeded export of function from
libpypy

diff --git a/pypy/module/sys/initpath.py b/pypy/module/sys/initpath.py
--- a/pypy/module/sys/initpath.py
+++ b/pypy/module/sys/initpath.py
@@ -188,8 +188,8 @@
 #endif
 #include 
 #include 
+#include 
 
-RPY_EXPORTED
 char *_pypy_init_home(void)
 {
 HMODULE hModule = 0;
@@ -225,7 +225,6 @@
 #include 
 #include 
 
-RPY_EXPORTED
 char *_pypy_init_home(void)
 {
 Dl_info info;
@@ -243,11 +242,27 @@
 }
 """
 
+_source_code += """
+inline
+void _pypy_init_free(char *p)
+{
+free(p);
+}
+"""
+
+if we_are_translated():
+   post_include_bits = []
+else:
+# for tests 
+post_include_bits=['RPY_EXPORTED char *_pypy_init_home(void);',
+   'RPY_EXPORTED void _pypy_init_free(char*);',
+  ]
+
 _eci = ExternalCompilationInfo(separate_module_sources=[_source_code],
-post_include_bits=['RPY_EXPORTED char *_pypy_init_home(void);'])
+   post_include_bits=post_include_bits)
 _eci = _eci.merge(rdynload.eci)
 
 pypy_init_home = rffi.llexternal("_pypy_init_home", [], rffi.CCHARP,
  _nowrapper=True, compilation_info=_eci)
-pypy_init_free = rffi.llexternal("free", [rffi.CCHARP], lltype.Void,
+pypy_init_free = rffi.llexternal("_pypy_init_free", [rffi.CCHARP], lltype.Void,
  _nowrapper=True, compilation_info=_eci)
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: fix whatsnew

2018-10-27 Thread mattip
Author: Matti Picus 
Branch: 
Changeset: r95256:9b4df13073e1
Date: 2018-10-27 22:34 +0300
http://bitbucket.org/pypy/pypy/changeset/9b4df13073e1/

Log:fix whatsnew

diff --git a/pypy/doc/whatsnew-head.rst b/pypy/doc/whatsnew-head.rst
--- a/pypy/doc/whatsnew-head.rst
+++ b/pypy/doc/whatsnew-head.rst
@@ -39,3 +39,15 @@
 
 .. branch: fix-readme-typo
 
+.. branch: avoid_shell_injection_in_shutil
+
+Backport CPython fix for possible shell injection issue in `distutils.spawn`,
+https://bugs.python.org/issue34540
+
+.. branch: cffi_dlopen_unicode
+
+Enable use of unicode file names in `dlopen`
+
+.. branch: rlock-in-rpython
+
+Backport CPython fix for `thread.RLock` 
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: fix translation

2018-10-27 Thread mattip
Author: Matti Picus 
Branch: 
Changeset: r95257:e32a30711384
Date: 2018-10-27 22:34 +0300
http://bitbucket.org/pypy/pypy/changeset/e32a30711384/

Log:fix translation

diff --git a/pypy/module/thread/os_lock.py b/pypy/module/thread/os_lock.py
--- a/pypy/module/thread/os_lock.py
+++ b/pypy/module/thread/os_lock.py
@@ -195,7 +195,7 @@
 w_owner = space.getitem(self.w_active,
 space.newint(self.rlock_owner))
 w_name = space.getattr(w_owner, space.newtext('name'))
-owner = space.str_w(space.repr(w_name))
+owner = space.text_w(space.repr(w_name))
 except OperationError as e:
 if e.async(space):
 raise
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: fix test

2018-10-26 Thread arigo
Author: Armin Rigo 
Branch: 
Changeset: r95250:b01d1db30165
Date: 2018-10-26 12:01 +0200
http://bitbucket.org/pypy/pypy/changeset/b01d1db30165/

Log:fix test

diff --git a/pypy/module/cpyext/test/test_misc.py 
b/pypy/module/cpyext/test/test_misc.py
--- a/pypy/module/cpyext/test/test_misc.py
+++ b/pypy/module/cpyext/test/test_misc.py
@@ -16,7 +16,7 @@
 '''),
 ], prologue='''
 static long my_flag = 0;
-static int my_callback(void) { my_flag++; }
+static int my_callback(void) { return ++my_flag; }
 ''')
 
 try:
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: fix win32 translation, also remove some MSVC compiler warnings

2018-10-09 Thread mattip
Author: Matti Picus 
Branch: 
Changeset: r95196:0bd6514900a7
Date: 2018-10-09 17:23 +0300
http://bitbucket.org/pypy/pypy/changeset/0bd6514900a7/

Log:fix win32 translation, also remove some MSVC compiler warnings

diff --git a/pypy/module/_cffi_backend/embedding.py 
b/pypy/module/_cffi_backend/embedding.py
--- a/pypy/module/_cffi_backend/embedding.py
+++ b/pypy/module/_cffi_backend/embedding.py
@@ -95,7 +95,9 @@
 if os.name == 'nt':
 
 do_includes = r"""
+#ifndef _WIN32_WINNT
 #define _WIN32_WINNT 0x0501
+#endif
 #include 
 
 static void _cffi_init(void);
diff --git a/pypy/module/cpyext/api.py b/pypy/module/cpyext/api.py
--- a/pypy/module/cpyext/api.py
+++ b/pypy/module/cpyext/api.py
@@ -1554,6 +1554,9 @@
 }
 '''
 separate_module_sources.append(get_pythonapi_source)
+kwds['post_include_bits'] = [
+'RPY_EXTERN HANDLE pypy_get_pythonapi_handle();',
+]
 
 eci = ExternalCompilationInfo(
 include_dirs=include_dirs,
diff --git a/pypy/module/sys/initpath.py b/pypy/module/sys/initpath.py
--- a/pypy/module/sys/initpath.py
+++ b/pypy/module/sys/initpath.py
@@ -183,7 +183,9 @@
 if os.name == 'nt':
 
 _source_code = r"""
+#ifndef _WIN32_WINNT
 #define _WIN32_WINNT 0x0501
+#endif
 #include 
 #include 
 
diff --git a/rpython/rlib/rmmap.py b/rpython/rlib/rmmap.py
--- a/rpython/rlib/rmmap.py
+++ b/rpython/rlib/rmmap.py
@@ -835,7 +835,7 @@
 # assume -1 and 0 both mean invalid file descriptor
 # to 'anonymously' map memory.
 if fileno != -1 and fileno != 0:
-fh = rwin32.get_osfhandle(fileno)
+fh = rffi.cast(HANDLE, rwin32.get_osfhandle(fileno))
 # Win9x appears to need us seeked to zero
 # SEEK_SET = 0
 # libc._lseek(fileno, 0, SEEK_SET)
diff --git a/rpython/rlib/rposix.py b/rpython/rlib/rposix.py
--- a/rpython/rlib/rposix.py
+++ b/rpython/rlib/rposix.py
@@ -137,7 +137,10 @@
 RPY_EXTERN void exit_suppress_iph(void* handle) {};
 #endif
 ''',]
-post_include_bits=['RPY_EXTERN int _PyVerify_fd(int);']
+post_include_bits=['RPY_EXTERN int _PyVerify_fd(int);',
+   'RPY_EXTERN void* enter_suppress_iph();',
+   'RPY_EXTERN void exit_suppress_iph(void* handle);',
+  ]
 else:
 separate_module_sources = []
 post_include_bits = []
@@ -235,7 +238,8 @@
 rthread.tlfield_rpy_errno.setraw(_get_errno())
 # ^^^ keep fork() up-to-date too, below
 if _WIN32:
-includes = ['io.h', 'sys/utime.h', 'sys/types.h', 'process.h', 'time.h']
+includes = ['io.h', 'sys/utime.h', 'sys/types.h', 'process.h', 'time.h',
+'direct.h']
 libraries = []
 else:
 if sys.platform.startswith(('darwin', 'netbsd', 'openbsd')):
diff --git a/rpython/rlib/rwin32.py b/rpython/rlib/rwin32.py
--- a/rpython/rlib/rwin32.py
+++ b/rpython/rlib/rwin32.py
@@ -20,7 +20,7 @@
 
 if WIN32:
 eci = ExternalCompilationInfo(
-includes = ['windows.h', 'stdio.h', 'stdlib.h'],
+includes = ['windows.h', 'stdio.h', 'stdlib.h', 'io.h'],
 libraries = ['kernel32'],
 )
 else:
@@ -197,9 +197,9 @@
 LoadLibrary = winexternal('LoadLibraryA', [rffi.CCHARP], HMODULE,
   save_err=rffi.RFFI_SAVE_LASTERROR)
 def wrap_loadlibraryex(func):
-def loadlibrary(name, handle=None, 
flags=LOAD_WITH_ALTERED_SEARCH_PATH):
+def loadlibrary(name, flags=LOAD_WITH_ALTERED_SEARCH_PATH):
 # Requires a full path name with '/' -> '\\'
-return func(name, handle, flags)
+return func(name, NULL_HANDLE, flags)
 return loadlibrary
 
 _LoadLibraryExA = winexternal('LoadLibraryExA',
@@ -217,7 +217,7 @@
  rffi.VOIDP)
 FreeLibrary = winexternal('FreeLibrary', [HMODULE], BOOL, releasegil=False)
 
-LocalFree = winexternal('LocalFree', [HLOCAL], DWORD)
+LocalFree = winexternal('LocalFree', [HLOCAL], HLOCAL)
 CloseHandle = winexternal('CloseHandle', [HANDLE], BOOL, releasegil=False,
   save_err=rffi.RFFI_SAVE_LASTERROR)
 CloseHandle_no_err = winexternal('CloseHandle', [HANDLE], BOOL,
@@ -232,12 +232,12 @@
 [DWORD, rffi.VOIDP, DWORD, DWORD, rffi.CWCHARP, DWORD, rffi.VOIDP],
 DWORD)
 
-_get_osfhandle = rffi.llexternal('_get_osfhandle', [rffi.INT], HANDLE)
+_get_osfhandle = rffi.llexternal('_get_osfhandle', [rffi.INT], rffi.INTP)
 
 def get_osfhandle(fd):
 from rpython.rlib.rposix import FdValidator
 with FdValidator(fd):
-handle = _get_osfhandle(fd)
+handle = rffi.cast(HANDLE, _get_osfhandle(fd))
 if handle == INVALID_HANDLE_VALUE:
 raise WindowsError(ERROR_INVALID_HANDLE, "Invalid file handle")
 return handle
___
pypy-commit mailing list

[pypy-commit] pypy default: fix error message

2018-09-23 Thread arigo
Author: Armin Rigo 
Branch: 
Changeset: r95156:3c6307e2bd64
Date: 2018-09-23 13:07 +0200
http://bitbucket.org/pypy/pypy/changeset/3c6307e2bd64/

Log:fix error message

diff --git a/rpython/rlib/jit.py b/rpython/rlib/jit.py
--- a/rpython/rlib/jit.py
+++ b/rpython/rlib/jit.py
@@ -151,7 +151,7 @@
 if getattr(func, '_elidable_function_', False):
 raise TypeError("it does not make sense for %s to be both elidable and 
unroll_safe" % func)
 if not getattr(func, '_jit_look_inside_', True):
-raise TypeError("it does not make sense for %s to be both elidable and 
dont_look_inside" % func)
+raise TypeError("it does not make sense for %s to be both unroll_safe 
and dont_look_inside" % func)
 func._jit_unroll_safe_ = True
 return func
 
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: Fix the cpython test for newer pypy versions, with a comment

2018-09-19 Thread arigo
Author: Armin Rigo 
Branch: 
Changeset: r95148:c8d93fa469ba
Date: 2018-09-19 18:48 +0200
http://bitbucket.org/pypy/pypy/changeset/c8d93fa469ba/

Log:Fix the cpython test for newer pypy versions, with a comment

diff --git a/lib-python/2.7/test/test_inspect.py 
b/lib-python/2.7/test/test_inspect.py
--- a/lib-python/2.7/test/test_inspect.py
+++ b/lib-python/2.7/test/test_inspect.py
@@ -45,6 +45,9 @@
 
 git = mod.StupidGit()
 
+class ExampleClassWithSlot(object):
+__slots__ = 'myslot'
+
 class IsTestBase(unittest.TestCase):
 predicates = set([inspect.isbuiltin, inspect.isclass, inspect.iscode,
   inspect.isframe, inspect.isfunction, inspect.ismethod,
@@ -96,7 +99,11 @@
 else:
 
self.assertFalse(inspect.isgetsetdescriptor(type(tb.tb_frame).f_locals))
 if hasattr(types, 'MemberDescriptorType'):
-self.istest(inspect.ismemberdescriptor, 'type(lambda: 
None).func_globals')
+# App-level slots are member descriptors on both PyPy and
+# CPython, but the various built-in attributes are all
+# getsetdescriptors on PyPy.  So check ismemberdescriptor()
+# with an app-level slot.
+self.istest(inspect.ismemberdescriptor, 
'ExampleClassWithSlot.myslot')
 else:
 self.assertFalse(inspect.ismemberdescriptor(type(lambda: 
None).func_globals))
 
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: fix test

2018-09-19 Thread arigo
Author: Armin Rigo 
Branch: 
Changeset: r95145:4ffcc8f9acd4
Date: 2018-09-19 17:22 +0200
http://bitbucket.org/pypy/pypy/changeset/4ffcc8f9acd4/

Log:fix test

diff --git a/pypy/doc/whatsnew-head.rst b/pypy/doc/whatsnew-head.rst
--- a/pypy/doc/whatsnew-head.rst
+++ b/pypy/doc/whatsnew-head.rst
@@ -36,3 +36,6 @@
 .. branch: pyparser-improvements-3
 
 Small refactorings in the Python parser.
+
+.. branch: fix-readme-typo
+
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: fix issue #2873 in micronumpy, thanks Andreas

2018-08-21 Thread mattip
Author: Matti Picus 
Branch: 
Changeset: r95013:73d842283378
Date: 2018-08-21 18:16 +0300
http://bitbucket.org/pypy/pypy/changeset/73d842283378/

Log:fix issue #2873 in micronumpy, thanks Andreas

diff --git a/pypy/module/micronumpy/concrete.py 
b/pypy/module/micronumpy/concrete.py
--- a/pypy/module/micronumpy/concrete.py
+++ b/pypy/module/micronumpy/concrete.py
@@ -388,7 +388,7 @@
 not self.flags & NPY.ARRAY_F_CONTIGUOUS):
raise oefmt(errtype, "ndarray is not Fortran contiguous")
 if ((flags & space.BUF_ANY_CONTIGUOUS) == space.BUF_ANY_CONTIGUOUS and
-not (self.flags & NPY.ARRAY_F_CONTIGUOUS and
+not (self.flags & NPY.ARRAY_F_CONTIGUOUS or
  self.flags & NPY.ARRAY_C_CONTIGUOUS)):
raise oefmt(errtype, "ndarray is not contiguous")
 if ((flags & space.BUF_STRIDES) != space.BUF_STRIDES and
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: Fix issue with empty string as module attribute.

2018-08-08 Thread rlamy
Author: Ronan Lamy 
Branch: 
Changeset: r94980:8c0c734e9e02
Date: 2018-08-08 15:59 +0100
http://bitbucket.org/pypy/pypy/changeset/8c0c734e9e02/

Log:Fix issue with empty string as module attribute.

diff --git a/pypy/interpreter/pyopcode.py b/pypy/interpreter/pyopcode.py
--- a/pypy/interpreter/pyopcode.py
+++ b/pypy/interpreter/pyopcode.py
@@ -1628,7 +1628,7 @@
 else:
 skip_leading_underscores = False
 for name in all:
-if skip_leading_underscores and name[0]=='_':
+if skip_leading_underscores and name and name[0] == '_':
 continue
 into_locals[name] = getattr(module, name)
 ''', filename=__file__)
diff --git a/pypy/module/imp/test/test_import.py 
b/pypy/module/imp/test/test_import.py
--- a/pypy/module/imp/test/test_import.py
+++ b/pypy/module/imp/test/test_import.py
@@ -69,8 +69,8 @@
  foobar= "found = 123",
  barbaz= "other = 543")
 setuppkg("pkg.withoutall",
- __init__  = "",
- foobar= "found = 123")
+ __init__  = "globals()[''] = 456",
+ foobar= "found = 123\n")
 setuppkg("pkg.bogusall",
  __init__  = "__all__ = 42")
 setuppkg("pkg_r", inpkg = "import x.y")
@@ -373,7 +373,7 @@
 raises(ImportError, __import__, 'xxxbadmodule', fromlist=[u'xx'])
 mod = __import__('collections', fromlist=[u'defaultdict'])
 assert mod is not None
-
+
 
 def test_import_relative_back_to_absolute2(self):
 from pkg import abs_x_y
@@ -745,6 +745,13 @@
 exec "from pkg.withoutall import *" in d
 assert d["foobar"].found == 123
 
+def test_import_star_empty_string(self):
+for case in ["not-imported-yet", "already-imported"]:
+d = {}
+exec "from pkg.withoutall import *" in d
+assert "" in d
+
+
 def test_import_star_with_bogus___all__(self):
 for case in ["not-imported-yet", "already-imported"]:
 try:
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: fix translation

2018-07-08 Thread mattip
Author: Matti Picus 
Branch: 
Changeset: r94834:b42a5efd4312
Date: 2018-07-08 17:58 -0700
http://bitbucket.org/pypy/pypy/changeset/b42a5efd4312/

Log:fix translation

diff --git a/pypy/module/_cppyy/interp_cppyy.py 
b/pypy/module/_cppyy/interp_cppyy.py
--- a/pypy/module/_cppyy/interp_cppyy.py
+++ b/pypy/module/_cppyy/interp_cppyy.py
@@ -510,7 +510,7 @@
 not space.is_w(w_obj, space.w_None) or
 space.is_w(w_cls, space.type(space.w_None)))
 if asking_for_bound:
-return MethodWithProps(space, self, w_obj)
+return MethodWithProps(space, self, w_obj, w_cls)
 else:
 return self  # unbound methods don't exist in Python 3, return self
 
@@ -626,7 +626,7 @@
 # onto a class and w_this should be set
 cppinstance = self.space.interp_w(W_CPPInstance, w_obj)
 if cppinstance.clsdecl.handle != self.scope.handle:
-return MethodWithProps(self.space, self, w_obj)# bound
+return MethodWithProps(self.space, self, w_obj, w_cls)# 
bound
 return self  # unbound
 
 @unwrap_spec(args_w='args_w')
diff --git a/pypy/module/cpyext/cdatetime.py b/pypy/module/cpyext/cdatetime.py
--- a/pypy/module/cpyext/cdatetime.py
+++ b/pypy/module/cpyext/cdatetime.py
@@ -135,6 +135,7 @@
 '''Fills a newly allocated py_obj from the w_obj
 If it is a datetime.time or datetime.datetime, it may have tzinfo
 '''
+assert len(datetimeAPI_global) > 0
 if datetimeAPI_global[0].c_TimeType == py_obj.c_ob_type:
 py_datetime = rffi.cast(PyDateTime_Time, py_obj)
 w_tzinfo = space.getattr(w_obj, space.newtext('tzinfo'))
@@ -158,6 +159,7 @@
 @slot_function([PyObject], lltype.Void)
 def type_dealloc(space, py_obj):
 from pypy.module.cpyext.object import _dealloc
+assert len(datetimeAPI_global) > 0
 if datetimeAPI_global[0].c_TimeType == py_obj.c_ob_type:
 py_datetime = rffi.cast(PyDateTime_Time, py_obj)
 if (widen(py_datetime.c_hastzinfo) != 0):
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: Fix rvmprof/dummy: stop_sampling() is supposed to return an integer, not None

2018-07-03 Thread arigo
Author: Armin Rigo 
Branch: 
Changeset: r94803:60d37209763d
Date: 2018-07-03 21:45 +0200
http://bitbucket.org/pypy/pypy/changeset/60d37209763d/

Log:Fix rvmprof/dummy: stop_sampling() is supposed to return an integer,
not None

diff --git a/rpython/rlib/rvmprof/dummy.py b/rpython/rlib/rvmprof/dummy.py
--- a/rpython/rlib/rvmprof/dummy.py
+++ b/rpython/rlib/rvmprof/dummy.py
@@ -23,4 +23,4 @@
 pass
 
 def stop_sampling(self):
-pass
+return -1
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: fix test

2018-06-29 Thread mattip
Author: Matti Picus 
Branch: 
Changeset: r94785:435136eb0bac
Date: 2018-06-29 07:36 -0700
http://bitbucket.org/pypy/pypy/changeset/435136eb0bac/

Log:fix test

diff --git a/pypy/module/cpyext/test/test_object.py 
b/pypy/module/cpyext/test/test_object.py
--- a/pypy/module/cpyext/test/test_object.py
+++ b/pypy/module/cpyext/test/test_object.py
@@ -5,7 +5,7 @@
 from rpython.rtyper.lltypesystem import rffi, lltype
 from pypy.module.cpyext.pyobject import get_w_obj_and_decref
 from pypy.module.cpyext.api import (
-Py_LT, Py_LE, Py_NE, Py_EQ, Py_GE, Py_GT)
+Py_LT, Py_LE, Py_NE, Py_EQ, Py_GE, Py_GT, INTP_real)
 from pypy.module.cpyext.object import (
 PyObject_IsTrue, PyObject_Not, PyObject_GetAttrString,
 PyObject_DelAttrString, PyObject_GetAttr, PyObject_DelAttr,
@@ -205,7 +205,7 @@
 
 def test_cmp(self, space, api):
 w = space.wrap
-with lltype.scoped_alloc(rffi.INTP.TO, 1) as ptr:
+with lltype.scoped_alloc(INTP_real.TO, 1) as ptr:
 assert api.PyObject_Cmp(w(42), w(72), ptr) == 0
 assert ptr[0] == -1
 assert api.PyObject_Cmp(w("a"), w("a"), ptr) == 0
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: fix tests

2018-06-25 Thread mattip
Author: Matti Picus 
Branch: 
Changeset: r94781:2ae825a19da0
Date: 2018-06-25 21:42 -0700
http://bitbucket.org/pypy/pypy/changeset/2ae825a19da0/

Log:fix tests

diff --git a/pypy/module/cpyext/test/test_unicodeobject.py 
b/pypy/module/cpyext/test/test_unicodeobject.py
--- a/pypy/module/cpyext/test/test_unicodeobject.py
+++ b/pypy/module/cpyext/test/test_unicodeobject.py
@@ -4,7 +4,7 @@
 from pypy.module.cpyext.test.test_cpyext import AppTestCpythonExtensionBase
 from pypy.module.cpyext.unicodeobject import (
 Py_UNICODE, PyUnicodeObject, new_empty_unicode)
-from pypy.module.cpyext.api import PyObjectP, PyObject
+from pypy.module.cpyext.api import PyObjectP, PyObject, INTP_real
 from pypy.module.cpyext.pyobject import decref, from_ref
 from rpython.rtyper.lltypesystem import rffi, lltype
 import sys, py
@@ -464,8 +464,8 @@
 value = 1
 else:
 value = 0
-pendian = lltype.malloc(rffi.INTP.TO, 1, flavor='raw')
-pendian[0] = rffi.cast(rffi.INT, value)
+pendian = lltype.malloc(INTP_real.TO, 1, flavor='raw')
+pendian[0] = rffi.cast(rffi.INT_real, value)
 else:
 pendian = None
 
@@ -477,7 +477,7 @@
 rffi.free_charp(strict_charp)
 if pendian:
 if realendian is not None:
-assert rffi.cast(rffi.INT, realendian) == pendian[0]
+assert rffi.cast(rffi.INT_real, realendian) == pendian[0]
 lltype.free(pendian, flavor='raw')
 
 test("\x61\x00\x62\x00\x63\x00\x64\x00", -1)
@@ -500,8 +500,8 @@
 value = 1
 else:
 value = 0
-pendian = lltype.malloc(rffi.INTP.TO, 1, flavor='raw')
-pendian[0] = rffi.cast(rffi.INT, value)
+pendian = lltype.malloc(INTP_real.TO, 1, flavor='raw')
+pendian[0] = rffi.cast(rffi.INT_real, value)
 else:
 pendian = None
 
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: fix tests

2018-06-25 Thread mattip
Author: Matti Picus 
Branch: 
Changeset: r94780:9272d1b47f51
Date: 2018-06-25 21:35 -0700
http://bitbucket.org/pypy/pypy/changeset/9272d1b47f51/

Log:fix tests

diff --git a/pypy/module/cpyext/test/test_pystrtod.py 
b/pypy/module/cpyext/test/test_pystrtod.py
--- a/pypy/module/cpyext/test/test_pystrtod.py
+++ b/pypy/module/cpyext/test/test_pystrtod.py
@@ -4,7 +4,7 @@
 from pypy.module.cpyext.test.test_api import BaseApiTest, raises_w
 from rpython.rtyper.lltypesystem import rffi
 from rpython.rtyper.lltypesystem import lltype
-from pypy.module.cpyext.pystrtod import PyOS_string_to_double
+from pypy.module.cpyext.pystrtod import PyOS_string_to_double, INTP_real
 
 
 class TestPyOS_string_to_double(BaseApiTest):
@@ -90,7 +90,7 @@
 class TestPyOS_double_to_string(BaseApiTest):
 
 def test_format_code(self, api):
-ptype = lltype.malloc(rffi.INTP.TO, 1, flavor='raw')
+ptype = lltype.malloc(INTP_real.TO, 1, flavor='raw')
 r = api.PyOS_double_to_string(150.0, 'e', 1, 0, ptype)
 assert '1.5e+02' == rffi.charp2str(r)
 type_value = rffi.cast(lltype.Signed, ptype[0])
@@ -99,7 +99,7 @@
 lltype.free(ptype, flavor='raw')
 
 def test_precision(self, api):
-ptype = lltype.malloc(rffi.INTP.TO, 1, flavor='raw')
+ptype = lltype.malloc(INTP_real.TO, 1, flavor='raw')
 r = api.PyOS_double_to_string(3.14159269397, 'g', 5, 0, ptype)
 assert '3.1416' == rffi.charp2str(r)
 type_value = rffi.cast(lltype.Signed, ptype[0])
@@ -108,7 +108,7 @@
 lltype.free(ptype, flavor='raw')
 
 def test_flags_sign(self, api):
-ptype = lltype.malloc(rffi.INTP.TO, 1, flavor='raw')
+ptype = lltype.malloc(INTP_real.TO, 1, flavor='raw')
 r = api.PyOS_double_to_string(-3.14, 'g', 3, 1, ptype)
 assert '-3.14' == rffi.charp2str(r)
 type_value = rffi.cast(lltype.Signed, ptype[0])
@@ -117,7 +117,7 @@
 lltype.free(ptype, flavor='raw')
 
 def test_flags_add_dot_0(self, api):
-ptype = lltype.malloc(rffi.INTP.TO, 1, flavor='raw')
+ptype = lltype.malloc(INTP_real.TO, 1, flavor='raw')
 r = api.PyOS_double_to_string(3, 'g', 5, 2, ptype)
 assert '3.0' == rffi.charp2str(r)
 type_value = rffi.cast(lltype.Signed, ptype[0])
@@ -126,7 +126,7 @@
 lltype.free(ptype, flavor='raw')
 
 def test_flags_alt(self, api):
-ptype = lltype.malloc(rffi.INTP.TO, 1, flavor='raw')
+ptype = lltype.malloc(INTP_real.TO, 1, flavor='raw')
 r = api.PyOS_double_to_string(314., 'g', 3, 4, ptype)
 assert '314.' == rffi.charp2str(r)
 type_value = rffi.cast(lltype.Signed, ptype[0])
@@ -135,7 +135,7 @@
 lltype.free(ptype, flavor='raw')
 
 def test_ptype_nan(self, api):
-ptype = lltype.malloc(rffi.INTP.TO, 1, flavor='raw')
+ptype = lltype.malloc(INTP_real.TO, 1, flavor='raw')
 r = api.PyOS_double_to_string(float('nan'), 'g', 3, 4, ptype)
 assert 'nan' == rffi.charp2str(r)
 type_value = rffi.cast(lltype.Signed, ptype[0])
@@ -144,7 +144,7 @@
 lltype.free(ptype, flavor='raw')
 
 def test_ptype_infinity(self, api):
-ptype = lltype.malloc(rffi.INTP.TO, 1, flavor='raw')
+ptype = lltype.malloc(INTP_real.TO, 1, flavor='raw')
 r = api.PyOS_double_to_string(1e200 * 1e200, 'g', 0, 0, ptype)
 assert 'inf' == rffi.charp2str(r)
 type_value = rffi.cast(lltype.Signed, ptype[0])
@@ -153,8 +153,8 @@
 lltype.free(ptype, flavor='raw')
 
 def test_ptype_null(self, api):
-ptype = lltype.nullptr(rffi.INTP.TO)
+ptype = lltype.nullptr(INTP_real.TO)
 r = api.PyOS_double_to_string(3.14, 'g', 3, 0, ptype)
 assert '3.14' == rffi.charp2str(r)
-assert ptype == lltype.nullptr(rffi.INTP.TO)
+assert ptype == lltype.nullptr(INTP_real.TO)
 rffi.free_charp(r)
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: fix translation

2018-06-25 Thread mattip
Author: Matti Picus 
Branch: 
Changeset: r94779:5eb961f7541c
Date: 2018-06-25 14:50 -0700
http://bitbucket.org/pypy/pypy/changeset/5eb961f7541c/

Log:fix translation

diff --git a/pypy/module/cpyext/longobject.py b/pypy/module/cpyext/longobject.py
--- a/pypy/module/cpyext/longobject.py
+++ b/pypy/module/cpyext/longobject.py
@@ -133,7 +133,7 @@
 overflow_ptr[0] = rffi.cast(rffi.INT_real, -1)
 return -1
 
-@cpython_api([PyObject, rffi.CArrayPtr(rffi.INT_real)], rffi.LONGLONG,
+@cpython_api([PyObject, INTP_real], rffi.LONGLONG,
  error=-1)
 def PyLong_AsLongLongAndOverflow(space, w_long, overflow_ptr):
 """
diff --git a/pypy/module/cpyext/object.py b/pypy/module/cpyext/object.py
--- a/pypy/module/cpyext/object.py
+++ b/pypy/module/cpyext/object.py
@@ -228,7 +228,7 @@
 comparison is returned in result.  Returns -1 on failure.  This is the
 equivalent of the Python statement result = cmp(o1, o2)."""
 res = space.int_w(space.cmp(w_o1, w_o2))
-result[0] = rffi.cast(rffi.INT, res)
+result[0] = rffi.cast(rffi.INT_real, res)
 return 0
 
 @cpython_api([PyObject, PyObject, rffi.INT_real], PyObject)
diff --git a/pypy/module/cpyext/pystrtod.py b/pypy/module/cpyext/pystrtod.py
--- a/pypy/module/cpyext/pystrtod.py
+++ b/pypy/module/cpyext/pystrtod.py
@@ -114,7 +114,7 @@
 buffer, rtype = rfloat.double_to_string(val, format_code,
 intmask(precision),
 intmask(flags))
-if ptype != lltype.nullptr(rffi.INTP.TO):
-ptype[0] = rffi.cast(rffi.INT, DOUBLE_TO_STRING_TYPES_MAP[rtype])
+if ptype != lltype.nullptr(INTP_real.TO):
+ptype[0] = rffi.cast(rffi.INT_real, DOUBLE_TO_STRING_TYPES_MAP[rtype])
 bufp = rffi.str2charp(buffer)
 return bufp
diff --git a/pypy/module/cpyext/unicodeobject.py 
b/pypy/module/cpyext/unicodeobject.py
--- a/pypy/module/cpyext/unicodeobject.py
+++ b/pypy/module/cpyext/unicodeobject.py
@@ -576,7 +576,7 @@
 None, # errorhandler
 byteorder)
 if pbyteorder is not None:
-pbyteorder[0] = rffi.cast(rffi.INT, byteorder)
+pbyteorder[0] = rffi.cast(rffi.INT_real, byteorder)
 
 return space.newunicode(result)
 
@@ -632,7 +632,7 @@
 None, # errorhandler
 byteorder)
 if pbyteorder is not None:
-pbyteorder[0] = rffi.cast(rffi.INT, byteorder)
+pbyteorder[0] = rffi.cast(rffi.INT_real, byteorder)
 
 return space.newunicode(result)
 
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: fix #2851, define and use INTP_real as 'int*' for windows compatability

2018-06-24 Thread mattip
Author: Matti Picus 
Branch: 
Changeset: r94778:6e529ed6ae8e
Date: 2018-06-24 20:33 -0700
http://bitbucket.org/pypy/pypy/changeset/6e529ed6ae8e/

Log:fix #2851, define and use INTP_real as 'int*' for windows
compatability

diff --git a/pypy/module/cpyext/api.py b/pypy/module/cpyext/api.py
--- a/pypy/module/cpyext/api.py
+++ b/pypy/module/cpyext/api.py
@@ -772,6 +772,9 @@
 # a pointer to PyObject
 PyObjectP = rffi.CArrayPtr(PyObject)
 
+# int *
+INTP_real = rffi.CArrayPtr(rffi.INT_real)
+
 def configure_types():
 for config in (CConfig, CConfig2):
 for name, TYPE in rffi_platform.configure(config).iteritems():
diff --git a/pypy/module/cpyext/longobject.py b/pypy/module/cpyext/longobject.py
--- a/pypy/module/cpyext/longobject.py
+++ b/pypy/module/cpyext/longobject.py
@@ -1,7 +1,7 @@
 from rpython.rtyper.lltypesystem import lltype, rffi
 from pypy.module.cpyext.api import (
 cpython_api, PyObject, build_type_checkers_flags, Py_ssize_t,
-CONST_STRING, ADDR, CANNOT_FAIL)
+CONST_STRING, ADDR, CANNOT_FAIL, INTP_real)
 from pypy.objspace.std.longobject import W_LongObject
 from pypy.interpreter.error import OperationError, oefmt
 from pypy.module.cpyext.intobject import PyInt_AsUnsignedLongMask
@@ -112,7 +112,7 @@
 num = space.bigint_w(w_long)
 return num.ulonglongmask()
 
-@cpython_api([PyObject, rffi.CArrayPtr(rffi.INT_real)], lltype.Signed,
+@cpython_api([PyObject, INTP_real], lltype.Signed,
  error=-1)
 def PyLong_AsLongAndOverflow(space, w_long, overflow_ptr):
 """
diff --git a/pypy/module/cpyext/object.py b/pypy/module/cpyext/object.py
--- a/pypy/module/cpyext/object.py
+++ b/pypy/module/cpyext/object.py
@@ -1,7 +1,7 @@
 from rpython.rtyper.lltypesystem import rffi, lltype
 from pypy.module.cpyext.api import (
 cpython_api, generic_cpy_call, CANNOT_FAIL, Py_ssize_t, Py_ssize_tP,
-PyVarObject, size_t, slot_function,
+PyVarObject, size_t, slot_function, INTP_real,
 Py_TPFLAGS_HEAPTYPE, Py_LT, Py_LE, Py_EQ, Py_NE, Py_GT,
 Py_GE, CONST_STRING, FILEP, fwrite, c_only)
 from pypy.module.cpyext.pyobject import (
@@ -221,7 +221,7 @@
 expression cmp(o1, o2)."""
 return space.int_w(space.cmp(w_o1, w_o2))
 
-@cpython_api([PyObject, PyObject, rffi.INTP], rffi.INT_real, error=-1)
+@cpython_api([PyObject, PyObject, INTP_real], rffi.INT_real, error=-1)
 def PyObject_Cmp(space, w_o1, w_o2, result):
 """Compare the values of o1 and o2 using a routine provided by o1, if one
 exists, otherwise with a routine provided by o2.  The result of the
diff --git a/pypy/module/cpyext/pystrtod.py b/pypy/module/cpyext/pystrtod.py
--- a/pypy/module/cpyext/pystrtod.py
+++ b/pypy/module/cpyext/pystrtod.py
@@ -1,6 +1,6 @@
 import errno
 from pypy.interpreter.error import oefmt
-from pypy.module.cpyext.api import cpython_api, CONST_STRING
+from pypy.module.cpyext.api import cpython_api, CONST_STRING, INTP_real
 from pypy.module.cpyext.pyobject import PyObject
 from rpython.rlib import rdtoa
 from rpython.rlib import rfloat
@@ -80,7 +80,7 @@
 if not user_endptr:
 lltype.free(endptr, flavor='raw')
 
-@cpython_api([rffi.DOUBLE, lltype.Char, rffi.INT_real, rffi.INT_real, 
rffi.INTP], rffi.CCHARP)
+@cpython_api([rffi.DOUBLE, lltype.Char, rffi.INT_real, rffi.INT_real, 
INTP_real], rffi.CCHARP)
 def PyOS_double_to_string(space, val, format_code, precision, flags, ptype):
 """Convert a double val to a string using supplied
 format_code, precision, and flags.
diff --git a/pypy/module/cpyext/unicodeobject.py 
b/pypy/module/cpyext/unicodeobject.py
--- a/pypy/module/cpyext/unicodeobject.py
+++ b/pypy/module/cpyext/unicodeobject.py
@@ -3,7 +3,7 @@
 from pypy.module.unicodedata import unicodedb
 from pypy.module.cpyext.api import (
 CANNOT_FAIL, Py_ssize_t, build_type_checkers_flags, cpython_api,
-bootstrap_function, CONST_STRING,
+bootstrap_function, CONST_STRING, INTP_real,
 CONST_WSTRING, slot_function, cts, parse_dir)
 from pypy.module.cpyext.pyerrors import PyErr_BadArgument
 from pypy.module.cpyext.pyobject import (
@@ -526,7 +526,7 @@
 if sys.platform == 'win32':
 make_conversion_functions('MBCS', 'mbcs')
 
-@cpython_api([CONST_STRING, Py_ssize_t, CONST_STRING, rffi.INTP], PyObject)
+@cpython_api([CONST_STRING, Py_ssize_t, CONST_STRING, INTP_real], PyObject)
 def PyUnicode_DecodeUTF16(space, s, size, llerrors, pbyteorder):
 """Decode length bytes from a UTF-16 encoded buffer string and return the
 corresponding Unicode object.  errors (if non-NULL) defines the error
@@ -580,7 +580,7 @@
 
 return space.newunicode(result)
 
-@cpython_api([CONST_STRING, Py_ssize_t, CONST_STRING, rffi.INTP], PyObject)
+@cpython_api([CONST_STRING, Py_ssize_t, CONST_STRING, INTP_real], PyObject)
 def PyUnicode_DecodeUTF32(space, s, size, llerrors, pbyteorder):
 """Decode length bytes from a UTF-32 encoded buffer string and
 return the corresponding Unicode object.  errors (if non-NULL)

[pypy-commit] pypy default: fix error messages in complex number handling a bit

2018-05-28 Thread cfbolz
Author: Carl Friedrich Bolz-Tereick 
Branch: 
Changeset: r94694:cadf86879441
Date: 2018-05-28 21:33 +0200
http://bitbucket.org/pypy/pypy/changeset/cadf86879441/

Log:fix error messages in complex number handling a bit

diff --git a/pypy/objspace/std/complexobject.py 
b/pypy/objspace/std/complexobject.py
--- a/pypy/objspace/std/complexobject.py
+++ b/pypy/objspace/std/complexobject.py
@@ -128,7 +128,7 @@
 return format_float(x, 'g', DTSF_STR_PRECISION)
 
 
-def unpackcomplex(space, w_complex, strict_typing=True):
+def unpackcomplex(space, w_complex, strict_typing=True, firstarg=True):
 """
 convert w_complex into a complex and return the unwrapped (real, imag)
 tuple. If strict_typing==True, we also typecheck the value returned by
@@ -180,7 +180,20 @@
 raise oefmt(space.w_TypeError,
 "complex number expected, got '%T'", w_complex)
 #
-return (space.float_w(space.float(w_complex)), 0.0)
+try:
+return (space.float_w(space.float(w_complex)), 0.0)
+except OperationError as e:
+if not e.match(space, space.w_TypeError):
+raise
+if firstarg:
+raise oefmt(space.w_TypeError,
+"complex() first argument must be a string or a 
number, not '%T'",
+ w_complex)
+else:
+raise oefmt(space.w_TypeError,
+"complex() second argument must be a number, not '%T'",
+ w_complex)
+
 
 
 class W_ComplexObject(W_Root):
@@ -326,7 +339,8 @@
 if not noarg2:
 # complex(x, y) == x+y*j, even if 'y' is already a complex.
 realval2, imagval2 = unpackcomplex(space, w_imag,
-   strict_typing=False)
+   strict_typing=False,
+   firstarg=False)
 
 # try to preserve the signs of zeroes of realval and realval2
 if imagval2 != 0.0:
@@ -476,7 +490,7 @@
 try:
 return self.div(w_rhs)
 except ZeroDivisionError as e:
-raise OperationError(space.w_ZeroDivisionError, 
space.newtext(str(e)))
+raise oefmt(space.w_ZeroDivisionError, "complex division by zero")
 
 def descr_rtruediv(self, space, w_lhs):
 w_lhs = self._to_complex(space, w_lhs)
@@ -485,7 +499,7 @@
 try:
 return w_lhs.div(self)
 except ZeroDivisionError as e:
-raise OperationError(space.w_ZeroDivisionError, 
space.newtext(str(e)))
+raise oefmt(space.w_ZeroDivisionError, "complex division by zero")
 
 def descr_floordiv(self, space, w_rhs):
 w_rhs = self._to_complex(space, w_rhs)
@@ -495,7 +509,7 @@
 try:
 return self.divmod(space, w_rhs)[0]
 except ZeroDivisionError as e:
-raise OperationError(space.w_ZeroDivisionError, 
space.newtext(str(e)))
+raise oefmt(space.w_ZeroDivisionError, "complex division by zero")
 
 def descr_rfloordiv(self, space, w_lhs):
 w_lhs = self._to_complex(space, w_lhs)
@@ -505,7 +519,7 @@
 try:
 return w_lhs.divmod(space, self)[0]
 except ZeroDivisionError as e:
-raise OperationError(space.w_ZeroDivisionError, 
space.newtext(str(e)))
+raise oefmt(space.w_ZeroDivisionError, "complex division by zero")
 
 def descr_mod(self, space, w_rhs):
 w_rhs = self._to_complex(space, w_rhs)
@@ -514,7 +528,7 @@
 try:
 return self.divmod(space, w_rhs)[1]
 except ZeroDivisionError as e:
-raise OperationError(space.w_ZeroDivisionError, 
space.newtext(str(e)))
+raise oefmt(space.w_ZeroDivisionError, "complex modulo by zero")
 
 def descr_rmod(self, space, w_lhs):
 w_lhs = self._to_complex(space, w_lhs)
@@ -523,7 +537,7 @@
 try:
 return w_lhs.divmod(space, self)[1]
 except ZeroDivisionError as e:
-raise OperationError(space.w_ZeroDivisionError, 
space.newtext(str(e)))
+raise oefmt(space.w_ZeroDivisionError, "complex modulo by zero")
 
 def descr_divmod(self, space, w_rhs):
 w_rhs = self._to_complex(space, w_rhs)
@@ -532,7 +546,7 @@
 try:
 div, mod = self.divmod(space, w_rhs)
 except ZeroDivisionError as e:
-raise OperationError(space.w_ZeroDivisionError, 
space.newtext(str(e)))
+raise oefmt(space.w_ZeroDivisionError, "complex divmod by zero")
 return space.newtuple([div, mod])
 
 def descr_rdivmod(self, space, w_lhs):
@@ -542,7 +556,7 @@
 try:
 div, mod = w_lhs.divmod(space, self)
 except ZeroDivisionError as e:
-raise OperationError(space.w_ZeroDivisionError, 
space.newtext(str(e)))
+raise oefmt(space.w_ZeroDivisionError, "complex divmod by zero")
 

[pypy-commit] pypy default: Fix test_reverse_debugging

2018-05-26 Thread arigo
Author: Armin Rigo 
Branch: 
Changeset: r94687:24dc51e3f099
Date: 2018-05-26 14:18 +0200
http://bitbucket.org/pypy/pypy/changeset/24dc51e3f099/

Log:Fix test_reverse_debugging

diff --git a/pypy/interpreter/test/test_reverse_debugging.py 
b/pypy/interpreter/test/test_reverse_debugging.py
--- a/pypy/interpreter/test/test_reverse_debugging.py
+++ b/pypy/interpreter/test/test_reverse_debugging.py
@@ -86,6 +86,9 @@
 if msg[0] == revdb.ANSWER_TEXT:
 assert got_output is None
 got_output = msg[-1]
+assert msg[1] in (0, 1)
+if msg[1]:
+got_output += "\n"
 elif msg[0] == revdb.ANSWER_CHBKPT:
 assert got_chbkpt is None
 assert msg[1] == 5
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: fix test for python3, remove implemented functions from stubs.py

2018-05-14 Thread mattip
Author: Matti Picus 
Branch: 
Changeset: r94570:a8e6b2583cbc
Date: 2018-05-14 14:39 +0300
http://bitbucket.org/pypy/pypy/changeset/a8e6b2583cbc/

Log:fix test for python3, remove implemented functions from stubs.py

diff --git a/pypy/module/cpyext/stubs.py b/pypy/module/cpyext/stubs.py
--- a/pypy/module/cpyext/stubs.py
+++ b/pypy/module/cpyext/stubs.py
@@ -1261,13 +1261,6 @@
 version indicates the file format."""
 raise NotImplementedError
 
-@cpython_api([PyObject, rffi.INT_real], PyObject)
-def PyMarshal_WriteObjectToString(space, value, version):
-"""Return a string object containing the marshalled representation of 
value.
-
-version indicates the file format."""
-raise NotImplementedError
-
 @cpython_api([FILE], lltype.Signed, error=CANNOT_FAIL)
 def PyMarshal_ReadLongFromFile(space, file):
 """Return a C long from the data stream in a FILE* opened
@@ -1301,17 +1294,6 @@
 (EOFError or TypeError) and returns NULL."""
 raise NotImplementedError
 
-@cpython_api([rffi.CCHARP, Py_ssize_t], PyObject)
-def PyMarshal_ReadObjectFromString(space, string, len):
-"""Return a Python object from the data stream in a character buffer
-containing len bytes pointed to by string.  On error, sets the
-appropriate exception (EOFError or TypeError) and returns
-NULL.
-
-This function used an int type for len. This might require
-changes in your code for properly supporting 64-bit systems."""
-raise NotImplementedError
-
 @cpython_api([], rffi.INT_real, error=CANNOT_FAIL)
 def PyMethod_ClearFreeList(space):
 """Clear the free list. Return the total number of freed items.
diff --git a/pypy/module/cpyext/test/test_marshal.py 
b/pypy/module/cpyext/test/test_marshal.py
--- a/pypy/module/cpyext/test/test_marshal.py
+++ b/pypy/module/cpyext/test/test_marshal.py
@@ -6,8 +6,8 @@
 module = self.import_extension('foo', [
 ("mloads", "METH_O",
  """
- char *input = PyString_AsString(args);
- Py_ssize_t length = PyString_Size(args);
+ char *input = PyBytes_AsString(args);
+ Py_ssize_t length = PyBytes_Size(args);
  return PyMarshal_ReadObjectFromString(input, length);
  """)],
 prologue='#include ')
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: fix many broken links, checked with "sphinx-build -n -b linkcheck"

2018-05-09 Thread mattip
Author: Matti Picus 
Branch: 
Changeset: r94513:e11138105393
Date: 2018-05-09 19:21 +0300
http://bitbucket.org/pypy/pypy/changeset/e11138105393/

Log:fix many broken links, checked with "sphinx-build -n -b linkcheck"

diff --git a/pypy/doc/build.rst b/pypy/doc/build.rst
--- a/pypy/doc/build.rst
+++ b/pypy/doc/build.rst
@@ -267,14 +267,14 @@
 * PyPy 2.5.1 or earlier: normal users would see permission errors.
   Installers need to run ``pypy -c "import gdbm"`` and other similar
   commands at install time; the exact list is in
-  :source:`pypy/tool/release/package.py `.  Users
+  :source:`pypy/tool/release/package.py`.  Users
   seeing a broken installation of PyPy can fix it after-the-fact if they
   have sudo rights, by running once e.g. ``sudo pypy -c "import gdbm``.
 
 * PyPy 2.6 and later: anyone would get ``ImportError: no module named
   _gdbm_cffi``.  Installers need to run ``pypy _gdbm_build.py`` in the
   ``lib_pypy`` directory during the installation process (plus others;
-  see the exact list in :source:`pypy/tool/release/package.py `).
+  see the exact list in :source:`pypy/tool/release/package.py`).
   Users seeing a broken
   installation of PyPy can fix it after-the-fact, by running ``pypy
   /path/to/lib_pypy/_gdbm_build.py``.  This command produces a file
diff --git a/pypy/doc/coding-guide.rst b/pypy/doc/coding-guide.rst
--- a/pypy/doc/coding-guide.rst
+++ b/pypy/doc/coding-guide.rst
@@ -539,7 +539,7 @@
 
 hg help branch
 
-.. _official wiki: http://mercurial.selenic.com/wiki/Branch
+.. _official wiki: https://www.mercurial-scm.org/wiki/
 
 
 .. _using-development-tracker:
@@ -547,15 +547,7 @@
 Using the development bug/feature tracker
 -
 
-We have a `development tracker`_, based on Richard Jones'
-`roundup`_ application.  You can file bugs,
-feature requests or see what's going on
-for the next milestone, both from an E-Mail and from a
-web interface.
-
-.. _development tracker: https://bugs.pypy.org/
-.. _roundup: http://roundup.sourceforge.net/
-
+We use bitbucket for :source:`issues` tracking and :source:`pull-requests`.
 
 .. _testing:
 
diff --git a/pypy/doc/contributing.rst b/pypy/doc/contributing.rst
--- a/pypy/doc/contributing.rst
+++ b/pypy/doc/contributing.rst
@@ -91,7 +91,7 @@
 
 * Go to https://bitbucket.org/pypy/pypy/ and click "fork" (left
   icons).  You get a fork of the repository, e.g. in
-  https://bitbucket.org/yourname/pypy/.
+  `https://bitbucket.org/yourname/pypy/`.
 
 * Clone your new repo (i.e. the fork) to your local machine with the command
   ``hg clone ssh://h...@bitbucket.org/yourname/pypy``.  It is a very slow
diff --git a/pypy/doc/discussion/ctypes-implementation.rst 
b/pypy/doc/discussion/ctypes-implementation.rst
--- a/pypy/doc/discussion/ctypes-implementation.rst
+++ b/pypy/doc/discussion/ctypes-implementation.rst
@@ -141,28 +141,3 @@
 
 .. _pyglet: http://pyglet.org/
 
-
-ctypes configure
--
-
-We also released ``ctypes-configure``, which is an experimental package
-trying to approach the portability issues of ctypes-based code.
-
-idea
-
-
-One of ctypes problems is that ctypes programs are usually not very
-platform-independent. We created ctypes_configure, which invokes c
-compiler (via distutils) for various platform-dependent details like
-exact sizes of types (for example size_t), ``#defines``, exact outline of
-structures etc. It replaces in this regard code generator (h2py).
-
-installation
-
-
-``easy_install ctypes_configure``
-
-usage
-~
-
-:source:`ctypes_configure/doc/sample.py` explains in details how to use it.
diff --git a/pypy/doc/eventhistory.rst b/pypy/doc/eventhistory.rst
--- a/pypy/doc/eventhistory.rst
+++ b/pypy/doc/eventhistory.rst
@@ -40,11 +40,9 @@
 Main focus of the sprint will be on the goals of the upcoming June 0.9
 release.
 
-Read more in `the sprint announcement`__, see who is  planning to attend
-on the `people page`_.
+Read more about `the sprint`__
 
-__ 
https://bitbucket.org/pypy/extradoc/raw/tip/sprintinfo/ddorf2006/announce.html
-.. _people page: 
https://bitbucket.org/pypy/extradoc/raw/tip/sprintinfo/ddorf2006/people.txt
+__ https://bitbucket.org/pypy/extradoc/src/extradoc/sprintinfo/ddorf2006/
 
 
 PyPy sprint at Akihabara (Tokyo, Japan)
diff --git a/pypy/doc/extradoc.rst b/pypy/doc/extradoc.rst
--- a/pypy/doc/extradoc.rst
+++ b/pypy/doc/extradoc.rst
@@ -75,12 +75,12 @@
 .. _A Way Forward in Parallelising Dynamic Languages: 
https://bitbucket.org/pypy/extradoc/raw/extradoc/talk/icooolps2014/position-paper.pdf
 .. _Runtime Feedback in a Meta-Tracing JIT for Efficient Dynamic Languages: 
https://bitbucket.org/pypy/extradoc/raw/extradoc/talk/icooolps2011/jit-hints.pdf
 .. _Allocation Removal by Partial Evaluation in a Tracing JIT: 
https://bitbucket.org/pypy/extradoc/raw/extradoc/talk/pepm2011/bolz-allocation-removal.pdf
-.. _Towards a Jitting VM for Prolog Execution: 

[pypy-commit] pypy default: fix a very rare segfault in the JIT, shown by Pycket

2018-05-04 Thread cfbolz
Author: Carl Friedrich Bolz-Tereick 
Branch: 
Changeset: r94470:b0fdbba6aeab
Date: 2018-05-04 15:25 +0200
http://bitbucket.org/pypy/pypy/changeset/b0fdbba6aeab/

Log:fix a very rare segfault in the JIT, shown by Pycket

(neither did I manage to write a test, nor to fix the broken
invariant, which we've seen in other contexts before already.)

diff --git a/rpython/jit/metainterp/optimizeopt/info.py 
b/rpython/jit/metainterp/optimizeopt/info.py
--- a/rpython/jit/metainterp/optimizeopt/info.py
+++ b/rpython/jit/metainterp/optimizeopt/info.py
@@ -260,6 +260,12 @@
 # we don't know about this item
 return
 op = 
optimizer.get_box_replacement(self._fields[fielddescr.get_index()])
+if op is None:
+# XXX same bug as in serialize_opt:
+# op should never be None, because that's an invariant violation in
+# AbstractCachedEntry. But it still seems to happen when the info
+# is attached to a Constant. At least we shouldn't crash.
+return
 opnum = OpHelpers.getfield_for_descr(fielddescr)
 getfield_op = ResOperation(opnum, [structbox], descr=fielddescr)
 shortboxes.add_heap_op(op, getfield_op)
@@ -589,6 +595,7 @@
 return
 item = self._items[index]
 if item is not None:
+# see comment in AbstractStructPtrInfo.produce_short_preamble_ops
 op = optimizer.get_box_replacement(item)
 opnum = OpHelpers.getarrayitem_for_descr(descr)
 getarrayitem_op = ResOperation(opnum, [structbox, ConstInt(index)],
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: fix typos (thanks lesshaste and __pv)

2018-04-25 Thread cfbolz
Author: Carl Friedrich Bolz-Tereick 
Branch: 
Changeset: r94445:a614238235c7
Date: 2018-04-25 14:57 +0200
http://bitbucket.org/pypy/pypy/changeset/a614238235c7/

Log:fix typos (thanks lesshaste and __pv)

diff --git a/pypy/doc/release-v6.0.0.rst b/pypy/doc/release-v6.0.0.rst
--- a/pypy/doc/release-v6.0.0.rst
+++ b/pypy/doc/release-v6.0.0.rst
@@ -8,18 +8,18 @@
 the dual release.
 
 This release is a feature release following our previous 5.10 incremental
-release in late December 2017. Our C-API compatability layer ``cpyext`` is
+release in late December 2017. Our C-API compatibility layer ``cpyext`` is
 now much faster (see the `blog post`_) as well as more complete. We have made
 many other improvements in speed and CPython compatibility. Since the changes
 affect the included python development header files, all c-extension modules 
must
 be recompiled for this version.
 
-Until we can work with downstream providers to distruibute builds with PyPy, we
+Until we can work with downstream providers to distribute builds with PyPy, we
 have made packages for some common packages `available as wheels`_. You may
 compile yourself using ``pip install --no-build-isolation ``, the
 ``no-build-isolation`` is currently needed for pip v10.
 
-First-time python users are often stumped by silly typos and emissions when
+First-time python users are often stumped by silly typos and omissions when
 getting started writing code. We have improved our parser to emit more friendly
 `syntax errors`_,  making PyPy not only faster but more friendly.
 
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: Fix a case where the list strategy leaks to the user

2018-04-23 Thread arigo
Author: Armin Rigo 
Branch: 
Changeset: r94425:bae7d61d060c
Date: 2018-04-23 14:38 +0200
http://bitbucket.org/pypy/pypy/changeset/bae7d61d060c/

Log:Fix a case where the list strategy leaks to the user

diff --git a/pypy/objspace/std/listobject.py b/pypy/objspace/std/listobject.py
--- a/pypy/objspace/std/listobject.py
+++ b/pypy/objspace/std/listobject.py
@@ -991,6 +991,14 @@
 
 def setslice(self, w_list, start, step, slicelength, w_other):
 strategy = w_other.strategy
+if step != 1:
+len2 = strategy.length(w_other)
+if len2 == 0:
+return
+else:
+raise oefmt(self.space.w_ValueError,
+"attempt to assign sequence of size %d to extended 
"
+"slice of size %d", len2, 0)
 storage = strategy.getstorage_copy(w_other)
 w_list.strategy = strategy
 w_list.lstorage = storage
diff --git a/pypy/objspace/std/test/test_listobject.py 
b/pypy/objspace/std/test/test_listobject.py
--- a/pypy/objspace/std/test/test_listobject.py
+++ b/pypy/objspace/std/test/test_listobject.py
@@ -1080,6 +1080,15 @@
 l[::3] = ('a', 'b')
 assert l == ['a', 1.1, 2.2, 'b', 4.4, 5.5]
 
+l_int = [5]; l_int.pop()   # IntListStrategy
+l_empty = []   # EmptyListStrategy
+raises(ValueError, "l_int[::-1] = [42]")
+raises(ValueError, "l_int[::7] = [42]")
+raises(ValueError, "l_empty[::-1] = [42]")
+raises(ValueError, "l_empty[::7] = [42]")
+l_int[::1] = [42]; assert l_int == [42]
+l_empty[::1] = [42]; assert l_empty == [42]
+
 def test_setslice_with_self(self):
 l = [1,2,3,4]
 l[:] = l
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: fix llinterp debug_{start, stop} on 32bit - one more time

2018-04-19 Thread mattip
Author: Matti Picus 
Branch: 
Changeset: r94380:51718fe91a11
Date: 2018-04-19 11:20 +0300
http://bitbucket.org/pypy/pypy/changeset/51718fe91a11/

Log:fix llinterp debug_{start,stop} on 32bit - one more time

diff --git a/rpython/rlib/debug.py b/rpython/rlib/debug.py
--- a/rpython/rlib/debug.py
+++ b/rpython/rlib/debug.py
@@ -133,7 +133,7 @@
 opname = fn.__name__[1:] # remove the '_'
 return hop.genop(opname, vlist, resulttype=TIMESTAMP_type)
 else:
-return hop.inputconst(TIMESTAMP_type, 0)
+return hop.inputconst(TIMESTAMP_type, r_longlong(0))
 
 
 def have_debug_prints():
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: fix llinterp debug_{start, stop} on 32bit

2018-04-18 Thread antocuni
Author: Antonio Cuni 
Branch: 
Changeset: r94379:fbffeb3dc383
Date: 2018-04-18 13:27 +
http://bitbucket.org/pypy/pypy/changeset/fbffeb3dc383/

Log:fix llinterp debug_{start,stop} on 32bit

diff --git a/rpython/rlib/debug.py b/rpython/rlib/debug.py
--- a/rpython/rlib/debug.py
+++ b/rpython/rlib/debug.py
@@ -3,7 +3,7 @@
 
 from rpython.rtyper.extregistry import ExtRegistryEntry
 from rpython.rlib.objectmodel import we_are_translated, always_inline
-from rpython.rlib.rarithmetic import is_valid_int
+from rpython.rlib.rarithmetic import is_valid_int, r_longlong
 from rpython.rtyper.extfunc import register_external
 from rpython.rtyper.lltypesystem import lltype
 from rpython.rtyper.lltypesystem import rffi
@@ -100,8 +100,8 @@
 _log.debug_start(category)
 
 if timestamp:
-return c
-return -42 # random undefined value
+return r_longlong(c)
+return r_longlong(-42) # random undefined value
 
 def _debug_stop(category, timestamp):
 c = int(time.clock() * 100)
@@ -111,8 +111,8 @@
 _log.debug_stop(category)
 
 if timestamp:
-return c
-return -42 # random undefined value
+return r_longlong(c)
+return r_longlong(-42) # random undefined value
 
 class Entry(ExtRegistryEntry):
 _about_ = _debug_start, _debug_stop
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: fix python2-only test

2018-04-15 Thread mattip
Author: Matti Picus 
Branch: 
Changeset: r94334:4d2fb1545820
Date: 2018-04-15 08:59 +0300
http://bitbucket.org/pypy/pypy/changeset/4d2fb1545820/

Log:fix python2-only test

diff --git a/pypy/module/cpyext/test/test_bufferobject.py 
b/pypy/module/cpyext/test/test_bufferobject.py
--- a/pypy/module/cpyext/test/test_bufferobject.py
+++ b/pypy/module/cpyext/test/test_bufferobject.py
@@ -83,7 +83,7 @@
 if (((unsigned char*)bp.buf)[0] != '0') {
 void * buf = (void*)bp.buf;
 unsigned char val[4];
-unsigned char * s = PyString_AsString(obj);
+char * s = PyString_AsString(obj);
 memcpy(val, bp.buf, 4);
 PyBuffer_Release();
 if (PyObject_GetBuffer(obj, , PyBUF_SIMPLE) == -1)
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


  1   2   3   4   5   6   7   8   9   10   >