Author: Antonio Cuni <[email protected]>
Branch: py3k
Changeset: r57060:d89b115a2f10
Date: 2012-08-31 16:25 +0200
http://bitbucket.org/pypy/pypy/changeset/d89b115a2f10/

Log:    hg merge default

diff --git a/pypy/rpython/rstr.py b/pypy/rpython/rstr.py
--- a/pypy/rpython/rstr.py
+++ b/pypy/rpython/rstr.py
@@ -15,8 +15,11 @@
 class AbstractStringRepr(Repr):
 
     def __init__(self, *args):
+        Repr.__init__(self, *args)
+        self.rstr_decode_utf_8 = None
+
+    def ensure_ll_decode_utf8(self):
         from pypy.rlib.runicode import str_decode_utf_8, 
raise_unicode_exception_decode
-        Repr.__init__(self, *args)
         self.rstr_decode_utf_8 = func_with_new_name(str_decode_utf_8,
                                                     'rstr_decode_utf_8')
 
@@ -37,8 +40,11 @@
 class AbstractUnicodeRepr(AbstractStringRepr):
 
     def __init__(self, *args):
+        AbstractStringRepr.__init__(self, *args)
+        self.runicode_encode_utf_8 = None
+
+    def ensure_ll_encode_utf8(self):
         from pypy.rlib.runicode import unicode_encode_utf_8
-        AbstractStringRepr.__init__(self, *args)
         self.runicode_encode_utf_8 = func_with_new_name(unicode_encode_utf_8,
                                                         
'runicode_encode_utf_8')
 
@@ -341,6 +347,7 @@
         elif encoding == 'latin-1':
             return hop.gendirectcall(self.ll_decode_latin1, v_self)
         elif encoding == 'utf-8':
+            self.ensure_ll_decode_utf8()
             return hop.gendirectcall(self.ll_decode_utf8, v_self)
         else:
             raise TyperError("encoding %s not implemented" % (encoding, ))
@@ -374,6 +381,7 @@
         elif encoding == "latin-1":
             return hop.gendirectcall(self.ll_encode_latin1, v_self)
         elif encoding == 'utf-8':
+            self.ensure_ll_encode_utf8()
             return hop.gendirectcall(self.ll_encode_utf8, v_self)
         else:
             raise TyperError("encoding %s not implemented" % (encoding, ))
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to