Author: Ronan Lamy <ronan.l...@gmail.com> Branch: Changeset: r76603:6274aea11083 Date: 2015-03-27 19:56 +0000 http://bitbucket.org/pypy/pypy/changeset/6274aea11083/
Log: Prevent Repr from ever appearing in a calldesc diff --git a/rpython/annotator/description.py b/rpython/annotator/description.py --- a/rpython/annotator/description.py +++ b/rpython/annotator/description.py @@ -404,6 +404,8 @@ name=None, basedesc=None, classdict=None, specialize=None): super(ClassDesc, self).__init__(bookkeeper, cls) + if '__NOT_RPYTHON__' in cls.__dict__: + raise AnnotatorError('Bad class') if name is None: name = cls.__module__ + '.' + cls.__name__ diff --git a/rpython/rtyper/lltypesystem/rbuilder.py b/rpython/rtyper/lltypesystem/rbuilder.py --- a/rpython/rtyper/lltypesystem/rbuilder.py +++ b/rpython/rtyper/lltypesystem/rbuilder.py @@ -401,18 +401,6 @@ def empty(self): return nullptr(self.lowleveltype.TO) - @classmethod - def ll_new(cls, init_size): - # Clamp 'init_size' to be a value between 0 and 1280. - # Negative values are mapped to 1280. - init_size = intmask(min(r_uint(init_size), r_uint(1280))) - ll_builder = lltype.malloc(cls.lowleveltype.TO) - ll_builder.current_buf = ll_builder.mallocfn(init_size) - ll_builder.current_pos = 0 - ll_builder.current_end = init_size - ll_builder.total_size = init_size - return ll_builder - ll_append = staticmethod(ll_append) ll_append_char = staticmethod(ll_append_char) ll_append_slice = staticmethod(ll_append_slice) @@ -431,6 +419,19 @@ lltype.Ptr(lltype.Array(lltype.Char, hints={'nolength': True})) ) + @staticmethod + def ll_new(init_size): + # Clamp 'init_size' to be a value between 0 and 1280. + # Negative values are mapped to 1280. + init_size = intmask(min(r_uint(init_size), r_uint(1280))) + ll_builder = lltype.malloc(STRINGBUILDER) + ll_builder.current_buf = ll_builder.mallocfn(init_size) + ll_builder.current_pos = 0 + ll_builder.current_end = init_size + ll_builder.total_size = init_size + return ll_builder + + class UnicodeBuilderRepr(BaseStringBuilderRepr): lowleveltype = lltype.Ptr(UNICODEBUILDER) basetp = UNICODE @@ -440,5 +441,18 @@ lltype.Ptr(lltype.Array(lltype.UniChar, hints={'nolength': True})) ) + @staticmethod + def ll_new(init_size): + # Clamp 'init_size' to be a value between 0 and 1280. + # Negative values are mapped to 1280. + init_size = intmask(min(r_uint(init_size), r_uint(1280))) + ll_builder = lltype.malloc(UNICODEBUILDER) + ll_builder.current_buf = ll_builder.mallocfn(init_size) + ll_builder.current_pos = 0 + ll_builder.current_end = init_size + ll_builder.total_size = init_size + return ll_builder + + unicodebuilder_repr = UnicodeBuilderRepr() stringbuilder_repr = StringBuilderRepr() diff --git a/rpython/rtyper/rmodel.py b/rpython/rtyper/rmodel.py --- a/rpython/rtyper/rmodel.py +++ b/rpython/rtyper/rmodel.py @@ -25,6 +25,7 @@ """ __metaclass__ = extendabletype _initialized = setupstate.NOTINITIALIZED + __NOT_RPYTHON__ = True def __repr__(self): return '<%s %s>' % (self.__class__.__name__, self.lowleveltype) _______________________________________________ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit