Author: Matti Picus <[email protected]>
Branch: unicode-utf8-py3
Changeset: r95310:89c980f7f54b
Date: 2018-11-13 00:18 -0800
http://bitbucket.org/pypy/pypy/changeset/89c980f7f54b/

Log:    test, fix wcharp2utf8n for lastchr != 0

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
@@ -1046,7 +1046,7 @@
 
     s = rutf8.Utf8StringBuilder(maxlen)
     i = 0
-    while i < maxlen and w[i]:
+    while i < maxlen and w[i] != '\x00':
         s.append_code(ord(w[i]))
         i += 1
     return s.build(), i
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
@@ -916,3 +916,8 @@
         assert buf[1] == 'a'
         assert buf[2] == 'r'
         assert buf[3] == '\x00'
+
+def test_wcharp2utf8n():
+    w = 'hello\x00\x00\x00\x00'
+    u, i = wcharp2utf8n(w, len(w))
+    assert i == len('hello')
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to