[pypy-svn] r16924 - pypy/release/0.7.x/pypy/module/_codecs

ale at codespeak.net ale at codespeak.net
Sun Aug 28 10:27:39 CEST 2005


Author: ale
Date: Sun Aug 28 10:27:38 2005
New Revision: 16924

Modified:
   pypy/release/0.7.x/pypy/module/_codecs/app_codecs.py
Log:
Fixing a couple of bugs in unicode-escape encode of named unicode chars

A unsafe check of end of string

Forgot to raise exceptions if the encoding from succeeding

Modified: pypy/release/0.7.x/pypy/module/_codecs/app_codecs.py
==============================================================================
--- pypy/release/0.7.x/pypy/module/_codecs/app_codecs.py	(original)
+++ pypy/release/0.7.x/pypy/module/_codecs/app_codecs.py	Sun Aug 28 10:27:38 2005
@@ -1480,15 +1480,15 @@
             elif ch == 'N':
                 message = "malformed \\N character escape"
                 #pos += 1
+                look = pos
                 try:
                     import unicodedata
                 except ImportError:
                     message = "\\N escapes not supported (can't load unicodedata module)"
                     unicode_call_errorhandler(errors,"unicodeescape",message,s,pos-1,size)
-                if (s[pos] == '{'):
-                    look = pos+1
+                if (s[look] == '{'):
                     #/* look for the closing brace */
-                    while (s[look] != '}' and look < size):
+                    while (look < size and s[look] != '}'):
                         look += 1
                     if (look > pos+1 and look < size and s[look] == '}'):
                         #/* found a name.  look it up in the unicode database */
@@ -1503,6 +1503,10 @@
                             x = hexescape(s,pos+1,look-pos,message,errors)
                         p += x[0]
                         pos = x[1]
+                    else:        
+                        x=unicode_call_errorhandler(errors,"unicodeescape",message,s,pos-1,look)
+                else:        
+                    x=unicode_call_errorhandler(errors,"unicodeescape",message,s,pos-1,look)
             else:
                 if (pos > size):
                     message = "\\ at end of string"



More information about the Pypy-commit mailing list