Author: Antonio Cuni <anto.c...@gmail.com> Branch: Changeset: r57059:5ca4f666e0ee Date: 2012-08-31 16:24 +0200 http://bitbucket.org/pypy/pypy/changeset/5ca4f666e0ee/
Log: delay the import of rlib.runicode as much as possible, else we get circular imports 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 pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit