[pypy-svn] r61242 - in pypy/trunk: lib-python pypy/module/_codecs pypy/module/_codecs/test

antocuni at codespeak.net antocuni at codespeak.net
Thu Jan 22 16:07:41 CET 2009


Author: antocuni
Date: Thu Jan 22 16:07:41 2009
New Revision: 61242

Modified:
   pypy/trunk/lib-python/failure_list.txt
   pypy/trunk/pypy/module/_codecs/app_codecs.py
   pypy/trunk/pypy/module/_codecs/test/test_codecs.py
Log:
fix the 'start' attribute of this kind of UnicodeDecodeError. This bad
behaviour triggered a failure in lib-python/test_codecs



Modified: pypy/trunk/lib-python/failure_list.txt
==============================================================================
--- pypy/trunk/lib-python/failure_list.txt	(original)
+++ pypy/trunk/lib-python/failure_list.txt	Thu Jan 22 16:07:41 2009
@@ -3,8 +3,8 @@
 test_builtin                     this is our issue383
 test_cProfile                !   we still need to fix module/cProfile to respect builtin calls
 test_code                        obscure differences in code objects produced by compiler
-test_codecs                  !   unknown
-test_coding                  !   hah.  fix buildbot :-/
+test_codecs                  !   unknown  # SHOULD BE FIXED NOW
+test_coding                  !   hah.  fix buildbot :-/  # SHOULD BE FIXED NOW
 test_compiler                !   unknown
 test_ctypes                  !   implementation details but also some real crashes
 test_decimal                     missing decimal.ROUND_05UP

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	Thu Jan 22 16:07:41 2009
@@ -373,7 +373,6 @@
 
 def PyUnicode_DecodeUTF7(s, size, errors):
     from _codecs import lookup_error
-    starts = s
     errmsg = ""
     inShift = 0
     bitsleft = 0
@@ -464,10 +463,9 @@
             i += 1
 
     if (inShift) :
-        #XXX This aint right
         endinpos = size
         msg = "unterminated shift sequence"
-        out, i = unicode_call_errorhandler(errors, 'utf-7', msg, s, i-1, i)
+        out, i = unicode_call_errorhandler(errors, 'utf-7', msg, s, startinpos, i)
         p += out
     return p
 

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	Thu Jan 22 16:07:41 2009
@@ -499,6 +499,13 @@
     def test_charmap_decode(self):
         assert 'foo'.decode('charmap') == 'foo'
 
+    def test_utf7_start_end_in_exception(self):
+        try:
+            '+IC'.decode('utf-7')
+        except UnicodeDecodeError, exc:
+            assert exc.start == 0
+            assert exc.end == 3
+
 class TestDirect:
     def test_charmap_encode(self):
         from pypy.module._codecs.app_codecs import charmap_encode



More information about the Pypy-commit mailing list