Alex Gaynor avatar Alex Gaynor committed 4ec167b

General cleanups, switch something to use a better API

Comments (0)

Files changed (2)

pypy/interpreter/pytraceback.py

 from pypy.interpreter import baseobjspace
 from pypy.interpreter.error import OperationError
+
 from rpython.tool.error import offset2lineno
 
 
 
     def descr__reduce__(self, space):
         from pypy.interpreter.mixedmodule import MixedModule
-        w_mod    = space.getbuiltinmodule('_pickle_support')
-        mod      = space.interp_w(MixedModule, w_mod)
+        w_mod = space.getbuiltinmodule('_pickle_support')
+        mod = space.interp_w(MixedModule, w_mod)
         new_inst = mod.get('traceback_new')
-        w        = space.wrap
+        w = space.wrap
 
         tup_base = []
         tup_state = [
         self.lasti = space.int_w(w_lasti)
         self.next = space.interp_w(PyTraceback, w_next, can_be_None=True)
 
+
 def record_application_traceback(space, operror, frame, last_instruction):
     if frame.pycode.hidden_applevel:
         return
     tb = PyTraceback(space, frame, last_instruction, tb)
     operror.set_traceback(tb)
 
+
 def check_traceback(space, w_tb, msg):
     from pypy.interpreter.typedef import PyTraceback
     tb = space.interpclass_w(w_tb)
-    if tb is None or not space.is_true(space.isinstance(tb, 
+    if tb is None or not space.is_true(space.isinstance(tb,
             space.gettypeobject(PyTraceback.typedef))):
         raise OperationError(space.w_TypeError, space.wrap(msg))
     return tb

pypy/objspace/std/typeobject.py

+from pypy.interpreter import gateway
+from pypy.interpreter.baseobjspace import W_Root
+from pypy.interpreter.error import OperationError, operationerrfmt
+from pypy.interpreter.function import Function, StaticMethod
+from pypy.interpreter.typedef import weakref_descr
 from pypy.objspace.std.model import W_Object
 from pypy.objspace.std.register_all import register_all
-from pypy.interpreter.function import Function, StaticMethod
-from pypy.interpreter import gateway
-from pypy.interpreter.error import OperationError, operationerrfmt
-from pypy.interpreter.typedef import weakref_descr
-from pypy.interpreter.baseobjspace import W_Root
 from pypy.objspace.std.stdtypedef import std_dict_descr, issubtypedef, Member
-from pypy.objspace.std.objecttype import object_typedef
-from pypy.objspace.std import identitydict
-from rpython.rlib.objectmodel import we_are_translated
+
+from rpython.rlib.jit import (promote, elidable_promote, we_are_jitted,
+     promote_string, elidable, dont_look_inside, unroll_safe)
 from rpython.rlib.objectmodel import current_object_addr_as_int, compute_hash
-from rpython.rlib.jit import promote, elidable_promote, we_are_jitted,\
-     promote_string
-from rpython.rlib.jit import elidable, dont_look_inside, unroll_safe
 from rpython.rlib.rarithmetic import intmask, r_uint
 
+
 class TypeCell(W_Root):
     def __init__(self, w_value=None):
         self.w_value = w_value
 
+
 def unwrap_cell(space, w_value):
     if (space.config.objspace.std.withtypeversion and
             isinstance(w_value, TypeCell)):
             if attr in w_self.lazyloaders:
                 # very clever next line: it forces the attr string
                 # to be interned.
-                w_attr = space.new_interned_str(attr)
+                space.new_interned_str(attr)
                 loader = w_self.lazyloaders[attr]
                 del w_self.lazyloaders[attr]
                 w_value = loader()
 
     def get_module(w_self):
         space = w_self.space
-        if w_self.is_heaptype() and '__module__' in w_self.dict_w:
+        if w_self.is_heaptype() and w_self.getdictvalue(space, '__module__') is not None:
             return w_self.getdictvalue(space, '__module__')
         else:
             # for non-heap types, CPython checks for a module.name in the
             mod = '__builtin__'
         else:
             mod = space.str_w(w_mod)
-        if mod !='__builtin__':
+        if mod != '__builtin__':
             return '%s.%s' % (mod, w_self.name)
         else:
             return w_self.name
                 subclasses_w.append(w_ob)
         return subclasses_w
 
-
     # for now, weakref support for W_TypeObject is hard to get automatically
     _lifeline_ = None
+
     def getweakref(self):
         return self._lifeline_
+
     def setweakref(self, space, weakreflifeline):
         self._lifeline_ = weakreflifeline
+
     def delweakref(self):
         self._lifeline_ = None
 
             else:
                 create_slot(w_self, slot_name)
     wantdict = wantdict or hasoldstylebase
-    if wantdict: create_dict_slot(w_self)
-    if wantweakref: create_weakref_slot(w_self)
-    if '__del__' in dict_w: w_self.needsdel = True
+    if wantdict:
+        create_dict_slot(w_self)
+    if wantweakref:
+        create_weakref_slot(w_self)
+    if '__del__' in dict_w:
+        w_self.needsdel = True
 
 def create_slot(w_self, slot_name):
     space = w_self.space
         kind = 'type'
     else:
         kind = 'class'
-    if mod is not None and mod !='__builtin__':
+    if mod is not None and mod != '__builtin__':
         return space.wrap("<%s '%s.%s'>" % (kind, mod, w_obj.name))
     else:
         return space.wrap("<%s '%s'>" % (kind, w_obj.name))
         # __get__(None, type): turns e.g. functions into unbound methods
         return space.get(w_value, space.w_None, w_type)
     if w_descr is not None:
-        return space.get(w_descr,w_type)
+        return space.get(w_descr, w_type)
     raise operationerrfmt(space.w_AttributeError,
                           "type object '%s' has no attribute '%s'",
                           w_type.name, name)
             return mro_error(space, orderlists)  # no candidate found
         assert candidate not in order
         order.append(candidate)
-        for i in range(len(orderlists)-1, -1, -1):
+        for i in range(len(orderlists) - 1, -1, -1):
             if orderlists[i][0] is candidate:
                 del orderlists[i][0]
                 if len(orderlists[i]) == 0:
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.