[pypy-commit] pypy utf8-unicode2: Fix mismatch between translated and untranslated behavior

waedt noreply at buildbot.pypy.org
Sat Aug 9 08:46:58 CEST 2014


Author: Tyler Wade <wayedt at gmail.com>
Branch: utf8-unicode2
Changeset: r72723:d124ea9a7f3a
Date: 2014-08-09 00:37 -0500
http://bitbucket.org/pypy/pypy/changeset/d124ea9a7f3a/

Log:	Fix mismatch between translated and untranslated behavior

diff --git a/pypy/interpreter/utf8.py b/pypy/interpreter/utf8.py
--- a/pypy/interpreter/utf8.py
+++ b/pypy/interpreter/utf8.py
@@ -229,6 +229,10 @@
         assert self._len >= 0
         return self._len
 
+    def __bool__(self):
+        # XXX Make the untranslated behavior the same as the translated behavior
+        raise True
+
     def __hash__(self):
         return compute_hash(self.bytes)
 
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
@@ -372,9 +372,10 @@
             newline = None
         else:
             newline = space.unicode_w(w_newline)
-        if newline and not (utf8.EQ(newline, Utf8Str('\n')) or
-            utf8.EQ(newline, Utf8Str('\r\n')) or
-            utf8.EQ(newline, Utf8Str('\r'))):
+        if (newline is not None and len(newline) > 0 and
+            not (utf8.EQ(newline, Utf8Str('\n')) or
+                 utf8.EQ(newline, Utf8Str('\r\n')) or
+                 utf8.EQ(newline, Utf8Str('\r')))):
             r = space.str_w(space.repr(w_newline))
             raise OperationError(space.w_ValueError, space.wrap(
                 "illegal newline value: %s" % (r,)))


More information about the pypy-commit mailing list