[pypy-svn] r59024 - in pypy/trunk/pypy: module/_codecs objspace/std/test

antocuni at codespeak.net antocuni at codespeak.net
Sun Oct 12 14:28:17 CEST 2008


Author: antocuni
Date: Sun Oct 12 14:28:16 2008
New Revision: 59024

Modified:
   pypy/trunk/pypy/module/_codecs/app_codecs.py
   pypy/trunk/pypy/objspace/std/test/test_unicodeobject.py
Log:
(antocuni, iko)

fix a bug introduced when converting PyUnicode_DecodeRawUnicodeEscape from C
to Python



Modified: pypy/trunk/pypy/module/_codecs/app_codecs.py
==============================================================================
--- pypy/trunk/pypy/module/_codecs/app_codecs.py	(original)
+++ pypy/trunk/pypy/module/_codecs/app_codecs.py	Sun Oct 12 14:28:16 2008
@@ -892,6 +892,10 @@
                 break
             p += unichr(ord(s[pos]))
             pos += 1
+
+        # we have a backlash at the end of the string, stop here
+        if pos >= size:
+            break
     
         if (((pos - bs) & 1) == 0 or
             pos >= size or

Modified: pypy/trunk/pypy/objspace/std/test/test_unicodeobject.py
==============================================================================
--- pypy/trunk/pypy/objspace/std/test/test_unicodeobject.py	(original)
+++ pypy/trunk/pypy/objspace/std/test/test_unicodeobject.py	Sun Oct 12 14:28:16 2008
@@ -659,3 +659,7 @@
     def test_no_len_on_str_iter(self):
         iterable = u"hello"
         raises(TypeError, len, iter(iterable))
+
+    def test_encode_raw_unicode_escape(self):
+        u = unicode('\\', 'raw_unicode_escape')
+        assert u == u'\\'



More information about the Pypy-commit mailing list