Author: Armin Rigo <[email protected]>
Branch: unicode-utf8
Changeset: r92257:2cc3cf290fbf
Date: 2017-08-24 17:37 +0200
http://bitbucket.org/pypy/pypy/changeset/2cc3cf290fbf/

Log:    (fijal, arigo)

        Hack hack hack

diff --git a/pypy/interpreter/unicodehelper.py 
b/pypy/interpreter/unicodehelper.py
--- a/pypy/interpreter/unicodehelper.py
+++ b/pypy/interpreter/unicodehelper.py
@@ -29,6 +29,10 @@
                                              space.newtext(msg)]))
     return raise_unicode_exception_encode
 
+def convert_arg_to_w_unicode(space, w_arg, strict=None):
+    from pypy.objspace.std.unicodeobject import W_UnicodeObject
+    return W_UnicodeObject.convert_arg_to_w_unicode(space, w_arg, strict)
+
 # ____________________________________________________________
 
 def encode(space, w_data, encoding=None, errors='strict'):
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
@@ -374,16 +374,17 @@
 
 def make_encoder_wrapper(name):
     rname = "utf8_encode_%s" % (name.replace("_encode", ""), )
-    @unwrap_spec(utf8='utf8', errors='text_or_none')
-    def wrap_encoder(space, utf8, errors="strict"):
+    @unwrap_spec(errors='text_or_none')
+    def wrap_encoder(space, w_arg, errors="strict"):
         from pypy.interpreter import unicodehelper
-        XXX
 
+        w_arg = unicodehelper.convert_arg_to_w_unicode(space, w_arg, rname)
         if errors is None:
             errors = 'strict'
         state = space.fromcache(CodecState)
         func = getattr(unicodehelper, rname)
-        result = func(utf8, utf8len,
+        utf8len = w_arg._length
+        result = func(w_arg._utf8, utf8len,
             errors, state.encode_error_handler)
         return space.newtuple([space.newbytes(result), space.newint(utf8len)])
     wrap_encoder.func_name = rname
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to