[pypy-svn] r75732 - in pypy/branch/interplevel-codecs/pypy: module/_codecs/test rlib

afa at codespeak.net afa at codespeak.net
Thu Jul 1 20:13:29 CEST 2010


Author: afa
Date: Thu Jul  1 20:13:26 2010
New Revision: 75732

Modified:
   pypy/branch/interplevel-codecs/pypy/module/_codecs/test/test_codecs.py
   pypy/branch/interplevel-codecs/pypy/rlib/runicode.py
Log:
Never use raise_unicode_exception_encode when called from the codecs module,
otherwise a RPython UnicodeError is raised, and crashes the intepreter.


Modified: pypy/branch/interplevel-codecs/pypy/module/_codecs/test/test_codecs.py
==============================================================================
--- pypy/branch/interplevel-codecs/pypy/module/_codecs/test/test_codecs.py	(original)
+++ pypy/branch/interplevel-codecs/pypy/module/_codecs/test/test_codecs.py	Thu Jul  1 20:13:26 2010
@@ -531,6 +531,7 @@
 
         import codecs
         raises(TypeError, codecs.charmap_encode, u'\xff', "replace",  {0xff: 300})
+        raises(UnicodeError, codecs.charmap_encode, u"\xff", "replace", {0xff: None})
 
     def test_charmap_encode_replace(self):
         charmap = dict([ (ord(c), 2*c.upper()) for c in "abcdefgh"])

Modified: pypy/branch/interplevel-codecs/pypy/rlib/runicode.py
==============================================================================
--- pypy/branch/interplevel-codecs/pypy/rlib/runicode.py	(original)
+++ pypy/branch/interplevel-codecs/pypy/rlib/runicode.py	Thu Jul  1 20:13:26 2010
@@ -785,8 +785,8 @@
             for ch2 in res:
                 c2 = mapping.get(unichr(ord(ch2)), '')
                 if len(c2) == 0:
-                    raise_unicode_exception_encode(
-                        errors, "charmap",
+                    errorhandler(
+                        "strict", "charmap",
                         "character maps to <undefined>",
                         s,  pos, pos + 1)
                 result.append(c2)



More information about the Pypy-commit mailing list