Author: Alex Gaynor <alex.gay...@gmail.com> Branch: kill-someobject Changeset: r57824:93067e51258a Date: 2012-10-07 17:49 +0200 http://bitbucket.org/pypy/pypy/changeset/93067e51258a/
Log: (alex, fijal) kill nonsense diff --git a/pypy/annotation/bookkeeper.py b/pypy/annotation/bookkeeper.py --- a/pypy/annotation/bookkeeper.py +++ b/pypy/annotation/bookkeeper.py @@ -167,9 +167,6 @@ self.stats = Stats(self) - # used in SomeObject.__new__ for keeping debugging info - self._isomeobject_coming_from = identity_dict() - delayed_imports() def count(self, category, *args): @@ -477,11 +474,11 @@ elif x is None: return s_None else: - result = SomeObject() + raise Exception("Don't know how to represent %r" % (x,)) if need_const: result.const = x return result - + def getdesc(self, pyobj): # get the XxxDesc wrapper for the given Python object, which must be # one of: diff --git a/pypy/annotation/description.py b/pypy/annotation/description.py --- a/pypy/annotation/description.py +++ b/pypy/annotation/description.py @@ -247,13 +247,16 @@ defs_s = [] if graph is None: signature = self.signature - defaults = self.defaults + defaults = self.defaults else: signature = graph.signature - defaults = graph.defaults + defaults = graph.defaults if defaults: for x in defaults: - defs_s.append(self.bookkeeper.immutablevalue(x)) + if x is NODEFAULT: + defs_s.append(None) + else: + defs_s.append(self.bookkeeper.immutablevalue(x)) try: inputcells = args.match_signature(signature, defs_s) except ArgErr, e: diff --git a/pypy/objspace/flow/model.py b/pypy/objspace/flow/model.py --- a/pypy/objspace/flow/model.py +++ b/pypy/objspace/flow/model.py @@ -5,7 +5,6 @@ # a discussion in Berlin, 4th of october 2003 import py from pypy.tool.uid import uid, Hashable -from pypy.tool.descriptor import roproperty from pypy.tool.sourcetools import PY_IDENTIFIER, nice_repr_for_func from pypy.rlib.rarithmetic import is_valid_int, r_longlong, r_ulonglong, r_uint @@ -34,8 +33,6 @@ class FunctionGraph(object): - __slots__ = ['startblock', 'returnblock', 'exceptblock', '__dict__'] - def __init__(self, name, startblock, return_var=None): self.name = name # function name (possibly mangled already) self.startblock = startblock @@ -56,23 +53,23 @@ def getreturnvar(self): return self.returnblock.inputargs[0] - def getsource(self): + @property + def source(self): from pypy.tool.sourcetools import getsource func = self.func # can raise AttributeError src = getsource(self.func) if src is None: raise AttributeError('source not found') return src - source = roproperty(getsource) - - def getstartline(self): + + @property + def startline(self): return self.func.func_code.co_firstlineno - startline = roproperty(getstartline) - - def getfilename(self): + + @property + def filename(self): return self.func.func_code.co_filename - filename = roproperty(getfilename) - + def __str__(self): if hasattr(self, 'func'): return nice_repr_for_func(self.func, self.name) diff --git a/pypy/rpython/lltypesystem/lloperation.py b/pypy/rpython/lltypesystem/lloperation.py --- a/pypy/rpython/lltypesystem/lloperation.py +++ b/pypy/rpython/lltypesystem/lloperation.py @@ -3,7 +3,6 @@ """ from pypy.rpython.extregistry import ExtRegistryEntry -from pypy.tool.descriptor import roproperty class LLOp(object): @@ -65,7 +64,10 @@ val = lltype.enforce(RESULTTYPE, val) return val - def get_fold_impl(self): + @property + def fold(self): + if hasattr(self, "_fold"): + return self._fold global lltype # <- lazy import hack, worth an XXX from pypy.rpython.lltypesystem import lltype if self.canrun: @@ -80,9 +82,8 @@ def op_impl(*args): raise error # cache the implementation function into 'self' - self.fold = op_impl + self._fold = op_impl return op_impl - fold = roproperty(get_fold_impl) def is_pure(self, args_v): if self.canfold: # canfold => pure operation diff --git a/pypy/rpython/normalizecalls.py b/pypy/rpython/normalizecalls.py --- a/pypy/rpython/normalizecalls.py +++ b/pypy/rpython/normalizecalls.py @@ -12,6 +12,7 @@ from pypy.rlib.objectmodel import instantiate, ComputedIntSymbolic from pypy.interpreter.argument import Signature + def normalize_call_familes(annotator): for callfamily in annotator.bookkeeper.pbc_maximal_call_families.infos(): if not callfamily.modified: @@ -105,7 +106,6 @@ call_nbargs = shape_cnt + len(shape_keys) did_something = False - NODEFAULT = object() for graph in graphs: argnames, varargname, kwargname = graph.signature @@ -123,7 +123,7 @@ inlist = [] defaults = graph.defaults or () num_nondefaults = len(inputargs_s) - len(defaults) - defaults = [NODEFAULT] * num_nondefaults + list(defaults) + defaults = [description.NODEFAULT] * num_nondefaults + list(defaults) newdefaults = [] for j in argorder: v = Variable(graph.getargs()[j]) @@ -141,7 +141,7 @@ v = inlist[i] except ValueError: default = defaults[j] - if default is NODEFAULT: + if default is description.NODEFAULT: raise TyperError( "call pattern has %d positional arguments, " "but %r takes at least %d arguments" % ( @@ -151,7 +151,7 @@ newblock.closeblock(Link(outlist, oldblock)) graph.startblock = newblock for i in range(len(newdefaults)-1,-1,-1): - if newdefaults[i] is NODEFAULT: + if newdefaults[i] is description.NODEFAULT: newdefaults = newdefaults[i:] break graph.defaults = tuple(newdefaults) diff --git a/pypy/tool/descriptor.py b/pypy/tool/descriptor.py --- a/pypy/tool/descriptor.py +++ b/pypy/tool/descriptor.py @@ -1,14 +1,3 @@ - -class roproperty(object): - def __init__(self, getter): - self.getter = getter - def __get__(self, obj, cls=None): - if obj is None: - return self - else: - return self.getter(obj) - - class InstanceMethod(object): "Like types.InstanceMethod, but with a reasonable (structural) equality." _______________________________________________ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit