[pypy-svn] r61376 - in pypy/trunk/pypy/module/_codecs: . test

fijal at codespeak.net fijal at codespeak.net
Mon Jan 26 20:48:22 CET 2009


Author: fijal
Date: Mon Jan 26 20:48:21 2009
New Revision: 61376

Modified:
   pypy/trunk/pypy/module/_codecs/app_codecs.py
   pypy/trunk/pypy/module/_codecs/test/test_codecs.py
Log:
* one if which I have really no clue how should look like, tests don't care
  either
* a fix. the funny thing is that it used to work by accident.


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	Mon Jan 26 20:48:21 2009
@@ -564,7 +564,7 @@
             pos -= 1
             
         #/* Map 16-bit characters to '\uxxxx' */
-        elif (ord(ch) >= 256):
+        if (ord(ch) >= 256):
             p += '\\'
             p += 'u'
             p += '%04x' % ord(ch)
@@ -581,6 +581,8 @@
         elif (ch == '\r'):
             p += '\\'
             p += 'r'
+        elif ch == '\\':
+            p += '\\\\'
 
         #/* Map non-printable US ASCII to '\xhh' */
         elif (ch < ' ' or ord(ch) >= 0x7F) :

Modified: pypy/trunk/pypy/module/_codecs/test/test_codecs.py
==============================================================================
--- pypy/trunk/pypy/module/_codecs/test/test_codecs.py	(original)
+++ pypy/trunk/pypy/module/_codecs/test/test_codecs.py	Mon Jan 26 20:48:21 2009
@@ -528,3 +528,6 @@
         assert unicode_escape_encode(u'abc') == (u'abc'.encode('unicode_escape'), 3)
         assert unicode_escape_decode('abc') == (u'abc'.decode('unicode_escape'), 3)
         assert unicode_escape_decode('\\x61\\x62\\x63') == (u'abc', 12)
+
+        assert u'\\'.encode('unicode-escape') == '\\\\'
+        assert '\\\\'.decode('unicode-escape') == u'\\'



More information about the Pypy-commit mailing list