[pypy-commit] cffi sirtom67/float_complex: "c" tests pass!

2017-02-19 Thread sirtom67
Author: Tom Krauss 
Branch: sirtom67/float_complex
Changeset: r2891:3ce9e47d35f0
Date: 2017-02-19 19:51 -0600
http://bitbucket.org/cffi/cffi/changeset/3ce9e47d35f0/

Log:"c" tests pass!

diff --git a/c/_cffi_backend.c b/c/_cffi_backend.c
--- a/c/_cffi_backend.c
+++ b/c/_cffi_backend.c
@@ -3536,6 +3536,36 @@
 return cd;
 }
 
+static void check_bytes_for_float_compatible(
+PyObject *io,
+double * value,
+int * got_value_indicator,
+int * cannot_cast_indicator)
+{
+*got_value_indicator = 0;
+*cannot_cast_indicator = 0;
+if (PyBytes_Check(io)) {
+if (PyBytes_GET_SIZE(io) != 1) {
+Py_DECREF(io);
+*cannot_cast_indicator = 1;
+}
+*value = (unsigned char)PyBytes_AS_STRING(io)[0];
+*got_value_indicator = 1;
+}
+#if HAVE_WCHAR_H
+else if (PyUnicode_Check(io)) {
+wchar_t ordinal;
+if (_my_PyUnicode_AsSingleWideChar(io, ) < 0) {
+Py_DECREF(io);
+*cannot_cast_indicator = 1;
+}
+*value = (long)ordinal;
+*got_value_indicator = 1;
+}
+#endif
+
+}
+
 static PyObject *do_cast(CTypeDescrObject *ct, PyObject *ob)
 {
 CDataObject *cd;
@@ -3592,23 +3622,16 @@
 Py_INCREF(io);
 }
 
-if (PyBytes_Check(io)) {
-if (PyBytes_GET_SIZE(io) != 1) {
-Py_DECREF(io);
-goto cannot_cast;
-}
-value = (unsigned char)PyBytes_AS_STRING(io)[0];
-}
-#if HAVE_WCHAR_H
-else if (PyUnicode_Check(io)) {
-wchar_t ordinal;
-if (_my_PyUnicode_AsSingleWideChar(io, ) < 0) {
-Py_DECREF(io);
-goto cannot_cast;
-}
-value = (long)ordinal;
-}
-#endif
+int got_value_indicator;
+int cannot_cast_indicator;
+check_bytes_for_float_compatible(io, ,
+_value_indicator, _cast_indicator);
+if (cannot_cast_indicator) {
+goto cannot_cast;
+}
+if (got_value_indicator) {
+// got it from string
+}
 else if ((ct->ct_flags & CT_IS_LONGDOUBLE) &&
  CData_Check(io) &&
  (((CDataObject *)io)->c_type->ct_flags & CT_IS_LONGDOUBLE)) {
@@ -3658,11 +3681,23 @@
 Py_INCREF(io);
 }
 
-value = PyComplex_AsCComplex(io);
+int got_value_indicator;
+int cannot_cast_indicator;
+check_bytes_for_float_compatible(io, &(value.real),
+_value_indicator, _cast_indicator);
+if (cannot_cast_indicator) {
+goto cannot_cast;
+}
+if (got_value_indicator) {
+// got it from string
+value.imag = 0.0;
+} else {
+value = PyComplex_AsCComplex(io);
+}
 Py_DECREF(io);
-if (value.real == -1.0 && value.imag == 0.0 && PyErr_Occurred())
+if (value.real == -1.0 && value.imag == 0.0 && PyErr_Occurred()) {
 return NULL;
-
+}
 cd = _new_casted_primitive(ct);
 if (cd != NULL) {
 write_raw_complex_data(cd->c_data, value, ct->ct_size);
diff --git a/c/test_c.py b/c/test_c.py
--- a/c/test_c.py
+++ b/c/test_c.py
@@ -206,8 +206,9 @@
 
 assert cast(p, -1.1j) != cast(p, -1.1j)
 assert repr(complex(cast(p, -0.0)).real) == '-0.0'
-assert repr(complex(cast(p, -0j))) == '-0j'
-assert complex(cast(p, '\x09')) == 9.0
+#assert repr(complex(cast(p, -0j))) == '-0j'   # 
http://bugs.python.org/issue29602
+assert complex(cast(p, b'\x09')) == 9.0
+assert complex(cast(p, u+'\x09')) == 9.0
 assert complex(cast(p, True)) == 1.0
 py.test.raises(TypeError, cast, p, None)
 #
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: remove two wraps and a str_w

2017-02-19 Thread cfbolz
Author: Carl Friedrich Bolz 
Branch: 
Changeset: r90214:408b2ec34a3f
Date: 2017-02-19 21:49 +0100
http://bitbucket.org/pypy/pypy/changeset/408b2ec34a3f/

Log:remove two wraps and a str_w

diff --git a/pypy/interpreter/astcompiler/astbuilder.py 
b/pypy/interpreter/astcompiler/astbuilder.py
--- a/pypy/interpreter/astcompiler/astbuilder.py
+++ b/pypy/interpreter/astcompiler/astbuilder.py
@@ -1105,7 +1105,7 @@
 raise
 # UnicodeError in literal: turn into SyntaxError
 e.normalize_exception(space)
-errmsg = space.str_w(space.str(e.get_w_value(space)))
+errmsg = space.text_w(space.str(e.get_w_value(space)))
 raise self.error('(unicode error) %s' % errmsg, atom_node)
 # This implements implicit string concatenation.
 if len(sub_strings_w) > 1:
diff --git a/pypy/module/cpyext/userslot.py b/pypy/module/cpyext/userslot.py
--- a/pypy/module/cpyext/userslot.py
+++ b/pypy/module/cpyext/userslot.py
@@ -26,7 +26,7 @@
 
 @slot_function([PyObject, Py_ssize_t], PyObject)
 def slot_sq_item(space, w_obj, index):
-return space.getitem(w_obj, space.wrap(index))
+return space.getitem(w_obj, space.newint(index))
 
 @slot_function([PyTypeObjectPtr, PyObject, PyObject], PyObject)
 def slot_tp_new(space, w_type, w_args, w_kwds):
@@ -39,12 +39,12 @@
 # we know (since we are in this function) that self is not a cpytype
 from pypy.module.cpyext.typeobject import W_PyCTypeObject
 w_type0 = w_type
-mro_w = space.listview(space.getattr(w_type0, space.wrap('__mro__')))
+mro_w = space.listview(space.getattr(w_type0, space.newtext('__mro__')))
 for w_m in mro_w[1:]:
 if not w_type0.is_cpytype():
 break
 w_type0 = w_m
-w_impl = space.getattr(w_type0, space.wrap('__new__'))
+w_impl = space.getattr(w_type0, space.newtext('__new__'))
 args = Arguments(space, [w_type],
  w_stararg=w_args, w_starstararg=w_kwds)
 return space.call_args(w_impl, args)
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


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

2017-02-19 Thread arigo
Author: Armin Rigo 
Branch: extradoc
Changeset: r864:e44365234a13
Date: 2017-02-19 20:04 +0100
http://bitbucket.org/pypy/pypy.org/changeset/e44365234a13/

Log:update the values

diff --git a/don1.html b/don1.html
--- a/don1.html
+++ b/don1.html
@@ -15,7 +15,7 @@
 
 

-   $66639 of $105000 (63.5%)
+   $66648 of $105000 (63.5%)


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


[pypy-commit] pypy py3.5: typo

2017-02-19 Thread arigo
Author: Armin Rigo 
Branch: py3.5
Changeset: r90212:aabda7c4125f
Date: 2017-02-19 18:45 +0100
http://bitbucket.org/pypy/pypy/changeset/aabda7c4125f/

Log:typo

diff --git a/pypy/module/struct/test/test_struct.py 
b/pypy/module/struct/test/test_struct.py
--- a/pypy/module/struct/test/test_struct.py
+++ b/pypy/module/struct/test/test_struct.py
@@ -379,7 +379,7 @@
 assert bytes(b2) == self.struct.pack("ii", 17, 42) + (b'\x00' * 11)
 
 exc = raises(TypeError, self.struct.pack_into, "ii", b'test', 0, 17, 
42)
-assert str(exc.value) == "a read-write buffer is requried, not bytes"
+assert str(exc.value) == "a read-write buffer is required, not bytes"
 exc = raises(self.struct.error, self.struct.pack_into, "ii", b[0:1], 
0, 17, 42)
 assert str(exc.value) == "pack_into requires a buffer of at least 8 
bytes"
 
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy py3.5: hg merge default

2017-02-19 Thread arigo
Author: Armin Rigo 
Branch: py3.5
Changeset: r90213:691bc97b8dc9
Date: 2017-02-19 18:47 +0100
http://bitbucket.org/pypy/pypy/changeset/691bc97b8dc9/

Log:hg merge default

diff --git a/rpython/annotator/unaryop.py b/rpython/annotator/unaryop.py
--- a/rpython/annotator/unaryop.py
+++ b/rpython/annotator/unaryop.py
@@ -699,7 +699,7 @@
 if enc not in ('ascii', 'latin-1', 'utf-8'):
 raise AnnotatorError("Encoding %s not supported for unicode" % 
(enc,))
 return SomeString(no_nul=self.no_nul)
-method_encode.can_only_throw = [UnicodeEncodeError]
+method_encode.can_only_throw = []
 
 
 class __extend__(SomeString):
diff --git a/rpython/rlib/runicode.py b/rpython/rlib/runicode.py
--- a/rpython/rlib/runicode.py
+++ b/rpython/rlib/runicode.py
@@ -110,21 +110,10 @@
 def ll_unicode_error_decode(errors, encoding, msg, s, startingpos, endingpos):
 raise UnicodeDecodeError(encoding, s, startingpos, endingpos, msg)
 
-def ll_unicode_error_encode(errors, encoding, msg, u, startingpos, endingpos):
-raise UnicodeEncodeError(encoding, u, startingpos, endingpos, msg)
-
 # 
 # utf-8
 
-utf8_code_length = [
-1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, # 00-0F
-1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
-1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
-1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
-1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
-1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
-1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
-1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, # 70-7F
+_utf8_code_length = ''.join(map(chr, [
 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, # 80-8F
 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
@@ -133,7 +122,7 @@
 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, # D0-DF
 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, # E0-EF
 4, 4, 4, 4, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0  # F0-F4 - F5-FF
-]
+]))
 
 # if you can't use the @elidable version, call str_decode_utf_8_impl()
 # directly
@@ -190,7 +179,7 @@
 pos += 1
 continue
 
-n = utf8_code_length[ordch1]
+n = ord(_utf8_code_length[ordch1 - 0x80])
 if pos + n > size:
 if not final:
 break
@@ -365,7 +354,7 @@
 s = NonConstant(u'?')
 size = NonConstant(12345)
 errors = NonConstant('strict')
-errorhandler = ll_unicode_error_encode
+# no errorhandler needed for rtyper/rstr.py
 allow_surrogates = NonConstant(True)
 return unicode_encode_utf_8_elidable(s, size, errors, errorhandler,
  allow_surrogates=allow_surrogates)
diff --git a/rpython/rtyper/rstr.py b/rpython/rtyper/rstr.py
--- a/rpython/rtyper/rstr.py
+++ b/rpython/rtyper/rstr.py
@@ -390,10 +390,8 @@
 from rpython.rlib import runicode
 s = hlunicode(ll_s)
 assert s is not None
-errorhandler = runicode.ll_unicode_error_encode
 bytes = runicode.unicode_encode_utf_8_elidable(
-s, len(s), 'strict',
-errorhandler=errorhandler, allow_surrogates=True)
+s, len(s), 'strict', None, True)
 return self.ll.llstr(bytes)
 
 def rtype_method_encode(self, hop):
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: more attempts to fix translation errors

2017-02-19 Thread arigo
Author: Armin Rigo 
Branch: 
Changeset: r90211:ecec05ae43ec
Date: 2017-02-19 18:43 +0100
http://bitbucket.org/pypy/pypy/changeset/ecec05ae43ec/

Log:more attempts to fix translation errors

diff --git a/rpython/annotator/unaryop.py b/rpython/annotator/unaryop.py
--- a/rpython/annotator/unaryop.py
+++ b/rpython/annotator/unaryop.py
@@ -699,7 +699,7 @@
 if enc not in ('ascii', 'latin-1', 'utf-8'):
 raise AnnotatorError("Encoding %s not supported for unicode" % 
(enc,))
 return SomeString(no_nul=self.no_nul)
-method_encode.can_only_throw = [UnicodeEncodeError]
+method_encode.can_only_throw = []
 
 
 class __extend__(SomeString):
diff --git a/rpython/rlib/runicode.py b/rpython/rlib/runicode.py
--- a/rpython/rlib/runicode.py
+++ b/rpython/rlib/runicode.py
@@ -110,9 +110,6 @@
 def ll_unicode_error_decode(errors, encoding, msg, s, startingpos, endingpos):
 raise UnicodeDecodeError(encoding, s, startingpos, endingpos, msg)
 
-def ll_unicode_error_encode(errors, encoding, msg, u, startingpos, endingpos):
-raise UnicodeEncodeError(encoding, u, startingpos, endingpos, msg)
-
 # 
 # utf-8
 
@@ -357,7 +354,7 @@
 s = NonConstant(u'?')
 size = NonConstant(12345)
 errors = NonConstant('strict')
-errorhandler = ll_unicode_error_encode
+# no errorhandler needed for rtyper/rstr.py
 allow_surrogates = NonConstant(True)
 return unicode_encode_utf_8_elidable(s, size, errors, errorhandler,
  allow_surrogates=allow_surrogates)
diff --git a/rpython/rtyper/rstr.py b/rpython/rtyper/rstr.py
--- a/rpython/rtyper/rstr.py
+++ b/rpython/rtyper/rstr.py
@@ -390,10 +390,8 @@
 from rpython.rlib import runicode
 s = hlunicode(ll_s)
 assert s is not None
-errorhandler = runicode.ll_unicode_error_encode
 bytes = runicode.unicode_encode_utf_8_elidable(
-s, len(s), 'strict',
-errorhandler=errorhandler, allow_surrogates=True)
+s, len(s), 'strict', None, True)
 return self.ll.llstr(bytes)
 
 def rtype_method_encode(self, hop):
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: reduce the footprint of this table

2017-02-19 Thread arigo
Author: Armin Rigo 
Branch: 
Changeset: r90210:952e978c7009
Date: 2017-02-19 17:45 +0100
http://bitbucket.org/pypy/pypy/changeset/952e978c7009/

Log:reduce the footprint of this table

diff --git a/rpython/rlib/runicode.py b/rpython/rlib/runicode.py
--- a/rpython/rlib/runicode.py
+++ b/rpython/rlib/runicode.py
@@ -116,15 +116,7 @@
 # 
 # utf-8
 
-utf8_code_length = [
-1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, # 00-0F
-1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
-1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
-1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
-1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
-1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
-1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
-1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, # 70-7F
+_utf8_code_length = ''.join(map(chr, [
 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, # 80-8F
 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
@@ -133,7 +125,7 @@
 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, # D0-DF
 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, # E0-EF
 4, 4, 4, 4, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0  # F0-F4 - F5-FF
-]
+]))
 
 # if you can't use the @elidable version, call str_decode_utf_8_impl()
 # directly
@@ -190,7 +182,7 @@
 pos += 1
 continue
 
-n = utf8_code_length[ordch1]
+n = ord(_utf8_code_length[ordch1 - 0x80])
 if pos + n > size:
 if not final:
 break
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy py3.5: hg merge default

2017-02-19 Thread arigo
Author: Armin Rigo 
Branch: py3.5
Changeset: r90209:d9cf694006ab
Date: 2017-02-19 17:06 +0100
http://bitbucket.org/pypy/pypy/changeset/d9cf694006ab/

Log:hg merge default

diff --git a/rpython/rlib/runicode.py b/rpython/rlib/runicode.py
--- a/rpython/rlib/runicode.py
+++ b/rpython/rlib/runicode.py
@@ -107,6 +107,12 @@
 return u'', None, endingpos
 raise UnicodeEncodeError(encoding, u, startingpos, endingpos, msg)
 
+def ll_unicode_error_decode(errors, encoding, msg, s, startingpos, endingpos):
+raise UnicodeDecodeError(encoding, s, startingpos, endingpos, msg)
+
+def ll_unicode_error_encode(errors, encoding, msg, u, startingpos, endingpos):
+raise UnicodeEncodeError(encoding, u, startingpos, endingpos, msg)
+
 # 
 # utf-8
 
@@ -143,8 +149,8 @@
 size = NonConstant(12345)
 errors = NonConstant('strict')
 final = NonConstant(True)
-errorhandler = default_unicode_error_decode
-allow_surrogates = NonConstant(False)
+errorhandler = ll_unicode_error_decode
+allow_surrogates = NonConstant(True)
 return str_decode_utf_8_elidable(s, size, errors, final, errorhandler,
  allow_surrogates=allow_surrogates)
 
@@ -359,8 +365,8 @@
 s = NonConstant(u'?')
 size = NonConstant(12345)
 errors = NonConstant('strict')
-errorhandler = default_unicode_error_encode
-allow_surrogates = NonConstant(False)
+errorhandler = ll_unicode_error_encode
+allow_surrogates = NonConstant(True)
 return unicode_encode_utf_8_elidable(s, size, errors, errorhandler,
  allow_surrogates=allow_surrogates)
 
diff --git a/rpython/rtyper/rstr.py b/rpython/rtyper/rstr.py
--- a/rpython/rtyper/rstr.py
+++ b/rpython/rtyper/rstr.py
@@ -23,7 +23,7 @@
 from rpython.rlib import runicode
 value = hlstr(llvalue)
 assert value is not None
-errorhandler = runicode.default_unicode_error_decode
+errorhandler = runicode.ll_unicode_error_decode
 u, pos = runicode.str_decode_utf_8_elidable(
 value, len(value), 'strict', True, errorhandler, True)
 # XXX maybe the whole ''.decode('utf-8') should be not RPython.
@@ -390,7 +390,7 @@
 from rpython.rlib import runicode
 s = hlunicode(ll_s)
 assert s is not None
-errorhandler = runicode.default_unicode_error_encode
+errorhandler = runicode.ll_unicode_error_encode
 bytes = runicode.unicode_encode_utf_8_elidable(
 s, len(s), 'strict',
 errorhandler=errorhandler, allow_surrogates=True)
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: translation fix (mostly for tests)

2017-02-19 Thread arigo
Author: Armin Rigo 
Branch: 
Changeset: r90208:3b6d1f077a95
Date: 2017-02-19 17:06 +0100
http://bitbucket.org/pypy/pypy/changeset/3b6d1f077a95/

Log:translation fix (mostly for tests)

diff --git a/rpython/rlib/runicode.py b/rpython/rlib/runicode.py
--- a/rpython/rlib/runicode.py
+++ b/rpython/rlib/runicode.py
@@ -107,6 +107,12 @@
 return u'', None, endingpos
 raise UnicodeEncodeError(encoding, u, startingpos, endingpos, msg)
 
+def ll_unicode_error_decode(errors, encoding, msg, s, startingpos, endingpos):
+raise UnicodeDecodeError(encoding, s, startingpos, endingpos, msg)
+
+def ll_unicode_error_encode(errors, encoding, msg, u, startingpos, endingpos):
+raise UnicodeEncodeError(encoding, u, startingpos, endingpos, msg)
+
 # 
 # utf-8
 
@@ -143,8 +149,8 @@
 size = NonConstant(12345)
 errors = NonConstant('strict')
 final = NonConstant(True)
-errorhandler = default_unicode_error_decode
-allow_surrogates = NonConstant(False)
+errorhandler = ll_unicode_error_decode
+allow_surrogates = NonConstant(True)
 return str_decode_utf_8_elidable(s, size, errors, final, errorhandler,
  allow_surrogates=allow_surrogates)
 
@@ -359,8 +365,8 @@
 s = NonConstant(u'?')
 size = NonConstant(12345)
 errors = NonConstant('strict')
-errorhandler = default_unicode_error_encode
-allow_surrogates = NonConstant(False)
+errorhandler = ll_unicode_error_encode
+allow_surrogates = NonConstant(True)
 return unicode_encode_utf_8_elidable(s, size, errors, errorhandler,
  allow_surrogates=allow_surrogates)
 
diff --git a/rpython/rtyper/rstr.py b/rpython/rtyper/rstr.py
--- a/rpython/rtyper/rstr.py
+++ b/rpython/rtyper/rstr.py
@@ -23,7 +23,7 @@
 from rpython.rlib import runicode
 value = hlstr(llvalue)
 assert value is not None
-errorhandler = runicode.default_unicode_error_decode
+errorhandler = runicode.ll_unicode_error_decode
 u, pos = runicode.str_decode_utf_8_elidable(
 value, len(value), 'strict', True, errorhandler, True)
 # XXX maybe the whole ''.decode('utf-8') should be not RPython.
@@ -390,7 +390,7 @@
 from rpython.rlib import runicode
 s = hlunicode(ll_s)
 assert s is not None
-errorhandler = runicode.default_unicode_error_encode
+errorhandler = runicode.ll_unicode_error_encode
 bytes = runicode.unicode_encode_utf_8_elidable(
 s, len(s), 'strict',
 errorhandler=errorhandler, allow_surrogates=True)
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy py3.5: hg merge default

2017-02-19 Thread arigo
Author: Armin Rigo 
Branch: py3.5
Changeset: r90207:6ea6e99c6940
Date: 2017-02-19 16:55 +0100
http://bitbucket.org/pypy/pypy/changeset/6ea6e99c6940/

Log:hg merge default

diff --git a/rpython/rtyper/rstr.py b/rpython/rtyper/rstr.py
--- a/rpython/rtyper/rstr.py
+++ b/rpython/rtyper/rstr.py
@@ -25,11 +25,7 @@
 assert value is not None
 errorhandler = runicode.default_unicode_error_decode
 u, pos = runicode.str_decode_utf_8_elidable(
-value, len(value), 'strict', True, errorhandler, False)
-# XXX should it really be 'allow_surrogates=False'?  In RPython,
-# unicode.decode('utf-8') happily accepts surrogates.  This
-# makes it hard to test untranslated (it's the cause of a
-# failure in lib-python's test_warnings on PyPy3, for example)
+value, len(value), 'strict', True, errorhandler, True)
 # XXX maybe the whole ''.decode('utf-8') should be not RPython.
 return self.ll.llunicode(u)
 
@@ -397,7 +393,7 @@
 errorhandler = runicode.default_unicode_error_encode
 bytes = runicode.unicode_encode_utf_8_elidable(
 s, len(s), 'strict',
-errorhandler=errorhandler, allow_surrogates=False)
+errorhandler=errorhandler, allow_surrogates=True)
 return self.ll.llstr(bytes)
 
 def rtype_method_encode(self, hop):
diff --git a/rpython/rtyper/test/test_runicode.py 
b/rpython/rtyper/test/test_runicode.py
--- a/rpython/rtyper/test/test_runicode.py
+++ b/rpython/rtyper/test/test_runicode.py
@@ -110,7 +110,13 @@
 x = u'\ud800' + unichr(n)
 return x.encode('utf-8')
 
-self.interpret_raises(UnicodeEncodeError, g, [38])
+# used to raise in RPython, but not when run as plain Python,
+# which just makes code very hard to test.  Nowadays, .encode()
+# and .decode() accept surrogates like in Python 2.7.  Use
+# functions from the rlib.runicode module if you need stricter
+# behavior.
+#self.interpret_raises(UnicodeEncodeError, g, [38])
+assert self.ll_to_string(self.interpret(g, [38])) == g(38)
 
 def test_utf_8_encoding_annotation(self):
 from rpython.rlib.runicode import unicode_encode_utf_8
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy py3.5: spacing

2017-02-19 Thread arigo
Author: Armin Rigo 
Branch: py3.5
Changeset: r90206:135243084607
Date: 2017-02-19 16:55 +0100
http://bitbucket.org/pypy/pypy/changeset/135243084607/

Log:spacing

diff --git a/pypy/objspace/std/test/test_typeobject.py 
b/pypy/objspace/std/test/test_typeobject.py
--- a/pypy/objspace/std/test/test_typeobject.py
+++ b/pypy/objspace/std/test/test_typeobject.py
@@ -1412,6 +1412,8 @@
 assert type.__ne__(dict, 42) is NotImplemented
 assert type.__eq__(int, int) == True
 assert type.__eq__(int, dict) is NotImplemented
+
+
 class AppTestComparesByIdentity:
 
 def setup_class(cls):
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: Give up the fact that str.encode('utf-8') doesn't accept surrogates

2017-02-19 Thread arigo
Author: Armin Rigo 
Branch: 
Changeset: r90205:08b2dac171f5
Date: 2017-02-19 16:54 +0100
http://bitbucket.org/pypy/pypy/changeset/08b2dac171f5/

Log:Give up the fact that str.encode('utf-8') doesn't accept surrogates
in RPython. This is just asking for troubles because the same code
accepts surrogates when run as plain Python (2.7).

diff --git a/rpython/rtyper/rstr.py b/rpython/rtyper/rstr.py
--- a/rpython/rtyper/rstr.py
+++ b/rpython/rtyper/rstr.py
@@ -25,11 +25,7 @@
 assert value is not None
 errorhandler = runicode.default_unicode_error_decode
 u, pos = runicode.str_decode_utf_8_elidable(
-value, len(value), 'strict', True, errorhandler, False)
-# XXX should it really be 'allow_surrogates=False'?  In RPython,
-# unicode.decode('utf-8') happily accepts surrogates.  This
-# makes it hard to test untranslated (it's the cause of a
-# failure in lib-python's test_warnings on PyPy3, for example)
+value, len(value), 'strict', True, errorhandler, True)
 # XXX maybe the whole ''.decode('utf-8') should be not RPython.
 return self.ll.llunicode(u)
 
@@ -397,7 +393,7 @@
 errorhandler = runicode.default_unicode_error_encode
 bytes = runicode.unicode_encode_utf_8_elidable(
 s, len(s), 'strict',
-errorhandler=errorhandler, allow_surrogates=False)
+errorhandler=errorhandler, allow_surrogates=True)
 return self.ll.llstr(bytes)
 
 def rtype_method_encode(self, hop):
diff --git a/rpython/rtyper/test/test_runicode.py 
b/rpython/rtyper/test/test_runicode.py
--- a/rpython/rtyper/test/test_runicode.py
+++ b/rpython/rtyper/test/test_runicode.py
@@ -110,7 +110,13 @@
 x = u'\ud800' + unichr(n)
 return x.encode('utf-8')
 
-self.interpret_raises(UnicodeEncodeError, g, [38])
+# used to raise in RPython, but not when run as plain Python,
+# which just makes code very hard to test.  Nowadays, .encode()
+# and .decode() accept surrogates like in Python 2.7.  Use
+# functions from the rlib.runicode module if you need stricter
+# behavior.
+#self.interpret_raises(UnicodeEncodeError, g, [38])
+assert self.ll_to_string(self.interpret(g, [38])) == g(38)
 
 def test_utf_8_encoding_annotation(self):
 from rpython.rlib.runicode import unicode_encode_utf_8
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: test and fix

2017-02-19 Thread arigo
Author: Armin Rigo 
Branch: 
Changeset: r90203:4334782fe642
Date: 2017-02-19 16:41 +0100
http://bitbucket.org/pypy/pypy/changeset/4334782fe642/

Log:test and fix

diff --git a/pypy/module/posix/interp_posix.py 
b/pypy/module/posix/interp_posix.py
--- a/pypy/module/posix/interp_posix.py
+++ b/pypy/module/posix/interp_posix.py
@@ -378,7 +378,7 @@
 except OSError as e:
 raise wrap_oserror2(space, e, w_path)
 else:
-return space.newint(ok)
+return space.newbool(ok)
 
 
 def times(space):
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
@@ -368,11 +368,11 @@
 pdir = self.pdir + '/file1'
 posix = self.posix
 
-assert posix.access(pdir, posix.R_OK)
-assert posix.access(pdir, posix.W_OK)
+assert posix.access(pdir, posix.R_OK) is True
+assert posix.access(pdir, posix.W_OK) is True
 import sys
 if sys.platform != "win32":
-assert not posix.access(pdir, posix.X_OK)
+assert posix.access(pdir, posix.X_OK) is False
 
 def test_times(self):
 """
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy py3.5: hg merge default

2017-02-19 Thread arigo
Author: Armin Rigo 
Branch: py3.5
Changeset: r90204:13731a1c2af6
Date: 2017-02-19 16:41 +0100
http://bitbucket.org/pypy/pypy/changeset/13731a1c2af6/

Log:hg merge default

diff --git a/pypy/module/posix/interp_posix.py 
b/pypy/module/posix/interp_posix.py
--- a/pypy/module/posix/interp_posix.py
+++ b/pypy/module/posix/interp_posix.py
@@ -621,7 +621,7 @@
 except OSError as e:
 raise wrap_oserror2(space, e, w_path, eintr_retry=False)
 else:
-return space.newint(ok)
+return space.newbool(ok)
 
 
 def times(space):
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
@@ -362,11 +362,11 @@
 pdir = self.pdir + '/file1'
 posix = self.posix
 
-assert posix.access(pdir, posix.R_OK)
-assert posix.access(pdir, posix.W_OK)
+assert posix.access(pdir, posix.R_OK) is True
+assert posix.access(pdir, posix.W_OK) is True
 import sys
 if sys.platform != "win32":
-assert not posix.access(pdir, posix.X_OK)
+assert posix.access(pdir, posix.X_OK) is False
 
 def test_times(self):
 """
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy py3.5: fix test

2017-02-19 Thread arigo
Author: Armin Rigo 
Branch: py3.5
Changeset: r90202:0e13d85aff3f
Date: 2017-02-19 16:14 +0100
http://bitbucket.org/pypy/pypy/changeset/0e13d85aff3f/

Log:fix test

diff --git a/pypy/module/imp/test/test_app.py b/pypy/module/imp/test/test_app.py
--- a/pypy/module/imp/test/test_app.py
+++ b/pypy/module/imp/test/test_app.py
@@ -73,7 +73,10 @@
 # passed in, whose value is ignored. We don't implement that.
 #raises(IOError, _imp.create_dynamic, FakeSpec(), "unused")
 
-raises(ImportError, _imp.create_dynamic, FakeSpec(b'foo'))
+# Note: On CPython, the following gives nonsense.  I suspect
+# it's because the b'foo' is read with PyUnicode_Xxx()
+# functions that don't check the type of the argument.
+raises(TypeError, _imp.create_dynamic, FakeSpec(b'foo'))
 
 def test_suffixes(self):
 import imp
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: fix (for py3)

2017-02-19 Thread arigo
Author: Armin Rigo 
Branch: 
Changeset: r90200:56126b34d84c
Date: 2017-02-19 16:04 +0100
http://bitbucket.org/pypy/pypy/changeset/56126b34d84c/

Log:fix (for py3)

diff --git a/pypy/module/cpyext/test/test_userslots.py 
b/pypy/module/cpyext/test/test_userslots.py
--- a/pypy/module/cpyext/test/test_userslots.py
+++ b/pypy/module/cpyext/test/test_userslots.py
@@ -39,12 +39,12 @@
 arg = space.newtuple([one, one, one])
 # call w_date.__new__
 w_obj = space.call_function(w_date, one, one, one)
-w_year = space.getattr(w_obj, space.newbytes('year'))
+w_year = space.getattr(w_obj, space.newtext('year'))
 assert space.int_w(w_year) == 1
 
 w_obj = generic_cpy_call(space, py_datetype.c_tp_new, py_datetype,
  arg, space.newdict({}))
-w_year = space.getattr(w_obj, space.newbytes('year'))
+w_year = space.getattr(w_obj, space.newtext('year'))
 assert space.int_w(w_year) == 1
 
 class AppTestUserSlots(AppTestCpythonExtensionBase):
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy py3.5: hg merge default

2017-02-19 Thread arigo
Author: Armin Rigo 
Branch: py3.5
Changeset: r90201:bd18926a5492
Date: 2017-02-19 16:05 +0100
http://bitbucket.org/pypy/pypy/changeset/bd18926a5492/

Log:hg merge default

diff --git a/lib_pypy/_ctypes/function.py b/lib_pypy/_ctypes/function.py
--- a/lib_pypy/_ctypes/function.py
+++ b/lib_pypy/_ctypes/function.py
@@ -604,7 +604,8 @@
 """
 # hack for performance: if restype is a "simple" primitive type, don't
 # allocate the buffer because it's going to be thrown away immediately
-if self._is_primitive(restype) and not restype._is_pointer_like():
+if (self._is_primitive(restype) and restype._type_ != '?'
+and not restype._is_pointer_like()):
 return result
 #
 shape = restype._ffishape_
diff --git a/lib_pypy/cffi/backend_ctypes.py b/lib_pypy/cffi/backend_ctypes.py
--- a/lib_pypy/cffi/backend_ctypes.py
+++ b/lib_pypy/cffi/backend_ctypes.py
@@ -112,11 +112,20 @@
 def _make_cmp(name):
 cmpfunc = getattr(operator, name)
 def cmp(self, other):
-if isinstance(other, CTypesData):
+v_is_ptr = not isinstance(self, CTypesGenericPrimitive)
+w_is_ptr = (isinstance(other, CTypesData) and
+   not isinstance(other, CTypesGenericPrimitive))
+if v_is_ptr and w_is_ptr:
 return cmpfunc(self._convert_to_address(None),
other._convert_to_address(None))
+elif v_is_ptr or w_is_ptr:
+return NotImplemented
 else:
-return NotImplemented
+if isinstance(self, CTypesGenericPrimitive):
+self = self._value
+if isinstance(other, CTypesGenericPrimitive):
+other = other._value
+return cmpfunc(self, other)
 cmp.func_name = name
 return cmp
 
@@ -128,7 +137,7 @@
 __ge__ = _make_cmp('__ge__')
 
 def __hash__(self):
-return hash(type(self)) ^ hash(self._convert_to_address(None))
+return hash(self._convert_to_address(None))
 
 def _to_string(self, maxlen):
 raise TypeError("string(): %r" % (self,))
@@ -137,14 +146,8 @@
 class CTypesGenericPrimitive(CTypesData):
 __slots__ = []
 
-def __eq__(self, other):
-return self is other
-
-def __ne__(self, other):
-return self is not other
-
 def __hash__(self):
-return object.__hash__(self)
+return hash(self._value)
 
 def _get_own_repr(self):
 return repr(self._from_ctypes(self._value))
diff --git a/pypy/module/_cffi_backend/cdataobj.py 
b/pypy/module/_cffi_backend/cdataobj.py
--- a/pypy/module/_cffi_backend/cdataobj.py
+++ b/pypy/module/_cffi_backend/cdataobj.py
@@ -99,27 +99,39 @@
 raise oefmt(space.w_TypeError,
 "cdata of type '%s' has no len()", self.ctype.name)
 
+def _compare_mode(self, w_other):
+from pypy.module._cffi_backend.ctypeprim import W_CTypePrimitive
+zero = rffi.cast(lltype.Unsigned, 0)
+self_is_ptr = not isinstance(self.ctype, W_CTypePrimitive)
+other_is_ptr = (isinstance(w_other, W_CData) and
+   not isinstance(w_other.ctype, W_CTypePrimitive))
+if other_is_ptr and self_is_ptr:
+with self as ptr1, w_other as ptr2:
+ptr1 = rffi.cast(lltype.Unsigned, ptr1)
+ptr2 = rffi.cast(lltype.Unsigned, ptr2)
+return (0, ptr1, ptr2, None, None)
+elif other_is_ptr or self_is_ptr:
+return (-1, zero, zero, None, None)
+else:
+w_ob1 = self.convert_to_object()
+if isinstance(w_other, W_CData):
+w_ob2 = w_other.convert_to_object()
+else:
+w_ob2 = w_other
+return (1, zero, zero, w_ob1, w_ob2)
+
 def _make_comparison(name):
 op = getattr(operator, name)
-requires_ordering = name not in ('eq', 'ne')
 #
 def _cmp(self, w_other):
-from pypy.module._cffi_backend.ctypeprim import W_CTypePrimitive
 space = self.space
-if not isinstance(w_other, W_CData):
+mode, adr1, adr2, w_ob1, w_ob2 = self._compare_mode(w_other)
+if mode == 0:
+return space.newbool(op(adr1, adr2))
+elif mode == 1:
+return getattr(space, name)(w_ob1, w_ob2)
+else:
 return space.w_NotImplemented
-
-with self as ptr1, w_other as ptr2:
-if requires_ordering:
-if (isinstance(self.ctype, W_CTypePrimitive) or
-isinstance(w_other.ctype, W_CTypePrimitive)):
-raise oefmt(space.w_TypeError,
-"cannot do comparison on a primitive "
-"cdata")
-ptr1 = 

[pypy-commit] pypy py3.5: fix test_surrogate_in_filename

2017-02-19 Thread arigo
Author: Armin Rigo 
Branch: py3.5
Changeset: r90199:fea26f231a97
Date: 2017-02-19 16:00 +0100
http://bitbucket.org/pypy/pypy/changeset/fea26f231a97/

Log:fix test_surrogate_in_filename

diff --git a/pypy/module/_warnings/interp_warnings.py 
b/pypy/module/_warnings/interp_warnings.py
--- a/pypy/module/_warnings/interp_warnings.py
+++ b/pypy/module/_warnings/interp_warnings.py
@@ -226,7 +226,7 @@
 return False
 
 def normalize_module(space, w_filename):
-filename = space.identifier_w(w_filename)
+filename = space.text_w(w_filename)
 if len(filename) == 0:
 return space.newtext("")
 if filename.endswith(".py"):
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: update to cffi/91fcbd69bce2: cffi issue #255

2017-02-19 Thread arigo
Author: Armin Rigo 
Branch: 
Changeset: r90198:87cd234e833d
Date: 2017-02-19 15:53 +0100
http://bitbucket.org/pypy/pypy/changeset/87cd234e833d/

Log:update to cffi/91fcbd69bce2: cffi issue #255

diff --git a/lib_pypy/cffi/backend_ctypes.py b/lib_pypy/cffi/backend_ctypes.py
--- a/lib_pypy/cffi/backend_ctypes.py
+++ b/lib_pypy/cffi/backend_ctypes.py
@@ -112,11 +112,20 @@
 def _make_cmp(name):
 cmpfunc = getattr(operator, name)
 def cmp(self, other):
-if isinstance(other, CTypesData):
+v_is_ptr = not isinstance(self, CTypesGenericPrimitive)
+w_is_ptr = (isinstance(other, CTypesData) and
+   not isinstance(other, CTypesGenericPrimitive))
+if v_is_ptr and w_is_ptr:
 return cmpfunc(self._convert_to_address(None),
other._convert_to_address(None))
+elif v_is_ptr or w_is_ptr:
+return NotImplemented
 else:
-return NotImplemented
+if isinstance(self, CTypesGenericPrimitive):
+self = self._value
+if isinstance(other, CTypesGenericPrimitive):
+other = other._value
+return cmpfunc(self, other)
 cmp.func_name = name
 return cmp
 
@@ -128,7 +137,7 @@
 __ge__ = _make_cmp('__ge__')
 
 def __hash__(self):
-return hash(type(self)) ^ hash(self._convert_to_address(None))
+return hash(self._convert_to_address(None))
 
 def _to_string(self, maxlen):
 raise TypeError("string(): %r" % (self,))
@@ -137,14 +146,8 @@
 class CTypesGenericPrimitive(CTypesData):
 __slots__ = []
 
-def __eq__(self, other):
-return self is other
-
-def __ne__(self, other):
-return self is not other
-
 def __hash__(self):
-return object.__hash__(self)
+return hash(self._value)
 
 def _get_own_repr(self):
 return repr(self._from_ctypes(self._value))
diff --git a/pypy/module/_cffi_backend/cdataobj.py 
b/pypy/module/_cffi_backend/cdataobj.py
--- a/pypy/module/_cffi_backend/cdataobj.py
+++ b/pypy/module/_cffi_backend/cdataobj.py
@@ -99,27 +99,39 @@
 raise oefmt(space.w_TypeError,
 "cdata of type '%s' has no len()", self.ctype.name)
 
+def _compare_mode(self, w_other):
+from pypy.module._cffi_backend.ctypeprim import W_CTypePrimitive
+zero = rffi.cast(lltype.Unsigned, 0)
+self_is_ptr = not isinstance(self.ctype, W_CTypePrimitive)
+other_is_ptr = (isinstance(w_other, W_CData) and
+   not isinstance(w_other.ctype, W_CTypePrimitive))
+if other_is_ptr and self_is_ptr:
+with self as ptr1, w_other as ptr2:
+ptr1 = rffi.cast(lltype.Unsigned, ptr1)
+ptr2 = rffi.cast(lltype.Unsigned, ptr2)
+return (0, ptr1, ptr2, None, None)
+elif other_is_ptr or self_is_ptr:
+return (-1, zero, zero, None, None)
+else:
+w_ob1 = self.convert_to_object()
+if isinstance(w_other, W_CData):
+w_ob2 = w_other.convert_to_object()
+else:
+w_ob2 = w_other
+return (1, zero, zero, w_ob1, w_ob2)
+
 def _make_comparison(name):
 op = getattr(operator, name)
-requires_ordering = name not in ('eq', 'ne')
 #
 def _cmp(self, w_other):
-from pypy.module._cffi_backend.ctypeprim import W_CTypePrimitive
 space = self.space
-if not isinstance(w_other, W_CData):
+mode, adr1, adr2, w_ob1, w_ob2 = self._compare_mode(w_other)
+if mode == 0:
+return space.newbool(op(adr1, adr2))
+elif mode == 1:
+return getattr(space, name)(w_ob1, w_ob2)
+else:
 return space.w_NotImplemented
-
-with self as ptr1, w_other as ptr2:
-if requires_ordering:
-if (isinstance(self.ctype, W_CTypePrimitive) or
-isinstance(w_other.ctype, W_CTypePrimitive)):
-raise oefmt(space.w_TypeError,
-"cannot do comparison on a primitive "
-"cdata")
-ptr1 = rffi.cast(lltype.Unsigned, ptr1)
-ptr2 = rffi.cast(lltype.Unsigned, ptr2)
-result = op(ptr1, ptr2)
-return space.newbool(result)
 #
 return func_with_new_name(_cmp, name)
 
@@ -131,6 +143,11 @@
 ge = _make_comparison('ge')
 
 def hash(self):
+from pypy.module._cffi_backend.ctypeprim import W_CTypePrimitive
+if isinstance(self.ctype, W_CTypePrimitive):
+w_ob = self.convert_to_object()
+if not isinstance(w_ob, W_CData):
+return self.space.hash(w_ob)
 ptr = 

[pypy-commit] cffi default: issue #255: comparing primitive cdatas

2017-02-19 Thread arigo
Author: Armin Rigo 
Branch: 
Changeset: r2890:91fcbd69bce2
Date: 2017-02-19 14:37 +0100
http://bitbucket.org/cffi/cffi/changeset/91fcbd69bce2/

Log:issue #255: comparing primitive cdatas

diff --git a/c/_cffi_backend.c b/c/_cffi_backend.c
--- a/c/_cffi_backend.c
+++ b/c/_cffi_backend.c
@@ -2031,47 +2031,97 @@
 
 static PyObject *cdata_richcompare(PyObject *v, PyObject *w, int op)
 {
-int res;
+int v_is_ptr, w_is_ptr;
 PyObject *pyres;
-char *v_cdata, *w_cdata;
 
 assert(CData_Check(v));
-if (!CData_Check(w)) {
+
+/* Comparisons involving a primitive cdata work differently than
+ * comparisons involving a struct/array/pointer.
+ *
+ * If v or w is a struct/array/pointer, then the other must be too
+ * (otherwise we return NotImplemented and leave the case to
+ * Python).  If both are, then we compare the addresses.
+ *
+ * If v and/or w is a primitive cdata, then we convert the cdata(s)
+ * to regular Python objects and redo the comparison there.
+ */
+
+v_is_ptr = !(((CDataObject *)v)->c_type->ct_flags & CT_PRIMITIVE_ANY);
+w_is_ptr = CData_Check(w) &&
+  !(((CDataObject *)w)->c_type->ct_flags & CT_PRIMITIVE_ANY);
+
+if (v_is_ptr && w_is_ptr) {
+int res;
+char *v_cdata = ((CDataObject *)v)->c_data;
+char *w_cdata = ((CDataObject *)w)->c_data;
+
+switch (op) {
+case Py_EQ: res = (v_cdata == w_cdata); break;
+case Py_NE: res = (v_cdata != w_cdata); break;
+case Py_LT: res = (v_cdata <  w_cdata); break;
+case Py_LE: res = (v_cdata <= w_cdata); break;
+case Py_GT: res = (v_cdata >  w_cdata); break;
+case Py_GE: res = (v_cdata >= w_cdata); break;
+default: res = -1;
+}
+pyres = res ? Py_True : Py_False;
+}
+else if (v_is_ptr || w_is_ptr) {
 pyres = Py_NotImplemented;
-goto done;
-}
-
-if ((op != Py_EQ && op != Py_NE) &&
-CDataObject *)v)->c_type->ct_flags & CT_PRIMITIVE_ANY) ||
- (((CDataObject *)w)->c_type->ct_flags & CT_PRIMITIVE_ANY)))
-goto Error;
-
-v_cdata = ((CDataObject *)v)->c_data;
-w_cdata = ((CDataObject *)w)->c_data;
-
-switch (op) {
-case Py_EQ: res = (v_cdata == w_cdata); break;
-case Py_NE: res = (v_cdata != w_cdata); break;
-case Py_LT: res = (v_cdata <  w_cdata); break;
-case Py_LE: res = (v_cdata <= w_cdata); break;
-case Py_GT: res = (v_cdata >  w_cdata); break;
-case Py_GE: res = (v_cdata >= w_cdata); break;
-default: res = -1;
-}
-pyres = res ? Py_True : Py_False;
- done:
+}
+else {
+PyObject *aa[2];
+int i;
+
+aa[0] = v; Py_INCREF(v);
+aa[1] = w; Py_INCREF(w);
+pyres = NULL;
+
+for (i = 0; i < 2; i++) {
+v = aa[i];
+if (!CData_Check(v))
+continue;
+w = convert_to_object(((CDataObject *)v)->c_data,
+  ((CDataObject *)v)->c_type);
+if (w == NULL)
+goto error;
+if (CData_Check(w)) {
+Py_DECREF(w);
+PyErr_Format(PyExc_NotImplementedError,
+ "cannot use  in a comparison",
+ ((CDataObject *)v)->c_type->ct_name);
+goto error;
+}
+aa[i] = w;
+Py_DECREF(v);
+}
+pyres = PyObject_RichCompare(aa[0], aa[1], op);
+ error:
+Py_DECREF(aa[1]);
+Py_DECREF(aa[0]);
+return pyres;
+}
+
 Py_INCREF(pyres);
 return pyres;
-
- Error:
-PyErr_SetString(PyExc_TypeError,
-"cannot do comparison on a primitive cdata");
-return NULL;
-}
-
-static long cdata_hash(CDataObject *cd)
-{
-return _Py_HashPointer(cd->c_data);
+}
+
+static long cdata_hash(CDataObject *v)
+{
+if (((CDataObject *)v)->c_type->ct_flags & CT_PRIMITIVE_ANY) {
+PyObject *vv = convert_to_object(((CDataObject *)v)->c_data,
+ ((CDataObject *)v)->c_type);
+if (vv == NULL)
+return -1;
+if (!CData_Check(vv)) {
+long hash = PyObject_Hash(vv);
+Py_DECREF(vv);
+return hash;
+}
+Py_DECREF(vv);
+}
+return _Py_HashPointer(v->c_data);
 }
 
 static Py_ssize_t
diff --git a/c/test_c.py b/c/test_c.py
--- a/c/test_c.py
+++ b/c/test_c.py
@@ -27,6 +27,7 @@
.replace(r'\\U', r'\U'))
 u = U()
 str2bytes = str
+strict_compare = False
 else:
 type_or_class = "class"
 long = int
@@ -38,6 +39,7 @@
 bitem2bchr = bytechr
 u = ""
 str2bytes = lambda s: bytes(s, "ascii")
+strict_compare = True
 
 def size_of_int():
 BInt = new_primitive_type("int")
@@ -106,11 +108,11 @@
 x = cast(p, -66 + (1<<199)*256)
 assert repr(x) == ""
 assert 

[pypy-commit] pypy fix_bool_restype: Fix issue 2475: bool restypes not working

2017-02-19 Thread Graham Markall
Author: Graham Markall 
Branch: fix_bool_restype
Changeset: r90196:9bb716c6f836
Date: 2017-02-15 18:44 +
http://bitbucket.org/pypy/pypy/changeset/9bb716c6f836/

Log:Fix issue 2475: bool restypes not working

This commit adds a check to the performance hack in
CFuncPtr._wrap_result that doesn't use the hack when the return type
is bool, because a new bool object needs to be created.

A test of a C function with a bool restype is added.

diff --git a/lib_pypy/_ctypes/function.py b/lib_pypy/_ctypes/function.py
--- a/lib_pypy/_ctypes/function.py
+++ b/lib_pypy/_ctypes/function.py
@@ -604,7 +604,8 @@
 """
 # hack for performance: if restype is a "simple" primitive type, don't
 # allocate the buffer because it's going to be thrown away immediately
-if self._is_primitive(restype) and not restype._is_pointer_like():
+if (self._is_primitive(restype) and restype._type_ != '?'
+and not restype._is_pointer_like()):
 return result
 #
 shape = restype._ffishape_
diff --git a/pypy/module/test_lib_pypy/ctypes_tests/test_functions.py 
b/pypy/module/test_lib_pypy/ctypes_tests/test_functions.py
--- a/pypy/module/test_lib_pypy/ctypes_tests/test_functions.py
+++ b/pypy/module/test_lib_pypy/ctypes_tests/test_functions.py
@@ -99,6 +99,15 @@
 result = f(0, 0, 0, 0, 0, 0)
 assert result == '\x00'
 
+def test_boolresult(self):
+f = dll._testfunc_i_bhilfd
+f.argtypes = [c_byte, c_short, c_int, c_long, c_float, c_double]
+f.restype = c_bool
+false_result = f(0, 0, 0, 0, 0, 0)
+assert false_result is False
+true_result = f(1, 0, 0, 0, 0, 0)
+assert true_result is True
+
 def test_voidresult(self):
 f = dll._testfunc_v
 f.restype = None
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: Merged in gmarkall/pypy/fix_bool_restype (pull request #516)

2017-02-19 Thread arigo
Author: Armin Rigo 
Branch: 
Changeset: r90197:6b02806984f7
Date: 2017-02-19 12:02 +
http://bitbucket.org/pypy/pypy/changeset/6b02806984f7/

Log:Merged in gmarkall/pypy/fix_bool_restype (pull request #516)

Fix issue 2475: bool restypes not working

diff --git a/lib_pypy/_ctypes/function.py b/lib_pypy/_ctypes/function.py
--- a/lib_pypy/_ctypes/function.py
+++ b/lib_pypy/_ctypes/function.py
@@ -604,7 +604,8 @@
 """
 # hack for performance: if restype is a "simple" primitive type, don't
 # allocate the buffer because it's going to be thrown away immediately
-if self._is_primitive(restype) and not restype._is_pointer_like():
+if (self._is_primitive(restype) and restype._type_ != '?'
+and not restype._is_pointer_like()):
 return result
 #
 shape = restype._ffishape_
diff --git a/pypy/module/test_lib_pypy/ctypes_tests/test_functions.py 
b/pypy/module/test_lib_pypy/ctypes_tests/test_functions.py
--- a/pypy/module/test_lib_pypy/ctypes_tests/test_functions.py
+++ b/pypy/module/test_lib_pypy/ctypes_tests/test_functions.py
@@ -99,6 +99,15 @@
 result = f(0, 0, 0, 0, 0, 0)
 assert result == '\x00'
 
+def test_boolresult(self):
+f = dll._testfunc_i_bhilfd
+f.argtypes = [c_byte, c_short, c_int, c_long, c_float, c_double]
+f.restype = c_bool
+false_result = f(0, 0, 0, 0, 0, 0)
+assert false_result is False
+true_result = f(1, 0, 0, 0, 0, 0)
+assert true_result is True
+
 def test_voidresult(self):
 f = dll._testfunc_v
 f.restype = None
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy py3.5: fix merge issues: before the merge, the code (not the tests) was

2017-02-19 Thread arigo
Author: Armin Rigo 
Branch: py3.5
Changeset: r90195:0f157eedb3b2
Date: 2017-02-19 12:36 +0100
http://bitbucket.org/pypy/pypy/changeset/0f157eedb3b2/

Log:fix merge issues: before the merge, the code (not the tests) was
identical in pypy2 and pypy3, so just make it identical again

diff --git a/pypy/module/cppyy/converter.py b/pypy/module/cppyy/converter.py
--- a/pypy/module/cppyy/converter.py
+++ b/pypy/module/cppyy/converter.py
@@ -771,6 +771,7 @@
 for c_type, names, c_tc in type_info:
 class BasicConverter(ffitypes.typeid(c_type), IntTypeConverterMixin, 
TypeConverter):
 _immutable_ = True
+typecode = c_tc
 def __init__(self, space, default):
 self.default = rffi.cast(self.c_type, capi.c_strtoll(space, 
default))
 class ConstRefConverter(ConstRefNumericTypeConverterMixin, 
BasicConverter):
diff --git a/pypy/module/cppyy/ffitypes.py b/pypy/module/cppyy/ffitypes.py
--- a/pypy/module/cppyy/ffitypes.py
+++ b/pypy/module/cppyy/ffitypes.py
@@ -2,6 +2,7 @@
 
 from rpython.rtyper.lltypesystem import rffi
 from rpython.rlib.rarithmetic import r_singlefloat, r_longfloat
+from rpython.rlib.rbigint import rbigint
 
 from pypy.module._cffi_backend import newtype
 
@@ -41,7 +42,6 @@
 self.c_size_t= nt.new_primitive_type(space, 'size_t')
 self.c_ptrdiff_t = nt.new_primitive_type(space, 'ptrdiff_t')
 
-
 class BoolTypeMixin(object):
 _mixin_ = True
 _immutable_fields_ = ['c_type', 'c_ptrtype']
@@ -49,6 +49,9 @@
 c_type  = rffi.UCHAR
 c_ptrtype   = rffi.UCHARP
 
+def _wrap_object(self, space, obj):
+return space.newbool(bool(ord(rffi.cast(rffi.CHAR, obj
+
 def _unwrap_object(self, space, w_obj):
 arg = space.c_int_w(w_obj)
 if arg != False and arg != True:
@@ -56,9 +59,6 @@
 "boolean value should be bool, or integer 1 or 0")
 return arg
 
-def _wrap_object(self, space, obj):
-return space.newbool(bool(ord(rffi.cast(rffi.CHAR, obj
-
 def cffi_type(self, space):
 state = space.fromcache(State)
 return state.c_bool
@@ -93,44 +93,44 @@
 state = space.fromcache(State)
 return state.c_char
 
-class ShortTypeMixin(object):
+class BaseIntTypeMixin(object):
+_mixin_ = True
+
+def _wrap_object(self, space, obj):
+return space.newint(rffi.cast(rffi.INT, obj))
+
+def _unwrap_object(self, space, w_obj):
+return rffi.cast(self.c_type, space.c_int_w(w_obj))
+
+class ShortTypeMixin(BaseIntTypeMixin):
 _mixin_ = True
 _immutable_fields_ = ['c_type', 'c_ptrtype']
 
 c_type  = rffi.SHORT
 c_ptrtype   = rffi.SHORTP
 
-def _unwrap_object(self, space, w_obj):
-return rffi.cast(rffi.SHORT, space.int_w(w_obj))
-
+class UShortTypeMixin(BaseIntTypeMixin):
 def cffi_type(self, space):
 state = space.fromcache(State)
 return state.c_short
 
-class UShortTypeMixin(object):
 _mixin_ = True
 _immutable_fields_ = ['c_type', 'c_ptrtype']
 
 c_type  = rffi.USHORT
 c_ptrtype   = rffi.USHORTP
 
-def _unwrap_object(self, space, w_obj):
-return rffi.cast(self.c_type, space.int_w(w_obj))
-
+class IntTypeMixin(BaseIntTypeMixin):
 def cffi_type(self, space):
 state = space.fromcache(State)
 return state.c_ushort
 
-class IntTypeMixin(object):
 _mixin_ = True
 _immutable_fields_ = ['c_type', 'c_ptrtype']
 
 c_type  = rffi.INT
 c_ptrtype   = rffi.INTP
 
-def _unwrap_object(self, space, w_obj):
-return rffi.cast(self.c_type, space.c_int_w(w_obj))
-
 def cffi_type(self, space):
 state = space.fromcache(State)
 return state.c_int
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy py3.5: fix

2017-02-19 Thread arigo
Author: Armin Rigo 
Branch: py3.5
Changeset: r90194:6d2b0db1c9cd
Date: 2017-02-19 10:33 +0100
http://bitbucket.org/pypy/pypy/changeset/6d2b0db1c9cd/

Log:fix

diff --git a/pypy/objspace/std/formatting.py b/pypy/objspace/std/formatting.py
--- a/pypy/objspace/std/formatting.py
+++ b/pypy/objspace/std/formatting.py
@@ -457,7 +457,7 @@
 if do_unicode:
 value = self.space.unicode_w(w_value)
 else:
-value = self.space.bytes_w(w_value)
+value = self.space.text_w(w_value)
 self.std_wp(value)
 
 def fmt_c(self, w_value):
diff --git a/pypy/objspace/std/test/test_stringformat.py 
b/pypy/objspace/std/test/test_stringformat.py
--- a/pypy/objspace/std/test/test_stringformat.py
+++ b/pypy/objspace/std/test/test_stringformat.py
@@ -408,6 +408,7 @@
 assert b"<%a>" % b"\xe9" == b""
 assert b"<%a>" % "foo" == b"<'foo'>"
 assert b"<%a>" % "\u1234" == b"<'\\u1234'>"
+assert b"<%a>" % 3.14 == b"<3.14>"
 
 def test_r_compat_bytes(self):
 assert b"<%r>" % b"test" == b""
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy py3.5: fix test (two errors on the same call, and pypy happens to report the other one now)

2017-02-19 Thread arigo
Author: Armin Rigo 
Branch: py3.5
Changeset: r90193:a4715ec68be8
Date: 2017-02-19 10:25 +0100
http://bitbucket.org/pypy/pypy/changeset/a4715ec68be8/

Log:fix test (two errors on the same call, and pypy happens to report
the other one now)

diff --git a/lib-python/3/test/test_struct.py b/lib-python/3/test/test_struct.py
--- a/lib-python/3/test/test_struct.py
+++ b/lib-python/3/test/test_struct.py
@@ -542,7 +542,7 @@
 
 # format lists containing only count spec should result in an error
 self.assertRaises(struct.error, struct.pack, '12345')
-self.assertRaises(struct.error, struct.unpack, '12345', '')
+self.assertRaises(struct.error, struct.unpack, '12345', b'')
 self.assertRaises(struct.error, struct.pack_into, '12345', store, 0)
 self.assertRaises(struct.error, struct.unpack_from, '12345', store, 0)
 
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy py3.5: typo

2017-02-19 Thread arigo
Author: Armin Rigo 
Branch: py3.5
Changeset: r90192:56a8ffad3837
Date: 2017-02-19 10:23 +0100
http://bitbucket.org/pypy/pypy/changeset/56a8ffad3837/

Log:typo

diff --git a/pypy/interpreter/baseobjspace.py b/pypy/interpreter/baseobjspace.py
--- a/pypy/interpreter/baseobjspace.py
+++ b/pypy/interpreter/baseobjspace.py
@@ -1507,7 +1507,7 @@
 if self.is_none(w_obj):
 e = oefmt(self.w_TypeError, "a %s is required, not None", expected)
 else:
-e = oefmt(self.w_TypeError, "a %s is requried, not %T", expected, 
w_obj)
+e = oefmt(self.w_TypeError, "a %s is required, not %T", expected, 
w_obj)
 raise e
 
 @specialize.arg(1)
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: fix, shown randomly in some tests

2017-02-19 Thread arigo
Author: Armin Rigo 
Branch: 
Changeset: r90190:2372b8d38e72
Date: 2017-02-19 10:22 +0100
http://bitbucket.org/pypy/pypy/changeset/2372b8d38e72/

Log:fix, shown randomly in some tests

diff --git a/rpython/rlib/runicode.py b/rpython/rlib/runicode.py
--- a/rpython/rlib/runicode.py
+++ b/rpython/rlib/runicode.py
@@ -139,12 +139,12 @@
 # NB. a bit messy because rtyper/rstr.py also calls the same
 # function.  Make sure we annotate for the args it passes, too
 if NonConstant(False):
-s = '?'
-size = 12345
-errors = 'strict'
-final = True
+s = NonConstant('?')
+size = NonConstant(12345)
+errors = NonConstant('strict')
+final = NonConstant(True)
 errorhandler = default_unicode_error_decode
-allow_surrogates = False
+allow_surrogates = NonConstant(False)
 return str_decode_utf_8_elidable(s, size, errors, final, errorhandler,
  allow_surrogates=allow_surrogates)
 
@@ -356,11 +356,11 @@
 # NB. a bit messy because rtyper/rstr.py also calls the same
 # function.  Make sure we annotate for the args it passes, too
 if NonConstant(False):
-s = u'?'
-size = 12345
-errors = 'strict'
+s = NonConstant(u'?')
+size = NonConstant(12345)
+errors = NonConstant('strict')
 errorhandler = default_unicode_error_encode
-allow_surrogates = False
+allow_surrogates = NonConstant(False)
 return unicode_encode_utf_8_elidable(s, size, errors, errorhandler,
  allow_surrogates=allow_surrogates)
 
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy py3.5: hg merge default

2017-02-19 Thread arigo
Author: Armin Rigo 
Branch: py3.5
Changeset: r90191:072710fa60a3
Date: 2017-02-19 10:22 +0100
http://bitbucket.org/pypy/pypy/changeset/072710fa60a3/

Log:hg merge default

diff --git a/rpython/rlib/runicode.py b/rpython/rlib/runicode.py
--- a/rpython/rlib/runicode.py
+++ b/rpython/rlib/runicode.py
@@ -139,12 +139,12 @@
 # NB. a bit messy because rtyper/rstr.py also calls the same
 # function.  Make sure we annotate for the args it passes, too
 if NonConstant(False):
-s = '?'
-size = 12345
-errors = 'strict'
-final = True
+s = NonConstant('?')
+size = NonConstant(12345)
+errors = NonConstant('strict')
+final = NonConstant(True)
 errorhandler = default_unicode_error_decode
-allow_surrogates = False
+allow_surrogates = NonConstant(False)
 return str_decode_utf_8_elidable(s, size, errors, final, errorhandler,
  allow_surrogates=allow_surrogates)
 
@@ -356,11 +356,11 @@
 # NB. a bit messy because rtyper/rstr.py also calls the same
 # function.  Make sure we annotate for the args it passes, too
 if NonConstant(False):
-s = u'?'
-size = 12345
-errors = 'strict'
+s = NonConstant(u'?')
+size = NonConstant(12345)
+errors = NonConstant('strict')
 errorhandler = default_unicode_error_encode
-allow_surrogates = False
+allow_surrogates = NonConstant(False)
 return unicode_encode_utf_8_elidable(s, size, errors, errorhandler,
  allow_surrogates=allow_surrogates)
 
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy py3.5: hg merge default

2017-02-19 Thread arigo
Author: Armin Rigo 
Branch: py3.5
Changeset: r90189:50d92acc1afa
Date: 2017-02-19 10:04 +0100
http://bitbucket.org/pypy/pypy/changeset/50d92acc1afa/

Log:hg merge default

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
@@ -151,3 +151,11 @@
 it is the standard ``OrderedDict.move_to_end()`` method, but the
 behavior is also available on Python 2.x or for the ``dict`` type by
 calling ``__pypy__.move_to_end(dict, key, last=True)``.
+
+.. branch: space-newtext
+
+Internal refactoring of ``space.wrap()``, which is now replaced with
+explicitly-typed methods.  Notably, there are now ``space.newbytes()``
+and ``space.newtext()``: these two methods are identical on PyPy 2.7 but
+not on PyPy 3.x.  The latter is used to get an app-level unicode string
+by decoding the RPython string, assumed to be utf-8.
diff --git a/pypy/module/_cffi_backend/ffi_obj.py 
b/pypy/module/_cffi_backend/ffi_obj.py
--- a/pypy/module/_cffi_backend/ffi_obj.py
+++ b/pypy/module/_cffi_backend/ffi_obj.py
@@ -174,7 +174,7 @@
 m1, s12, m2, s23, m3, w_x)
 
 
-@unwrap_spec(module_name='text', _version=int, _types='text')
+@unwrap_spec(module_name='text', _version=int, _types='bytes')
 def descr_init(self, module_name='?', _version=-1, _types='',
w__globals=None, w__struct_unions=None, w__enums=None,
w__typenames=None, w__includes=None):
diff --git a/rpython/rlib/test/test_rposix.py b/rpython/rlib/test/test_rposix.py
--- a/rpython/rlib/test/test_rposix.py
+++ b/rpython/rlib/test/test_rposix.py
@@ -492,7 +492,7 @@
 
 class TestPosixAscii(BasePosixUnicodeOrAscii):
 def _get_filename(self):
-return str(udir.join('test_open_ascii'))
+return unicode(udir.join('test_open_ascii'))
 
 @rposix_requires('openat')
 def test_openat(self):
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: fix

2017-02-19 Thread arigo
Author: Armin Rigo 
Branch: 
Changeset: r90188:c6bc044c5f15
Date: 2017-02-19 10:04 +0100
http://bitbucket.org/pypy/pypy/changeset/c6bc044c5f15/

Log:fix

diff --git a/pypy/module/_cffi_backend/ffi_obj.py 
b/pypy/module/_cffi_backend/ffi_obj.py
--- a/pypy/module/_cffi_backend/ffi_obj.py
+++ b/pypy/module/_cffi_backend/ffi_obj.py
@@ -174,7 +174,7 @@
 m1, s12, m2, s23, m3, w_x)
 
 
-@unwrap_spec(module_name='text', _version=int, _types='text')
+@unwrap_spec(module_name='text', _version=int, _types='bytes')
 def descr_init(self, module_name='?', _version=-1, _types='',
w__globals=None, w__struct_unions=None, w__enums=None,
w__typenames=None, w__includes=None):
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: document branch

2017-02-19 Thread arigo
Author: Armin Rigo 
Branch: 
Changeset: r90187:9638991ff70e
Date: 2017-02-19 10:01 +0100
http://bitbucket.org/pypy/pypy/changeset/9638991ff70e/

Log:document branch

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
@@ -142,3 +142,11 @@
 it is the standard ``OrderedDict.move_to_end()`` method, but the
 behavior is also available on Python 2.x or for the ``dict`` type by
 calling ``__pypy__.move_to_end(dict, key, last=True)``.
+
+.. branch: space-newtext
+
+Internal refactoring of ``space.wrap()``, which is now replaced with
+explicitly-typed methods.  Notably, there are now ``space.newbytes()``
+and ``space.newtext()``: these two methods are identical on PyPy 2.7 but
+not on PyPy 3.x.  The latter is used to get an app-level unicode string
+by decoding the RPython string, assumed to be utf-8.
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: fix tests

2017-02-19 Thread arigo
Author: Armin Rigo 
Branch: 
Changeset: r90186:56d384d17f52
Date: 2017-02-19 09:55 +0100
http://bitbucket.org/pypy/pypy/changeset/56d384d17f52/

Log:fix tests

diff --git a/rpython/rlib/test/test_rposix.py b/rpython/rlib/test/test_rposix.py
--- a/rpython/rlib/test/test_rposix.py
+++ b/rpython/rlib/test/test_rposix.py
@@ -492,7 +492,7 @@
 
 class TestPosixAscii(BasePosixUnicodeOrAscii):
 def _get_filename(self):
-return str(udir.join('test_open_ascii'))
+return unicode(udir.join('test_open_ascii'))
 
 @rposix_requires('openat')
 def test_openat(self):
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit