Commits

Alex Gaynor committed c6db23c

dead import removal + pep8

Comments (0)

Files changed (8)

rpython/rtyper/rint.py

 import sys
-from rpython.tool.pairtype import pairtype
+
 from rpython.annotator import model as annmodel
 from rpython.flowspace.operation import op_appendices
-from rpython.rtyper.lltypesystem.lltype import Signed, Unsigned, Bool, Float, \
-     Void, Char, UniChar, malloc, UnsignedLongLong, \
-     SignedLongLong, build_number, Number, cast_primitive, typeOf, \
-     SignedLongLongLong
-from rpython.rtyper.rmodel import IntegerRepr, inputconst
-from rpython.rlib.rarithmetic import intmask, r_int, r_uint, r_ulonglong, \
-     r_longlong, is_emulated_long
-from rpython.rtyper.error import TyperError, MissingRTypeOperation
-from rpython.rtyper.rmodel import log
 from rpython.rlib import objectmodel
+from rpython.rlib.rarithmetic import intmask, r_int, r_longlong
+from rpython.rtyper.error import TyperError
+from rpython.rtyper.lltypesystem.lltype import (Signed, Unsigned, Bool, Float,
+    Char, UniChar, UnsignedLongLong, SignedLongLong, build_number, Number,
+    cast_primitive, typeOf, SignedLongLongLong)
+from rpython.rtyper.rmodel import IntegerRepr, inputconst, log
+from rpython.tool.pairtype import pairtype
+
 
 _integer_reprs = {}
 def getintegerrepr(lltype, prefix=None):
 
     #comparisons: eq is_ ne lt le gt ge
 
-    def rtype_eq(_, hop): 
+    def rtype_eq(_, hop):
         return _rtype_compare_template(hop, 'eq')
 
     rtype_is_ = rtype_eq
     get_ll_le_function = get_ll_eq_function
 
     def get_ll_ge_function(self):
-        return None 
+        return None
 
     def get_ll_hash_function(self):
         if (sys.maxint == 2147483647 and
     ll_dummy_value = -1
 
     def rtype_chr(_, hop):
-        vlist =  hop.inputargs(Signed)
+        vlist = hop.inputargs(Signed)
         if hop.has_implicit_exception(ValueError):
             hop.exception_is_here()
             hop.gendirectcall(ll_check_chr, vlist[0])
         vlist = hop.inputargs(self)
         return hop.genop(self.opprefix + 'is_true', vlist, resulttype=Bool)
 
-    #Unary arithmetic operations    
-    
+    #Unary arithmetic operations
+
     def rtype_abs(self, hop):
         self = self.as_int
         vlist = hop.inputargs(self)
         self = self.as_int
         vlist = hop.inputargs(self)
         return hop.genop(self.opprefix + 'invert', vlist, resulttype=self)
-        
+
     def rtype_neg(self, hop):
         self = self.as_int
         vlist = hop.inputargs(self)

rpython/rtyper/rmodel.py

+from rpython.annotator import model as annmodel, unaryop, binaryop, description
+from rpython.flowspace.model import Constant
+from rpython.rtyper.error import TyperError, MissingRTypeOperation
+from rpython.rtyper.lltypesystem import lltype
+from rpython.rtyper.lltypesystem.lltype import (Void, Bool, Float, typeOf,
+    LowLevelType, isCompatibleType)
 from rpython.tool.pairtype import pairtype, extendabletype, pair
-from rpython.annotator import model as annmodel, unaryop, binaryop
-from rpython.annotator import description
-from rpython.flowspace.model import Constant
-from rpython.rtyper.lltypesystem.lltype import \
-     Void, Bool, Float, Signed, Char, UniChar, \
-     typeOf, LowLevelType, Ptr, isCompatibleType
-from rpython.rtyper.lltypesystem import lltype, llmemory
-from rpython.rtyper.ootypesystem import ootype
-from rpython.rtyper.error import TyperError, MissingRTypeOperation 
 
-# initialization states for Repr instances 
 
-class setupstate(object): 
-    NOTINITIALIZED = 0 
+# initialization states for Repr instances
+
+class setupstate(object):
+    NOTINITIALIZED = 0
     INPROGRESS = 1
-    BROKEN = 2 
+    BROKEN = 2
     FINISHED = 3
     DELAYED = 4
 
     iterating over.
     """
     __metaclass__ = extendabletype
-    _initialized = setupstate.NOTINITIALIZED 
+    _initialized = setupstate.NOTINITIALIZED
 
     def __repr__(self):
         return '<%s %s>' % (self.__class__.__name__, self.lowleveltype)
     def compact_repr(self):
         return '%s %s' % (self.__class__.__name__.replace('Repr','R'), self.lowleveltype._short_name())
 
-    def setup(self): 
+    def setup(self):
         """ call _setup_repr() and keep track of the initializiation
             status to e.g. detect recursive _setup_repr invocations.
-            the '_initialized' attr has four states: 
+            the '_initialized' attr has four states:
         """
-        if self._initialized == setupstate.FINISHED: 
-            return 
-        elif self._initialized == setupstate.BROKEN: 
+        if self._initialized == setupstate.FINISHED:
+            return
+        elif self._initialized == setupstate.BROKEN:
             raise BrokenReprTyperError(
                 "cannot setup already failed Repr: %r" %(self,))
-        elif self._initialized == setupstate.INPROGRESS: 
+        elif self._initialized == setupstate.INPROGRESS:
             raise AssertionError(
                 "recursive invocation of Repr setup(): %r" %(self,))
         elif self._initialized == setupstate.DELAYED:
             raise AssertionError(
                 "Repr setup() is delayed and cannot be called yet: %r" %(self,))
-        assert self._initialized == setupstate.NOTINITIALIZED 
-        self._initialized = setupstate.INPROGRESS 
-        try: 
-            self._setup_repr() 
-        except TyperError, e: 
-            self._initialized = setupstate.BROKEN 
-            raise 
-        else: 
-            self._initialized = setupstate.FINISHED 
+        assert self._initialized == setupstate.NOTINITIALIZED
+        self._initialized = setupstate.INPROGRESS
+        try:
+            self._setup_repr()
+        except TyperError, e:
+            self._initialized = setupstate.BROKEN
+            raise
+        else:
+            self._initialized = setupstate.FINISHED
 
     def _setup_repr(self):
         "For recursive data structure, which must be initialized in two steps."
         """Same as setup(), called a bit later, for effects that are only
         needed after the typer finished (as opposed to needed for other parts
         of the typer itself)."""
-        if self._initialized == setupstate.BROKEN: 
+        if self._initialized == setupstate.BROKEN:
             raise BrokenReprTyperError("cannot perform setup_final_touch "
                              "on failed Repr: %r" %(self,))
         assert self._initialized == setupstate.FINISHED, (
                 "setup_final() on repr with state %s: %r" %
                 (self._initialized, self))
-        self._setup_repr_final() 
+        self._setup_repr_final()
 
-    def _setup_repr_final(self): 
+    def _setup_repr_final(self):
         pass
 
     def is_setup_delayed(self):
     def __getattr__(self, name):
         # Assume that when an attribute is missing, it's because setup() needs
         # to be called
-        if not (name[:2] == '__' == name[-2:]): 
-            if self._initialized == setupstate.NOTINITIALIZED: 
+        if not (name[:2] == '__' == name[-2:]):
+            if self._initialized == setupstate.NOTINITIALIZED:
                 self.setup()
                 try:
                     return self.__dict__[name]
         else:
             raise TyperError("convert_desc_or_const expects a Desc"
                              "or Constant: %r" % desc_or_const)
-                            
+
     def convert_const(self, value):
         "Convert the given constant value to the low-level repr of 'self'."
         if self.lowleveltype is not Void:
         values of this Repr.
         This can return None to mean that simply using '==' is fine.
         """
-        raise TyperError, 'no equality function for %r' % self
+        raise TyperError('no equality function for %r' % self)
 
     def get_ll_hash_function(self):
         """Return a hash(x) function for low-level values of this Repr.
         """
-        raise TyperError, 'no hashing function for %r' % self
+        raise TyperError('no hashing function for %r' % self)
 
     def get_ll_fasthash_function(self):
         """Return a 'fast' hash(x) function for low-level values of this
             r_baseiter = r_container.make_iterator_repr()
             return EnumerateIteratorRepr(r_baseiter)
         return r_container.make_iterator_repr(*self.variant)
+
     def rtyper_makekey_ex(self, rtyper):
         return self.__class__, rtyper.makekey(self.s_container), self.variant
 
+
 class __extend__(annmodel.SomeImpossibleValue):
     def rtyper_makerepr(self, rtyper):
         return impossible_repr
+
     def rtyper_makekey(self):
         return self.__class__,
 
 
 
 class __extend__(pairtype(Repr, Repr)):
-    
+
     def rtype_is_((robj1, robj2), hop):
         if hop.s_result.is_constant():
             return inputconst(Bool, hop.s_result.const)
         return hop.rtyper.type_system.generic_is(robj1, robj2, hop)
 
     # default implementation for checked getitems
-    
+
     def rtype_getitem_idx_key((r_c1, r_o1), hop):
         return pair(r_c1, r_o1).rtype_getitem(hop)
 
         return self._opprefix
 
     opprefix = property(_get_opprefix)
-    
+
 class BoolRepr(IntegerRepr):
     lowleveltype = Bool
     # NB. no 'opprefix' here.  Use 'as_int' systematically.
     c.concretetype = lltype
     return c
 
-class BrokenReprTyperError(TyperError): 
-    """ raised when trying to setup a Repr whose setup 
-        has failed already. 
+class BrokenReprTyperError(TyperError):
+    """ raised when trying to setup a Repr whose setup
+        has failed already.
     """
 
 def mangle(prefix, name):
 
 def warning(msg):
     log.WARNING(msg)
-
-
-

rpython/rtyper/rpbc.py

 import types
-import sys
+
+from rpython.annotator import model as annmodel, description
+from rpython.flowspace.model import Constant
+from rpython.rtyper import rclass, callparse
+from rpython.rtyper.annlowlevel import llstr
+from rpython.rtyper.error import TyperError
+from rpython.rtyper.lltypesystem.lltype import typeOf, Void, Bool
+from rpython.rtyper.rmodel import (Repr, inputconst, CanBeNull, mangle,
+    inputdesc, warning, impossible_repr)
 from rpython.tool.pairtype import pair, pairtype
-from rpython.annotator import model as annmodel
-from rpython.annotator import description
-from rpython.flowspace.model import Constant
-from rpython.rtyper.lltypesystem.lltype import \
-     typeOf, Void, Bool, nullptr, frozendict, Ptr, Struct, malloc
-from rpython.rtyper.error import TyperError
-from rpython.rtyper.rmodel import Repr, inputconst, CanBeNull, \
-        mangle, inputdesc, warning, impossible_repr
-from rpython.rtyper import rclass
-from rpython.rtyper.annlowlevel import llstr, llunicode
 
-from rpython.rtyper import callparse
 
 def small_cand(rtyper, s_pbc):
     if 1 < len(s_pbc.descriptions) < rtyper.getconfig().translation.withsmallfuncsets and \
 class __extend__(annmodel.SomePBC):
     def rtyper_makerepr(self, rtyper):
         if self.isNone():
-            return none_frozen_pbc_repr 
+            return none_frozen_pbc_repr
         kind = self.getKind()
         if issubclass(kind, description.FunctionDesc):
             sample = self.any_description()
         elif issubclass(kind, description.MethodOfFrozenDesc):
             getRepr = rtyper.type_system.rpbc.MethodOfFrozenPBCRepr
         else:
-            raise TyperError("unexpected PBC kind %r"%(kind,))
+            raise TyperError("unexpected PBC kind %r" % (kind,))
 
         return getRepr(rtyper, self)
 
     """
     concretetable = {}   # (shape,index): row, maybe with duplicates
     uniquerows = []      # list of rows, without duplicates
-    
+
     def lookuprow(row):
         # a 'matching' row is one that has the same llfn, expect
         # that it may have more or less 'holes'
             return hop.llops.convertvar(v, rresult, hop.r_result)
 
 class __extend__(pairtype(AbstractFunctionsPBCRepr, AbstractFunctionsPBCRepr)):
-        def convert_from_to((r_fpbc1, r_fpbc2), v, llops):
-            # this check makes sense because both source and dest repr are FunctionsPBCRepr
-            if r_fpbc1.lowleveltype == r_fpbc2.lowleveltype:
-                return v
-            if r_fpbc1.lowleveltype is Void:
-                return inputconst(r_fpbc2, r_fpbc1.s_pbc.const)
-            if r_fpbc2.lowleveltype is Void:
-                return inputconst(Void, None)
-            return NotImplemented
+    def convert_from_to((r_fpbc1, r_fpbc2), v, llops):
+        # this check makes sense because both source and dest repr are FunctionsPBCRepr
+        if r_fpbc1.lowleveltype == r_fpbc2.lowleveltype:
+            return v
+        if r_fpbc1.lowleveltype is Void:
+            return inputconst(r_fpbc2, r_fpbc1.s_pbc.const)
+        if r_fpbc2.lowleveltype is Void:
+            return inputconst(Void, None)
+        return NotImplemented
 
 class OverriddenFunctionPBCRepr(Repr):
     def __init__(self, rtyper, s_pbc):
             result = rtyper.type_system.rpbc.MultipleFrozenPBCRepr(rtyper,
                                                                    access)
             rtyper.pbc_reprs[access] = result
-            rtyper.add_pendingsetup(result) 
+            rtyper.add_pendingsetup(result)
             return result
 
 
 
     def convert_const(self, pbc):
         if pbc is None:
-            return self.null_instance() 
+            return self.null_instance()
         if isinstance(pbc, types.MethodType) and pbc.im_self is None:
             value = pbc.im_func   # unbound method -> bare function
         frozendesc = self.rtyper.annotator.bookkeeper.getdesc(pbc)
                 mangled_name = mangle('pbc', attr)
                 fields.append((mangled_name, r_value.lowleveltype))
                 self.fieldmap[attr] = mangled_name, r_value
-        return fields 
+        return fields
 
     def convert_desc(self, frozendesc):
         if (self.access_set is not None and
         # XXX sort this out
         #call_families = rtyper.annotator.getpbccallfamilies()
         #call_families.find((None, self.function))
-        
+
         if s_pbc.can_be_none():
             raise TyperError("unsupported: variable of type "
                              "method-of-frozen-PBC or None")
         for desc in s_pbc.descriptions:
             assert desc.funcdesc is self.funcdesc
             im_selves.append(desc.frozendesc)
-            
+
         self.s_im_self = annmodel.SomePBC(im_selves)
         self.r_im_self = rtyper.getrepr(self.s_im_self)
         self.lowleveltype = self.r_im_self.lowleveltype
 
     def convert_desc(self, mdesc):
         if mdesc.funcdesc is not self.funcdesc:
-            raise TyperError("not a method bound on %r: %r" % (self.funcdesc, 
+            raise TyperError("not a method bound on %r: %r" % (self.funcdesc,
                                                                mdesc))
         return self.r_im_self.convert_desc(mdesc.frozendesc)
 
 
     def convert_from_to((r_from, _), v, llops):
         return inputconst(Void, None)
-    
+
     def rtype_is_((robj1, rnone2), hop):
         if hop.s_result.is_constant():
             return hop.inputconst(Bool, hop.s_result.const)
 
     def convert_desc(self, desc):
         if desc not in self.s_pbc.descriptions:
-            raise TyperError("%r not in %r" % (cls, self))
+            raise TyperError("%r not in %r" % (desc, self))
         if self.lowleveltype is Void:
             return None
         subclassdef = desc.getuniqueclassdef()
             s_init = classdef.classdesc.s_read_attribute('__init__')
             v_init = Constant("init-func-dummy")   # this value not really used
 
-            if (isinstance(s_init, annmodel.SomeImpossibleValue) and 
+            if (isinstance(s_init, annmodel.SomeImpossibleValue) and
                 classdef.classdesc.is_exception_class() and
                 classdef.has_no_attrs()):
                 # special case for instanciating simple built-in
             else:
                 s_init = access_set.s_value
                 v_init = r_class.getpbcfield(vtypeptr, access_set, '__init__',
-                                             hop.llops)                
+                                             hop.llops)
             v_instance = self._instantiate_runtime_class(hop, vtypeptr, r_instance)
 
         if isinstance(s_init, annmodel.SomeImpossibleValue):
         return v_instance
 
 
-
 class __extend__(pairtype(AbstractClassesPBCRepr, rclass.AbstractClassRepr)):
     def convert_from_to((r_clspbc, r_cls), v, llops):
         # turn a PBC of classes to a standard pointer-to-vtable class repr
     for cdef1 in classdef.getmro():
         for attrname in cdef1.attrs:
             yield cdef1, attrname
-

rpython/rtyper/rptr.py

-from rpython.tool.pairtype import pairtype
 from rpython.annotator import model as annmodel
 from rpython.flowspace import model as flowmodel
+from rpython.rlib.rarithmetic import r_uint
+from rpython.rtyper.error import TyperError
 from rpython.rtyper.lltypesystem import lltype
-from rpython.rtyper.error import TyperError
 from rpython.rtyper.rmodel import Repr, IntegerRepr
-from rpython.rlib.rarithmetic import r_uint
+from rpython.tool.pairtype import pairtype
 
 
 class __extend__(annmodel.SomePtr):
         if r_from.lowleveltype == r_to.lowleveltype:
             return v
         return NotImplemented
-

rpython/rtyper/rrange.py

-from rpython.tool.pairtype import pairtype
+from rpython.flowspace.model import Constant
 from rpython.rtyper.error import TyperError
 from rpython.rtyper.lltypesystem.lltype import Signed, Void, Ptr
+from rpython.rtyper.rlist import dum_nocheck, dum_checkidx
 from rpython.rtyper.rmodel import Repr, IntegerRepr, IteratorRepr
-from rpython.flowspace.model import Constant
-from rpython.rtyper.rlist import dum_nocheck, dum_checkidx
+from rpython.tool.pairtype import pairtype
 
 
 class AbstractRangeRepr(Repr):
 
 def _ll_rangelen(start, stop, step):
     if step > 0:
-        result = (stop - start + (step-1)) // step
+        result = (stop - start + (step - 1)) // step
     else:
-        result = (start - stop - (step+1)) // (-step)
+        result = (start - stop - (step + 1)) // (-step)
     if result < 0:
         result = 0
     return result

rpython/rtyper/rstr.py

-from rpython.tool.staticmethods import StaticMethods
+from rpython.annotator import model as annmodel
+from rpython.rlib import jit
+from rpython.rtyper import rint
+from rpython.rtyper.error import TyperError
+from rpython.rtyper.lltypesystem.lltype import (Signed, Bool, Void, UniChar,
+    typeOf)
+from rpython.rtyper.rmodel import IntegerRepr, IteratorRepr, inputconst, Repr
+from rpython.rtyper.rtuple import AbstractTupleRepr
 from rpython.tool.pairtype import pairtype, pair
 from rpython.tool.sourcetools import func_with_new_name
-from rpython.annotator import model as annmodel
-from rpython.rlib import jit
-from rpython.rlib.nonconst import NonConstant
-from rpython.rtyper.error import TyperError
-from rpython.rtyper.rmodel import IntegerRepr, IteratorRepr
-from rpython.rtyper.rmodel import inputconst, Repr
-from rpython.rtyper.rtuple import AbstractTupleRepr
-from rpython.rtyper import rint
-from rpython.rtyper.lltypesystem.lltype import Signed, Bool, Void, UniChar,\
-     cast_primitive, typeOf
+from rpython.tool.staticmethods import StaticMethods
+
 
 class AbstractStringRepr(Repr):
 
     def ll_raise_unicode_exception_decode(self, errors, encoding, msg, s,
                                        startingpos, endingpos):
         raise UnicodeDecodeError(encoding, s, startingpos, endingpos, msg)
-    
+
 
 class AbstractCharRepr(AbstractStringRepr):
     def rtype_method_lower(self, hop):
     def ll_raise_unicode_exception_encode(self, errors, encoding, msg, u,
                                           startingpos, endingpos):
         raise UnicodeEncodeError(encoding, u, startingpos, endingpos, msg)
-    
+
 class __extend__(annmodel.SomeString):
     def rtyper_makerepr(self, rtyper):
         return rtyper.type_system.rstr.string_repr
             hop.exception_is_here()
             return hop.gendirectcall(self.ll.ll_int, v_str, c_base)
         if not hop.args_r[1] == rint.signed_repr:
-            raise TyperError, 'base needs to be an int'
-        v_str, v_base= hop.inputargs(string_repr, rint.signed_repr)
+            raise TyperError('base needs to be an int')
+        v_str, v_base = hop.inputargs(string_repr, rint.signed_repr)
         hop.exception_is_here()
         return hop.gendirectcall(self.ll.ll_int, v_str, v_base)
 
 def _rtype_compare_template(hop, func):
     rstr = hop.rtyper.type_system.rstr
     vlist = hop.inputargs(rstr.char_repr, rstr.char_repr)
-    return hop.genop('char_'+func, vlist, resulttype=Bool)
+    return hop.genop('char_' + func, vlist, resulttype=Bool)
 
 class __extend__(AbstractUniCharRepr):
 
 def _rtype_unchr_compare_template(hop, func):
     rstr = hop.rtyper.type_system.rstr
     vlist = hop.inputargs(rstr.unichar_repr, rstr.unichar_repr)
-    return hop.genop('unichar_'+func, vlist, resulttype=Bool)
+    return hop.genop('unichar_' + func, vlist, resulttype=Bool)
 
 
 #
                 break
         if beg == n:
             raise ValueError
-        end = n-1
+        end = n - 1
         while end >= 0:
             if s[end] == ' ':
                 end -= 1
             else:
                 break
         assert end >= 0
-        return rstring_to_float(s[beg:end+1])
+        return rstring_to_float(s[beg:end + 1])
 
     def ll_splitlines(cls, LIST, ll_str, keep_newlines):
         from rpython.rtyper.annlowlevel import hlstr
         s = hlstr(ll_str)
-        STR = typeOf(ll_str)
         strlen = len(s)
         i = 0
         j = 0

rpython/rtyper/rtuple.py

 import operator
-from rpython.tool.pairtype import pairtype
+
 from rpython.annotator import model as annmodel
 from rpython.flowspace.model import Constant
-from rpython.rtyper.error import TyperError
-from rpython.rtyper.rmodel import Repr, IntegerRepr, inputconst
-from rpython.rtyper.rmodel import IteratorRepr
-from rpython.rtyper.rmodel import externalvsinternal
-from rpython.rtyper.lltypesystem.lltype import Void, Signed, Bool
 from rpython.rlib.rarithmetic import intmask
 from rpython.rlib.unroll import unrolling_iterable
+from rpython.rtyper.error import TyperError
+from rpython.rtyper.lltypesystem.lltype import Void, Signed, Bool
+from rpython.rtyper.rmodel import (Repr, IntegerRepr, inputconst, IteratorRepr,
+    externalvsinternal)
+from rpython.tool.pairtype import pairtype
+
 
 class __extend__(annmodel.SomeTuple):
     def rtyper_makerepr(self, rtyper):
         repr_class = rtyper.type_system.rtuple.TupleRepr
         return repr_class(rtyper, [rtyper.getrepr(s_item) for s_item in self.items])
-    
+
     def rtyper_makekey_ex(self, rtyper):
         keys = [rtyper.makekey(s_item) for s_item in self.items]
         return tuple([self.__class__]+keys)
                    for i in indices]
         return hop.r_result.newtuple(hop.llops, hop.r_result, items_v)
 
-class __extend__(pairtype(AbstractTupleRepr, Repr)): 
+class __extend__(pairtype(AbstractTupleRepr, Repr)):
     def rtype_contains((r_tup, r_item), hop):
         s_tup = hop.args_s[0]
         if not s_tup.is_constant():
-            raise TyperError("contains() on non-const tuple") 
+            raise TyperError("contains() on non-const tuple")
         t = s_tup.const
-        typ = type(t[0]) 
-        for x in t[1:]: 
-            if type(x) is not typ: 
+        typ = type(t[0])
+        for x in t[1:]:
+            if type(x) is not typ:
                 raise TyperError("contains() on mixed-type tuple "
                                  "constant %r" % (t,))
         d = {}
-        for x in t: 
-            d[x] = None 
+        for x in t:
+            d[x] = None
         hop2 = hop.copy()
         _, _ = hop2.r_s_popfirstarg()
         v_dict = Constant(d)
         s_dict = hop.rtyper.annotator.bookkeeper.immutablevalue(d)
         hop2.v_s_insertfirstarg(v_dict, s_dict)
         return hop2.dispatch()
- 
+
 class __extend__(pairtype(AbstractTupleRepr, AbstractTupleRepr)):
-    
+
     def rtype_add((r_tup1, r_tup2), hop):
         v_tuple1, v_tuple2 = hop.inputargs(r_tup1, r_tup2)
         vlist = []
         hop.exception_is_here()
         v = hop.gendirectcall(self.ll_tuplenext, v_iter)
         return hop.llops.convertvar(v, self.r_tuple.items_r[0], self.r_tuple.external_items_r[0])
-

rpython/rtyper/rtyper.py

 """
 
 import os
+
 import py
-from rpython.tool.pairtype import pair
+
 from rpython.annotator import model as annmodel, unaryop, binaryop
 from rpython.annotator.annrpython import FAIL
-from rpython.flowspace.model import Variable, Constant
-from rpython.flowspace.model import SpaceOperation, c_last_exception
-from rpython.rtyper.lltypesystem.lltype import \
-     Signed, Unsigned, Float, Char, Bool, Void, \
-     LowLevelType, Ptr, ContainerType, \
-     FuncType, functionptr, typeOf, RuntimeTypeInfo, \
-     attachRuntimeTypeInfo, Primitive, Number
+from rpython.flowspace.model import Variable, Constant, SpaceOperation, c_last_exception
+from rpython.rtyper.annlowlevel import annotate_lowlevel_helper, LowLevelAnnotatorPolicy
+from rpython.rtyper.error import TyperError
+from rpython.rtyper.lltypesystem.lltype import (Signed, Void, LowLevelType,
+    Ptr, ContainerType, FuncType, functionptr, typeOf, RuntimeTypeInfo,
+    attachRuntimeTypeInfo, Primitive)
 from rpython.rtyper.ootypesystem import ootype
+from rpython.rtyper.rmodel import Repr, inputconst, BrokenReprTyperError
+from rpython.rtyper.typesystem import LowLevelTypeSystem, ObjectOrientedTypeSystem
+from rpython.tool.pairtype import pair
 from rpython.translator.unsimplify import insert_empty_block
-from rpython.rtyper.error import TyperError
-from rpython.rtyper.rmodel import Repr, inputconst, BrokenReprTyperError
-from rpython.rtyper.rmodel import warning
-from rpython.rtyper.annlowlevel import annotate_lowlevel_helper, LowLevelAnnotatorPolicy
-from rpython.rtyper.typesystem import LowLevelTypeSystem,\
-                                    ObjectOrientedTypeSystem
 
 
 class RPythonTyper(object):
         if isinstance(lltype, Primitive):
             repr = self.primitive_to_repr[lltype] = self.getrepr(annmodel.lltype_to_annotation(lltype))
             return repr
-        raise TyperError('There is no primitive repr for %r'%(lltype,))
-    
+        raise TyperError('There is no primitive repr for %r' % (lltype,))
+
     def add_wrapper(self, clsdef):
         # record that this class has a wrapper, and what the __init__ is
         cls = clsdef.classdesc.pyobj
         # not nice, but we sometimes need to know which function we are wrapping
         self.wrapper_context = obj
 
-    def add_pendingsetup(self, repr): 
+    def add_pendingsetup(self, repr):
         assert isinstance(repr, Repr)
-        if repr in self._seen_reprs_must_call_setup: 
+        if repr in self._seen_reprs_must_call_setup:
             #warning("ignoring already seen repr for setup: %r" %(repr,))
-            return 
-        self._reprs_must_call_setup.append(repr) 
-        self._seen_reprs_must_call_setup[repr] = True 
-        
+            return
+        self._reprs_must_call_setup.append(repr)
+        self._seen_reprs_must_call_setup[repr] = True
+
     def getexceptiondata(self):
         return self.exceptiondata    # built at the end of specialize()
 
 
     def makerepr(self, s_obj):
         return pair(self.type_system, s_obj).rtyper_makerepr(self)
-        
+
     def getrepr(self, s_obj):
         # s_objs are not hashable... try hard to find a unique key anyway
         key = self.makekey(s_obj)
             # make sure all reprs so far have had their setup() called
             self.call_all_setups()
 
-        if self.typererrors: 
-            self.dump_typererrors(to_log=True) 
+        if self.typererrors:
+            self.dump_typererrors(to_log=True)
             raise TyperError("there were %d error" % len(self.typererrors))
         self.log.event('-=- specialized %d%s blocks -=-' % (
             blockcount, newtext))
                     if methname not in SELF._methods:
                         ootype.addMethods(SELF, {methname: meth})
 
-    def dump_typererrors(self, num=None, minimize=True, to_log=False): 
+    def dump_typererrors(self, num=None, minimize=True, to_log=False):
         c = 0
         bc = 0
-        for err in self.typererrors[:num]: 
+        for err in self.typererrors[:num]:
             c += 1
-            if minimize and isinstance(err, BrokenReprTyperError): 
+            if minimize and isinstance(err, BrokenReprTyperError):
                 bc += 1
                 continue
             graph, block, position = err.where
             self.setup_block_entry(block)
         except TyperError, e:
             self.gottypererror(e, block, "block-entry", None)
-            return  # cannot continue this block            
-            
+            return  # cannot continue this block
+
 
         # specialize all the operations, as far as possible
         if block.operations == ():   # return or except block
 
         extrablock = None
         pos = newops.llop_raising_exceptions
-        if (pos is not None and pos != len(newops)-1):
+        if (pos is not None and pos != len(newops) - 1):
             # this is for the case where the llop that raises the exceptions
             # is not the last one in the list.
             assert block.exitswitch == c_last_exception
             # consider it as a link source instead
             self.insert_link_conversions(extrablock)
 
-    def _convert_link(self, block, link):  
+    def _convert_link(self, block, link):
         if link.exitcase is not None and link.exitcase != 'default':
             if isinstance(block.exitswitch, Variable):
                 r_case = self.bindingrepr(block.exitswitch)
         return self.llops.gendirectcall(ll_function, *args_v)
 
     def r_s_pop(self, index=-1):
-        "Return and discard the argument with index position."        
+        "Return and discard the argument with index position."
         self.nb_args -= 1
         self.args_v.pop(index)
         return self.args_r.pop(index), self.args_s.pop(index)
-    
+
     def r_s_popfirstarg(self):
         "Return and discard the first argument."
         return self.r_s_pop(0)
             else:
                 args_s.append(annmodel.lltype_to_annotation(v.concretetype))
             newargs_v.append(v)
-        
+
         self.rtyper.call_all_setups()  # compute ForwardReferences now
 
         # hack for bound methods