Author: Alex Gaynor <[email protected]>
Branch:
Changeset: r61342:5d31d8fd913b
Date: 2013-02-16 21:12 -0800
http://bitbucket.org/pypy/pypy/changeset/5d31d8fd913b/
Log: remove some dead imports, some PEP8, general cleanups
diff --git a/rpython/rtyper/annlowlevel.py b/rpython/rtyper/annlowlevel.py
--- a/rpython/rtyper/annlowlevel.py
+++ b/rpython/rtyper/annlowlevel.py
@@ -2,18 +2,18 @@
The code needed to flow and annotate low-level helpers -- the ll_*() functions
"""
-import types
-from rpython.tool.sourcetools import valid_identifier
from rpython.annotator import model as annmodel
from rpython.annotator.policy import AnnotatorPolicy, Sig
from rpython.annotator.specialize import flatten_star_args
+from rpython.flowspace.model import Constant
+from rpython.rlib.objectmodel import specialize
+from rpython.rtyper import extregistry
from rpython.rtyper.lltypesystem import lltype
from rpython.rtyper.ootypesystem import ootype
-from rpython.rtyper import extregistry
-from rpython.flowspace.model import Constant
+from rpython.rtyper.rmodel import warning
+from rpython.tool.sourcetools import valid_identifier
from rpython.translator.simplify import get_functype
-from rpython.rtyper.rmodel import warning
-from rpython.rlib.objectmodel import specialize
+
class KeyComp(object):
def __init__(self, val):
@@ -34,7 +34,7 @@
if compact is None:
s = repr(val)
else:
- s = compact()
+ s = compact()
return s + 'Const'
__repr__ = __str__
@@ -90,7 +90,7 @@
args_s[:] = [l2a(a2l(s)) for s in args_s]
return LowLevelAnnotatorPolicy.default_specialize(funcdesc, args_s)
specialize__semierased = staticmethod(specialize__semierased)
-
+
specialize__ll = default_specialize
def specialize__ll_and_arg(funcdesc, args_s, *argindices):
@@ -103,7 +103,7 @@
def annotate_lowlevel_helper(annotator, ll_function, args_s, policy=None):
if policy is None:
- policy= LowLevelAnnotatorPolicy()
+ policy = LowLevelAnnotatorPolicy()
return annotator.annotate_helper(ll_function, args_s, policy)
# ___________________________________________________________________
@@ -380,7 +380,7 @@
else:
FUNC = F.TO
resultcls = annmodel.SomePtr
-
+
args_s = [annmodel.lltype_to_annotation(T) for T in FUNC.ARGS]
key = (llhelper, s_callable.const)
s_res = self.bookkeeper.emulate_pbc_call(key, s_callable, args_s)
@@ -603,7 +603,7 @@
assert s.islower()
def expand(s_self, *args_s):
assert isinstance(s_self, annmodel.SomePtr)
- return getattr(s_self.ll_ptrtype.TO, s.upper())
+ return getattr(s_self.ll_ptrtype.TO, s.upper())
return expand
def typemeth_placeholder_sigarg(s):
@@ -622,10 +622,10 @@
def expand(s_TYPE, *args_s):
assert isinstance(s_TYPE, annmodel.SomePBC)
assert s_TYPE.is_constant()
- return getattr(s_TYPE.const, s.upper())
+ return getattr(s_TYPE.const, s.upper())
return expand
-
+
class ADTInterface(object):
def __init__(self, base, sigtemplates):
diff --git a/rpython/rtyper/exceptiondata.py b/rpython/rtyper/exceptiondata.py
--- a/rpython/rtyper/exceptiondata.py
+++ b/rpython/rtyper/exceptiondata.py
@@ -1,6 +1,6 @@
-from rpython.rtyper import rclass
from rpython.annotator import model as annmodel
from rpython.rlib import rstackovf
+from rpython.rtyper import rclass
# the exceptions that can be implicitely raised by some operations
@@ -38,16 +38,16 @@
r_instance = rclass.getinstancerepr(rtyper, None)
r_type.setup()
r_instance.setup()
- self.r_exception_type = r_type
+ self.r_exception_type = r_type
self.r_exception_value = r_instance
- self.lltype_of_exception_type = r_type.lowleveltype
+ self.lltype_of_exception_type = r_type.lowleveltype
self.lltype_of_exception_value = r_instance.lowleveltype
self.rtyper = rtyper
def make_standard_exceptions(self, rtyper):
bk = rtyper.annotator.bookkeeper
for cls in self.standardexceptions:
- classdef = bk.getuniqueclassdef(cls)
+ bk.getuniqueclassdef(cls)
def finish(self, rtyper):
bk = rtyper.annotator.bookkeeper
diff --git a/rpython/rtyper/llinterp.py b/rpython/rtyper/llinterp.py
--- a/rpython/rtyper/llinterp.py
+++ b/rpython/rtyper/llinterp.py
@@ -1,17 +1,20 @@
-from rpython.flowspace.model import FunctionGraph, Constant, Variable,
c_last_exception
-from rpython.rlib.rarithmetic import intmask, r_uint, ovfcheck, r_longlong,
r_longlonglong
-from rpython.rlib.rarithmetic import r_ulonglong, is_valid_int
-from rpython.rtyper.lltypesystem import lltype, llmemory, lloperation, llheap
-from rpython.rtyper.lltypesystem import rclass
+import cStringIO
+import os
+import sys
+import traceback
+
+import py
+
+from rpython.flowspace.model import (FunctionGraph, Constant, Variable,
+ c_last_exception)
+from rpython.rlib import rstackovf
+from rpython.rlib.objectmodel import (ComputedIntSymbolic, CDefinedIntSymbolic,
+ Symbolic)
+# intmask is used in an exec'd code block
+from rpython.rlib.rarithmetic import ovfcheck, is_valid_int, intmask
+from rpython.rtyper.lltypesystem import lltype, llmemory, lloperation, llheap,
rclass
from rpython.rtyper.ootypesystem import ootype
-from rpython.rlib.objectmodel import ComputedIntSymbolic, CDefinedIntSymbolic
-from rpython.rlib.objectmodel import Symbolic
-from rpython.rlib import rstackovf
-import sys, os
-import math
-import py
-import traceback, cStringIO
log = py.log.Producer('llinterp')
@@ -19,6 +22,7 @@
def __init__(self, *args):
"NOT_RPYTHON"
Exception.__init__(self, *args)
+
def __str__(self):
etype = self.args[0]
#evalue = self.args[1]
@@ -42,7 +46,7 @@
return ''.join(etype.name).rstrip('\x00')
else:
# ootype!
- return etype._INSTANCE._name.split(".")[-1]
+ return etype._INSTANCE._name.split(".")[-1]
class LLInterpreter(object):
""" low level interpreter working with concrete values. """
@@ -336,7 +340,7 @@
evalue = exc_data.exc_value
if tracer:
tracer.dump('raise')
- exc_data.exc_type = lltype.typeOf(etype )._defl()
+ exc_data.exc_type = lltype.typeOf(etype)._defl()
exc_data.exc_value = lltype.typeOf(evalue)._defl()
from rpython.translator import exceptiontransform
T = resultvar.concretetype
@@ -641,7 +645,6 @@
if ITEMTYPE is not lltype.Void:
array[index] = item
-
def perform_call(self, f, ARGS, args):
fobj = self.llinterpreter.typer.type_system.deref(f)
has_callable = getattr(fobj, '_callable', None) is not None
@@ -652,11 +655,11 @@
return self.invoke_callable_with_pyexceptions(f, *args)
args_v = graph.getargs()
if len(ARGS) != len(args_v):
- raise TypeError("graph with %d args called with wrong func ptr
type: %r" %(len(args_v), ARGS))
+ raise TypeError("graph with %d args called with wrong func ptr
type: %r" %(len(args_v), ARGS))
for T, v in zip(ARGS, args_v):
if not lltype.isCompatibleType(T, v.concretetype):
raise TypeError("graph with %r args called with wrong func ptr
type: %r" %
- (tuple([v.concretetype for v in args_v]),
ARGS))
+ (tuple([v.concretetype for v in args_v]),
ARGS))
frame = self.newsubframe(graph, args)
return frame.eval()
@@ -670,7 +673,7 @@
if graphs is not None:
obj = self.llinterpreter.typer.type_system.deref(f)
if hasattr(obj, 'graph'):
- assert obj.graph in graphs
+ assert obj.graph in graphs
else:
pass
#log.warn("op_indirect_call with graphs=None:", f)
@@ -1052,7 +1055,7 @@
if x^y < 0 and x%%y != 0:
r += 1
return r
- '''%locals()
+ ''' % locals()
elif operator == '%':
## overflow check on % does not work with emulated int
code = '''%(checkfn)s(x // y)
@@ -1060,9 +1063,9 @@
if x^y < 0 and x%%y != 0:
r -= y
return r
- '''%locals()
+ ''' % locals()
else:
- code = 'return %(checkfn)s(x %(operator)s y)'%locals()
+ code = 'return %(checkfn)s(x %(operator)s y)' % locals()
exec py.code.Source("""
def %(fn)s(self, x, y):
assert isinstance(x, %(xtype)s)
@@ -1094,7 +1097,7 @@
_makefunc2('op_lllong_floordiv_zer', '//', 'r_longlonglong')
_makefunc2('op_lllong_mod_zer', '%', 'r_longlonglong')
-
+
def op_int_add_nonneg_ovf(self, x, y):
if isinstance(y, int):
assert y >= 0
@@ -1114,9 +1117,9 @@
def op_check_and_clear_exc(self):
exc_data = self.llinterpreter.get_transformed_exc_data(self.graph)
assert exc_data
- etype = exc_data.exc_type
+ etype = exc_data.exc_type
evalue = exc_data.exc_value
- exc_data.exc_type = lltype.typeOf(etype )._defl()
+ exc_data.exc_type = lltype.typeOf(etype)._defl()
exc_data.exc_value = lltype.typeOf(evalue)._defl()
return bool(etype)
@@ -1125,7 +1128,7 @@
def op_new(self, INST):
assert isinstance(INST, (ootype.Instance, ootype.BuiltinType))
return ootype.new(INST)
-
+
def op_oonewarray(self, ARRAY, length):
assert isinstance(ARRAY, ootype.Array)
assert is_valid_int(length)
@@ -1139,7 +1142,7 @@
eq_name, interp_eq = \
wrap_callable(self.llinterpreter, eq_func, eq_obj,
eq_method_name)
EQ_FUNC = ootype.StaticMethod([DICT._KEYTYPE, DICT._KEYTYPE],
ootype.Bool)
- sm_eq = ootype.static_meth(EQ_FUNC, eq_name, _callable=interp_eq)
+ sm_eq = ootype.static_meth(EQ_FUNC, eq_name, _callable=interp_eq)
hash_name, interp_hash = \
wrap_callable(self.llinterpreter, hash_func, hash_obj,
hash_method_name)
diff --git a/rpython/rtyper/raddress.py b/rpython/rtyper/raddress.py
--- a/rpython/rtyper/raddress.py
+++ b/rpython/rtyper/raddress.py
@@ -1,18 +1,18 @@
# rtyping of memory address operations
-from rpython.tool.pairtype import pairtype
from rpython.annotator import model as annmodel
-from rpython.rtyper.lltypesystem.llmemory import NULL, Address, \
- cast_adr_to_int, fakeaddress, sizeof
+from rpython.rlib.rarithmetic import r_uint
+from rpython.rtyper.lltypesystem import lltype
+from rpython.rtyper.lltypesystem.llmemory import (NULL, Address,
+ cast_adr_to_int, fakeaddress, sizeof)
from rpython.rtyper.rmodel import Repr, IntegerRepr
from rpython.rtyper.rptr import PtrRepr
-from rpython.rtyper.lltypesystem import lltype
-from rpython.rlib.rarithmetic import r_uint
+from rpython.tool.pairtype import pairtype
class __extend__(annmodel.SomeAddress):
def rtyper_makerepr(self, rtyper):
return address_repr
-
+
def rtyper_makekey(self):
return self.__class__,
@@ -141,5 +141,3 @@
def convert_from_to((r_ptr, r_addr), v, llops):
return llops.genop('cast_ptr_to_adr', [v], resulttype=Address)
-
-
diff --git a/rpython/rtyper/rbool.py b/rpython/rtyper/rbool.py
--- a/rpython/rtyper/rbool.py
+++ b/rpython/rtyper/rbool.py
@@ -1,14 +1,14 @@
+from rpython.annotator import model as annmodel
+from rpython.rtyper.error import TyperError
+from rpython.rtyper.lltypesystem.lltype import Signed, Unsigned, Bool, Float
+from rpython.rtyper.rmodel import IntegerRepr, BoolRepr, log
from rpython.tool.pairtype import pairtype
-from rpython.annotator import model as annmodel
-from rpython.rtyper.lltypesystem.lltype import Signed, Unsigned, Bool, Float
-from rpython.rtyper.error import TyperError
-from rpython.rtyper.rmodel import IntegerRepr, BoolRepr
-from rpython.rtyper.rmodel import log
class __extend__(annmodel.SomeBool):
def rtyper_makerepr(self, rtyper):
return bool_repr
+
def rtyper_makekey(self):
return self.__class__,
diff --git a/rpython/rtyper/rbuilder.py b/rpython/rtyper/rbuilder.py
--- a/rpython/rtyper/rbuilder.py
+++ b/rpython/rtyper/rbuilder.py
@@ -1,7 +1,7 @@
+from rpython.annotator.model import SomeChar, SomeUnicodeCodePoint
+from rpython.rlib.rstring import INIT_SIZE
+from rpython.rtyper.lltypesystem import lltype
from rpython.rtyper.rmodel import Repr
-from rpython.rtyper.lltypesystem import lltype
-from rpython.rlib.rstring import INIT_SIZE
-from rpython.annotator.model import SomeChar, SomeUnicodeCodePoint
class AbstractStringBuilderRepr(Repr):
diff --git a/rpython/rtyper/rbytearray.py b/rpython/rtyper/rbytearray.py
--- a/rpython/rtyper/rbytearray.py
+++ b/rpython/rtyper/rbytearray.py
@@ -1,9 +1,9 @@
+from rpython.annotator import model as annmodel
+from rpython.rtyper.lltypesystem import lltype
+from rpython.rtyper.rmodel import IntegerRepr
+from rpython.rtyper.rstr import AbstractStringRepr
+from rpython.tool.pairtype import pairtype
-from rpython.annotator import model as annmodel
-from rpython.tool.pairtype import pairtype
-from rpython.rtyper.rstr import AbstractStringRepr
-from rpython.rtyper.rmodel import IntegerRepr
-from rpython.rtyper.lltypesystem import lltype
class AbstractByteArrayRepr(AbstractStringRepr):
pass
diff --git a/rpython/rtyper/rclass.py b/rpython/rtyper/rclass.py
--- a/rpython/rtyper/rclass.py
+++ b/rpython/rtyper/rclass.py
@@ -1,10 +1,9 @@
import types
-from rpython.annotator import model as annmodel
-#from rpython.annotator.classdef import isclassdef
-from rpython.annotator import description
+
+from rpython.annotator import description, model as annmodel
from rpython.rtyper.error import TyperError
+from rpython.rtyper.lltypesystem.lltype import Void
from rpython.rtyper.rmodel import Repr, getgcflavor, inputconst
-from rpython.rtyper.lltypesystem.lltype import Void
class FieldListAccessor(object):
@@ -76,7 +75,7 @@
def buildinstancerepr(rtyper, classdef, gcflavor='gc'):
from rpython.rlib.objectmodel import UnboxedValue
from rpython.flowspace.model import Constant
-
+
if classdef is None:
unboxed = []
virtualizable2 = False
@@ -137,7 +136,7 @@
if self.classdef.commonbase(subclassdef) != self.classdef:
raise TyperError("not a subclass of %r: %r" % (
self.classdef.name, desc))
-
+
r_subclass = getclassrepr(self.rtyper, subclassdef)
return r_subclass.getruntime(self.lowleveltype)
@@ -170,12 +169,14 @@
class __extend__(annmodel.SomeInstance):
def rtyper_makerepr(self, rtyper):
return getinstancerepr(rtyper, self.classdef)
+
def rtyper_makekey(self):
return self.__class__, self.classdef
class __extend__(annmodel.SomeType):
def rtyper_makerepr(self, rtyper):
return get_type_repr(rtyper)
+
def rtyper_makekey(self):
return self.__class__,
@@ -390,8 +391,8 @@
s_unbound_attr = clsdef.find_attribute(meth_name).getvalue()
s_attr = clsdef.lookup_filter(s_unbound_attr, meth_name,
hop.args_s[0].flags)
- if s_attr.is_constant():
- xxx # does that even happen?
+ # does that even happen?
+ assert not s_attr.is_constant()
if '__iter__' in self.allinstancefields:
raise Exception("__iter__ on instance disallowed")
r_method = self.rtyper.makerepr(s_attr)
diff --git a/rpython/rtyper/rcontrollerentry.py
b/rpython/rtyper/rcontrollerentry.py
--- a/rpython/rtyper/rcontrollerentry.py
+++ b/rpython/rtyper/rcontrollerentry.py
@@ -1,7 +1,7 @@
+from rpython.flowspace.model import Constant
+from rpython.rtyper.error import TyperError
+from rpython.rtyper.rmodel import Repr
from rpython.tool.pairtype import pairtype
-from rpython.flowspace.model import Constant
-from rpython.rtyper.rmodel import Repr
-from rpython.rtyper.error import TyperError
class ControlledInstanceRepr(Repr):
diff --git a/rpython/rtyper/rdict.py b/rpython/rtyper/rdict.py
--- a/rpython/rtyper/rdict.py
+++ b/rpython/rtyper/rdict.py
@@ -1,6 +1,6 @@
from rpython.annotator import model as annmodel
+from rpython.rtyper import rmodel
from rpython.rtyper.lltypesystem import lltype
-from rpython.rtyper import rmodel
class __extend__(annmodel.SomeDict):
@@ -83,4 +83,3 @@
return self.r_dict.recast_value(hop.llops, v)
else:
return v
-
diff --git a/rpython/rtyper/rexternalobj.py b/rpython/rtyper/rexternalobj.py
--- a/rpython/rtyper/rexternalobj.py
+++ b/rpython/rtyper/rexternalobj.py
@@ -1,17 +1,11 @@
from rpython.annotator import model as annmodel
+from rpython.rtyper import extregistry
from rpython.rtyper.lltypesystem import lltype
-from rpython.rtyper.ootypesystem import ootype
-from rpython.rtyper.rmodel import Repr
-from rpython.rtyper import rbuiltin
-from rpython.flowspace.model import Constant, Variable
-from rpython.rtyper import extregistry
-from rpython.annotator.signature import annotation
-from rpython.tool.pairtype import pairtype
# ExternalObjects
+
class __extend__(annmodel.SomeExternalObject):
-
def rtyper_makerepr(self, rtyper):
# delegate to the get_repr() of the extregistrered Entry class
entry = extregistry.lookup_type(self.knowntype)
@@ -25,4 +19,3 @@
if 'const_box' in attrs:
del attrs['const_box']
return self.__class__, attrs
-
diff --git a/rpython/rtyper/rfloat.py b/rpython/rtyper/rfloat.py
--- a/rpython/rtyper/rfloat.py
+++ b/rpython/rtyper/rfloat.py
@@ -1,21 +1,18 @@
+from rpython.annotator import model as annmodel
+from rpython.rlib.objectmodel import _hash_float
+from rpython.rlib.rarithmetic import base_int
+from rpython.rtyper.error import TyperError
+from rpython.rtyper.lltypesystem.lltype import (Signed, Unsigned,
+ SignedLongLong, UnsignedLongLong, Bool, Float)
+from rpython.rtyper.rmodel import FloatRepr, IntegerRepr, BoolRepr, log
+from rpython.rtyper.rstr import AbstractStringRepr
from rpython.tool.pairtype import pairtype
-from rpython.annotator import model as annmodel
-from rpython.rtyper.lltypesystem.lltype import (Signed, Unsigned,
SignedLongLong,
- UnsignedLongLong, Bool, Float)
-from rpython.rtyper.error import TyperError
-from rpython.rtyper.rmodel import FloatRepr
-from rpython.rtyper.rmodel import IntegerRepr, BoolRepr
-from rpython.rtyper.rstr import AbstractStringRepr
-from rpython.rtyper.rmodel import log
-from rpython.rlib.rarithmetic import base_int
-from rpython.rlib.objectmodel import _hash_float
-
-import math
class __extend__(annmodel.SomeFloat):
def rtyper_makerepr(self, rtyper):
return float_repr
+
def rtyper_makekey(self):
return self.__class__,
diff --git a/rpython/rtyper/rgeneric.py b/rpython/rtyper/rgeneric.py
--- a/rpython/rtyper/rgeneric.py
+++ b/rpython/rtyper/rgeneric.py
@@ -1,9 +1,9 @@
from rpython.annotator import model as annmodel
+from rpython.rtyper.lltypesystem import lltype
from rpython.rtyper.rmodel import Repr
-from rpython.rtyper.rpbc import AbstractFunctionsPBCRepr,\
- AbstractMethodsPBCRepr
+from rpython.rtyper.rpbc import AbstractFunctionsPBCRepr
from rpython.tool.pairtype import pairtype
-from rpython.rtyper.lltypesystem import lltype
+
class AbstractGenericCallableRepr(Repr):
def __init__(self, rtyper, s_generic):
@@ -20,7 +20,6 @@
return self.call('call_args', hop)
def call(self, opname, hop):
- bk = self.rtyper.annotator.bookkeeper
vlist = hop.inputargs(self, *self.args_r) +
[hop.inputconst(lltype.Void, None)]
hop.exception_is_here()
v_result = hop.genop('indirect_call', vlist, resulttype=self.r_result)
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit