Author: Philip Jenvey <pjen...@underboss.org>
Branch: 
Changeset: r74314:3d31d50cab83
Date: 2014-10-31 11:25 -0700
http://bitbucket.org/pypy/pypy/changeset/3d31d50cab83/

Log:    cleanup

diff --git a/pypy/objspace/std/formatting.py b/pypy/objspace/std/formatting.py
--- a/pypy/objspace/std/formatting.py
+++ b/pypy/objspace/std/formatting.py
@@ -1,15 +1,15 @@
-"""
-String formatting routines.
-"""
+"""String formatting routines"""
 import sys
-from pypy.interpreter.error import OperationError, oefmt
+
 from rpython.rlib import jit
-from rpython.rlib.rfloat import formatd, DTSF_ALT, isnan, isinf
+from rpython.rlib.rarithmetic import INT_MAX
+from rpython.rlib.rfloat import DTSF_ALT, formatd, isnan, isinf
 from rpython.rlib.rstring import StringBuilder, UnicodeBuilder
 from rpython.rlib.unroll import unrolling_iterable
-from rpython.rlib.rarithmetic import INT_MAX
 from rpython.tool.sourcetools import func_with_new_name
 
+from pypy.interpreter.error import OperationError, oefmt
+
 
 class BaseStringFormatter(object):
     def __init__(self, space, values_w, w_valuedict):
diff --git a/pypy/objspace/std/objectobject.py 
b/pypy/objspace/std/objectobject.py
--- a/pypy/objspace/std/objectobject.py
+++ b/pypy/objspace/std/objectobject.py
@@ -1,7 +1,10 @@
+"""The builtin object type implementation"""
+
 from pypy.interpreter.baseobjspace import W_Root
 from pypy.interpreter.error import OperationError, oefmt
 from pypy.interpreter.gateway import applevel, interp2app, unwrap_spec
-from pypy.interpreter.typedef import GetSetProperty, default_identity_hash, 
TypeDef
+from pypy.interpreter.typedef import (
+    GetSetProperty, TypeDef, default_identity_hash)
 from pypy.objspace.descroperation import Object
 
 
@@ -25,7 +28,7 @@
     else:
         args = getnewargs()
         if not isinstance(args, tuple):
-            raise TypeError, "__getnewargs__ should return a tuple"
+            raise TypeError("__getnewargs__ should return a tuple")
 
     try:
         getstate = obj.__getstate__
@@ -46,15 +49,8 @@
     else:
         state = getstate()
 
-    if isinstance(obj, list):
-        listitems = iter(obj)
-    else:
-        listitems = None
-
-    if isinstance(obj, dict):
-        dictitems = obj.iteritems()
-    else:
-        dictitems = None
+    listitems = iter(obj) if isinstance(obj, list) else None
+    dictitems = obj.iteritems() if isinstance(obj, dict) else None
 
     import copy_reg
     newobj = copy_reg.__newobj__
@@ -74,7 +70,7 @@
     import copy_reg
     slotnames = copy_reg._slotnames(cls)
     if not isinstance(slotnames, list) and slotnames is not None:
-        raise TypeError, "copy_reg._slotnames didn't return a list or None"
+        raise TypeError("copy_reg._slotnames didn't return a list or None")
     return slotnames
 ''', filename=__file__)
 
@@ -94,14 +90,13 @@
     # don't allow arguments if the default object.__init__() is about
     # to be called
     w_type = _precheck_for_new(space, w_type)
-    w_parentinit, w_ignored = w_type.lookup_where('__init__')
+    w_parentinit, _ = w_type.lookup_where('__init__')
     if w_parentinit is space.w_object:
         try:
             __args__.fixedunpack(0)
         except ValueError:
-            raise OperationError(space.w_TypeError,
-                                 space.wrap("default __new__ takes "
-                                            "no parameters"))
+            raise oefmt(space.w_TypeError,
+                        "default __new__ takes no parameters")
     if w_type.is_abstract():
         _abstract_method_error(space, w_type)
     w_obj = space.allocate_instance(W_ObjectObject, w_type)
@@ -120,8 +115,8 @@
         try:
             __args__.fixedunpack(0)
         except ValueError:
-            raise OperationError(space.w_TypeError,
-                space.wrap("object.__init__() takes no parameters"))
+            raise oefmt(space.w_TypeError,
+                        "object.__init__() takes no parameters")
 
 
 def descr_get___class__(space, w_obj):
@@ -135,11 +130,12 @@
                     "__class__ must be set to new-style class, not '%T' "
                     "object", w_newcls)
     if not w_newcls.is_heaptype():
-        raise OperationError(space.w_TypeError,
-                             space.wrap("__class__ assignment: only for heap 
types"))
+        raise oefmt(space.w_TypeError,
+                    "__class__ assignment: only for heap types")
     w_oldcls = space.type(w_obj)
     assert isinstance(w_oldcls, W_TypeObject)
-    if w_oldcls.get_full_instance_layout() == 
w_newcls.get_full_instance_layout():
+    if (w_oldcls.get_full_instance_layout() ==
+        w_newcls.get_full_instance_layout()):
         w_obj.setclass(space, w_newcls)
     else:
         raise oefmt(space.w_TypeError,
@@ -167,8 +163,8 @@
     w_type = space.type(w_obj)
     w_impl = w_type.lookup("__repr__")
     if w_impl is None:
-        raise OperationError(space.w_TypeError,      # can it really occur?
-                             space.wrap("operand does not support unary str"))
+        # can it really occur?
+        raise oefmt(space.w_TypeError, "operand does not support unary str")
     return space.get_and_call_function(w_impl, w_obj)
 
 
diff --git a/pypy/objspace/std/util.py b/pypy/objspace/std/util.py
--- a/pypy/objspace/std/util.py
+++ b/pypy/objspace/std/util.py
@@ -1,6 +1,7 @@
-from pypy.interpreter.error import oefmt, OperationError
 from rpython.rlib.rstring import InvalidBaseError
 
+from pypy.interpreter.error import OperationError, oefmt
+
 
 IDTAG_INT     = 1
 IDTAG_LONG    = 3
_______________________________________________
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to