Author: Armin Rigo <[email protected]>
Branch: 
Changeset: r92740:926092bd058d
Date: 2017-10-12 18:31 +0200
http://bitbucket.org/pypy/pypy/changeset/926092bd058d/

Log:    Simplification (and speed-up)

diff --git a/pypy/module/_codecs/interp_codecs.py 
b/pypy/module/_codecs/interp_codecs.py
--- a/pypy/module/_codecs/interp_codecs.py
+++ b/pypy/module/_codecs/interp_codecs.py
@@ -66,20 +66,17 @@
                             "position %d from error handler out of bounds",
                             newpos)
             replace = space.unicode_w(w_replace)
-            return replace, newpos
+            if decode:
+                return replace, newpos
+            else:
+                return replace, None, newpos
         return call_errorhandler
 
     def make_decode_errorhandler(self, space):
         return self._make_errorhandler(space, True)
 
     def make_encode_errorhandler(self, space):
-        errorhandler = self._make_errorhandler(space, False)
-        def encode_call_errorhandler(errors, encoding, reason, input, startpos,
-                                     endpos):
-            replace, newpos = errorhandler(errors, encoding, reason, input,
-                                           startpos, endpos)
-            return replace, None, newpos
-        return encode_call_errorhandler
+        return self._make_errorhandler(space, False)
 
     def get_unicodedata_handler(self, space):
         if self.unicodedata_handler:
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to