Commits

Alex Gaynor committed 6614966

some random cleanups

Comments (0)

Files changed (1)

pypy/interpreter/typedef.py

-"""
+import py
 
-
-"""
-import py
-from pypy.interpreter.gateway import interp2app, BuiltinCode, unwrap_spec,\
-     WrappedDefault
 from pypy.interpreter.argument import Arguments
 from pypy.interpreter.baseobjspace import Wrappable, DescrMismatch
 from pypy.interpreter.error import OperationError, operationerrfmt
+from pypy.interpreter.gateway import (interp2app, BuiltinCode, unwrap_spec,
+     WrappedDefault)
+
+from rpython.rlib.jit import promote
+from rpython.rlib.objectmodel import compute_identity_hash, specialize
 from rpython.tool.sourcetools import compile2, func_with_new_name
-from rpython.rlib.objectmodel import instantiate, compute_identity_hash, specialize
-from rpython.rlib.jit import promote
 
-class TypeDef:
+
+class TypeDef(object):
     def __init__(self, __name, __base=None, __total_ordering__=None, **rawdict):
         "NOT_RPYTHON: initialization-time only"
         self.name = __name
         self.weakrefable = '__weakref__' in rawdict
         self.doc = rawdict.pop('__doc__', None)
         for base in bases:
-            self.hasdict     |= base.hasdict
+            self.hasdict |= base.hasdict
             self.weakrefable |= base.weakrefable
         self.rawdict = {}
         self.acceptable_as_base_class = '__new__' in rawdict
         return unknown_objclass_getter, cls
     miniglobals = {}
     if isinstance(cls, str):
-        assert cls.startswith('<'),"pythontype typecheck should begin with <"
+        assert cls.startswith('<'), "pythontype typecheck should begin with <"
         cls_name = cls[1:]
         typeexpr = "space.w_%s" % cls_name
     else:
         else:
             try:
                 return self.fget(self, space, w_obj)
-            except DescrMismatch, e:
+            except DescrMismatch:
                 return w_obj.descr_call_mismatch(
                     space, '__getattribute__',
                     self.reqcls, Arguments(space, [w_obj,
                                  space.wrap("readonly attribute"))
         try:
             fset(self, space, w_obj, w_value)
-        except DescrMismatch, e:
+        except DescrMismatch:
             w_obj.descr_call_mismatch(
                 space, '__setattr__',
                 self.reqcls, Arguments(space, [w_obj,
                                  space.wrap("cannot delete attribute"))
         try:
             fdel(self, space, w_obj)
-        except DescrMismatch, e:
+        except DescrMismatch:
             w_obj.descr_call_mismatch(
                 space, '__delattr__',
                 self.reqcls, Arguments(space, [w_obj,
 class Member(Wrappable):
     """For slots."""
     _immutable_ = True
+
     def __init__(self, index, name, w_cls):
         self.index = index
         self.name = name
 from pypy.interpreter.pyframe import PyFrame
 from pypy.interpreter.pyopcode import SuspendedUnroller
 from pypy.interpreter.module import Module
-from pypy.interpreter.function import Function, Method, StaticMethod
-from pypy.interpreter.function import ClassMethod
-from pypy.interpreter.function import BuiltinFunction, descr_function_get
+from pypy.interpreter.function import (Function, Method, StaticMethod,
+    ClassMethod, BuiltinFunction, descr_function_get)
 from pypy.interpreter.pytraceback import PyTraceback
 from pypy.interpreter.generator import GeneratorIterator
 from pypy.interpreter.nestedscope import Cell
 def fget_co_flags(space, code): # unwrapping through unwrap_spec
     sig = code.signature()
     flags = 0
-    if sig.has_vararg(): flags |= CO_VARARGS
-    if sig.has_kwarg(): flags |= CO_VARKEYWORDS
+    if sig.has_vararg():
+        flags |= CO_VARARGS
+    if sig.has_kwarg():
+        flags |= CO_VARKEYWORDS
     return space.wrap(flags)
 
 def fget_co_consts(space, code): # unwrapping through unwrap_spec
     __eq__ = interp2app(PyCode.descr_code__eq__),
     __ne__ = descr_generic_ne,
     __hash__ = interp2app(PyCode.descr_code__hash__),
-    __reduce__   = interp2app(PyCode.descr__reduce__),
+    __reduce__ = interp2app(PyCode.descr__reduce__),
     __repr__ = interp2app(PyCode.repr),
     co_argcount = interp_attrproperty('co_argcount', cls=PyCode),
     co_nlocals = interp_attrproperty('co_nlocals', cls=PyCode),
     co_code = interp_attrproperty('co_code', cls=PyCode),
     co_consts = GetSetProperty(PyCode.fget_co_consts),
     co_names = GetSetProperty(PyCode.fget_co_names),
-    co_varnames =  GetSetProperty(PyCode.fget_co_varnames),
-    co_freevars =  GetSetProperty(PyCode.fget_co_freevars),
-    co_cellvars =  GetSetProperty(PyCode.fget_co_cellvars),
+    co_varnames = GetSetProperty(PyCode.fget_co_varnames),
+    co_freevars = GetSetProperty(PyCode.fget_co_freevars),
+    co_cellvars = GetSetProperty(PyCode.fget_co_cellvars),
     co_filename = interp_attrproperty('co_filename', cls=PyCode),
     co_name = interp_attrproperty('co_name', cls=PyCode),
     co_firstlineno = interp_attrproperty('co_firstlineno', cls=PyCode),
 PyCode.typedef.acceptable_as_base_class = False
 
 PyFrame.typedef = TypeDef('frame',
-    __reduce__   = interp2app(PyFrame.descr__reduce__),
+    __reduce__ = interp2app(PyFrame.descr__reduce__),
     __setstate__ = interp2app(PyFrame.descr__setstate__),
     f_builtins = GetSetProperty(PyFrame.fget_f_builtins),
     f_lineno = GetSetProperty(PyFrame.fget_f_lineno, PyFrame.fset_f_lineno),
     __new__ = interp2app(Method.descr_method__new__.im_func),
     __call__ = interp2app(Method.descr_method_call),
     __get__ = interp2app(Method.descr_method_get),
-    im_func  = interp_attrproperty_w('w_function', cls=Method),
+    im_func = interp_attrproperty_w('w_function', cls=Method),
     __func__ = interp_attrproperty_w('w_function', cls=Method),
-    im_self  = interp_attrproperty_w('w_instance', cls=Method),
+    im_self = interp_attrproperty_w('w_instance', cls=Method),
     __self__ = interp_attrproperty_w('w_instance', cls=Method),
     im_class = interp_attrproperty_w('w_class', cls=Method),
     __getattribute__ = interp2app(Method.descr_method_getattribute),
 
 def always_none(self, obj):
     return None
-BuiltinFunction.typedef = TypeDef("builtin_function",**Function.typedef.rawdict)
+BuiltinFunction.typedef = TypeDef("builtin_function", **Function.typedef.rawdict)
 BuiltinFunction.typedef.rawdict.update({
     '__new__': interp2app(BuiltinFunction.descr_builtinfunction__new__.im_func),
     '__self__': GetSetProperty(always_none, cls=BuiltinFunction),
 BuiltinFunction.typedef.acceptable_as_base_class = False
 
 PyTraceback.typedef = TypeDef("traceback",
-    __reduce__   = interp2app(PyTraceback.descr__reduce__),
+    __reduce__ = interp2app(PyTraceback.descr__reduce__),
     __setstate__ = interp2app(PyTraceback.descr__setstate__),
-    tb_frame  = interp_attrproperty('frame', cls=PyTraceback),
-    tb_lasti  = interp_attrproperty('lasti', cls=PyTraceback),
+    tb_frame = interp_attrproperty('frame', cls=PyTraceback),
+    tb_lasti = interp_attrproperty('lasti', cls=PyTraceback),
     tb_lineno = GetSetProperty(PyTraceback.descr_tb_lineno),
-    tb_next   = interp_attrproperty('next', cls=PyTraceback),
+    tb_next = interp_attrproperty('next', cls=PyTraceback),
     )
 PyTraceback.typedef.acceptable_as_base_class = False
 
 Cell.typedef.acceptable_as_base_class = False
 
 Ellipsis.typedef = TypeDef("Ellipsis",
-    __repr__   = interp2app(Ellipsis.descr__repr__),
+    __repr__ = interp2app(Ellipsis.descr__repr__),
 )
 Ellipsis.typedef.acceptable_as_base_class = False
 
 NotImplemented.typedef = TypeDef("NotImplemented",
-    __repr__   = interp2app(NotImplemented.descr__repr__),
+    __repr__ = interp2app(NotImplemented.descr__repr__),
 )
 NotImplemented.typedef.acceptable_as_base_class = False