Author: Alex Gaynor <[email protected]>
Branch:
Changeset: r61722:3d86bb843b94
Date: 2013-02-23 18:30 -0800
http://bitbucket.org/pypy/pypy/changeset/3d86bb843b94/
Log: more pep8
diff --git a/rpython/flowspace/flowcontext.py b/rpython/flowspace/flowcontext.py
--- a/rpython/flowspace/flowcontext.py
+++ b/rpython/flowspace/flowcontext.py
@@ -9,11 +9,12 @@
from rpython.tool.stdlib_opcode import host_bytecode_spec
from rpython.flowspace.argument import ArgumentsForTranslation
from rpython.flowspace.model import (Constant, Variable, Block, Link,
- UnwrapException, c_last_exception)
+ c_last_exception)
from rpython.flowspace.framestate import (FrameState, recursively_unflatten,
- recursively_flatten)
+ recursively_flatten)
from rpython.flowspace.specialcase import (rpython_print_item,
- rpython_print_newline)
+ rpython_print_newline)
+
class FlowingError(Exception):
""" Signals invalid RPython in the function being analysed"""
@@ -107,13 +108,12 @@
# ____________________________________________________________
-class Recorder:
-
+class Recorder(object):
def append(self, operation):
raise NotImplementedError
def guessbool(self, frame, w_condition, **kwds):
- raise AssertionError, "cannot guessbool(%s)" % (w_condition,)
+ raise AssertionError("cannot guessbool(%s)" % (w_condition,))
class BlockRecorder(Recorder):
@@ -212,11 +212,13 @@
# ____________________________________________________________
-_unary_ops = [('UNARY_POSITIVE', "pos"),
+_unary_ops = [
+ ('UNARY_POSITIVE', "pos"),
('UNARY_NEGATIVE', "neg"),
('UNARY_NOT', "not_"),
('UNARY_CONVERT', "repr"),
- ('UNARY_INVERT', "invert"),]
+ ('UNARY_INVERT', "invert"),
+]
def unaryoperation(OPCODE, op):
def UNARY_OP(self, *ignored):
@@ -382,7 +384,7 @@
n -= 1
if n < 0:
break
- values_w[n] = self.locals_stack_w[base+n]
+ values_w[n] = self.locals_stack_w[base + n]
return values_w
def dropvalues(self, n):
@@ -564,7 +566,7 @@
def replace_in_stack(self, oldvalue, newvalue):
w_new = Constant(newvalue)
stack_items_w = self.locals_stack_w
- for i in range(self.valuestackdepth-1, self.pycode.co_nlocals-1, -1):
+ for i in range(self.valuestackdepth - 1, self.pycode.co_nlocals - 1,
-1):
w_v = stack_items_w[i]
if isinstance(w_v, Constant):
if w_v.value is oldvalue:
@@ -665,9 +667,9 @@
raise FSException(space.w_TypeError,
space.wrap("raise: no active exception to re-raise"))
- w_value = w_traceback = space.w_None
+ w_value = space.w_None
if nbargs >= 3:
- w_traceback = self.popvalue()
+ self.popvalue()
if nbargs >= 2:
w_value = self.popvalue()
if 1:
@@ -960,7 +962,7 @@
def call_function(self, oparg, w_star=None, w_starstar=None):
n_arguments = oparg & 0xff
- n_keywords = (oparg>>8) & 0xff
+ n_keywords = (oparg >> 8) & 0xff
if n_keywords:
keywords = [None] * n_keywords
keywords_w = [None] * n_keywords
@@ -979,7 +981,7 @@
arguments = self.popvalues(n_arguments)
args = ArgumentsForTranslation(self.space, arguments, keywords,
keywords_w, w_star, w_starstar)
- w_function = self.popvalue()
+ w_function = self.popvalue()
w_result = self.space.call_args(w_function, args)
self.pushvalue(w_result)
@@ -1193,6 +1195,7 @@
"""Signals a 'return' statement.
Argument is the wrapped object to return."""
kind = 0x01
+
def __init__(self, w_returnvalue):
self.w_returnvalue = w_returnvalue
@@ -1210,6 +1213,7 @@
"""Signals an application-level exception
(i.e. an OperationException)."""
kind = 0x02
+
def __init__(self, operr):
self.operr = operr
@@ -1240,6 +1244,7 @@
"""Signals a 'continue' statement.
Argument is the bytecode position of the beginning of the loop."""
kind = 0x08
+
def __init__(self, jump_to):
self.jump_to = jump_to
diff --git a/rpython/flowspace/generator.py b/rpython/flowspace/generator.py
--- a/rpython/flowspace/generator.py
+++ b/rpython/flowspace/generator.py
@@ -1,12 +1,11 @@
"""Flow graph building for generators"""
-from rpython.flowspace.model import Block, Link, SpaceOperation, checkgraph
-from rpython.flowspace.model import Variable, Constant
-from rpython.translator.unsimplify import insert_empty_startblock
-from rpython.translator.unsimplify import split_block
+from rpython.flowspace.argument import Signature
+from rpython.flowspace.model import (Block, Link, SpaceOperation, Variable,
+ Constant, checkgraph)
+from rpython.translator.unsimplify import insert_empty_startblock, split_block
from rpython.translator.simplify import eliminate_empty_blocks, simplify_graph
from rpython.tool.sourcetools import func_with_new_name
-from rpython.flowspace.argument import Signature
class AbstractPosition(object):
@@ -113,7 +112,8 @@
mappings = [Entry]
#
stopblock = Block([])
- v0 = Variable(); v1 = Variable()
+ v0 = Variable()
+ v1 = Variable()
stopblock.operations = [
SpaceOperation('simple_call', [Constant(StopIteration)], v0),
SpaceOperation('type', [v0], v1),
diff --git a/rpython/flowspace/model.py b/rpython/flowspace/model.py
--- a/rpython/flowspace/model.py
+++ b/rpython/flowspace/model.py
@@ -4,6 +4,7 @@
# the below object/attribute model evolved from
# a discussion in Berlin, 4th of october 2003
import py
+
from rpython.tool.uid import uid, Hashable
from rpython.tool.sourcetools import PY_IDENTIFIER, nice_repr_for_func
from rpython.rlib.rarithmetic import is_valid_int, r_longlong, r_ulonglong,
r_uint
@@ -180,9 +181,9 @@
class Block(object):
__slots__ = """inputargs operations exitswitch
exits blockcolor""".split()
-
+
def __init__(self, inputargs):
- self.inputargs = list(inputargs) # mixed list of variable/const XXX
+ self.inputargs = list(inputargs) # mixed list of variable/const XXX
self.operations = [] # list of SpaceOperation(s)
self.exitswitch = None # a variable or
# Constant(last_exception), see
below
@@ -205,7 +206,7 @@
else:
txt = "codeless block"
return txt
-
+
def __repr__(self):
txt = "%s with %d exits" % (str(self), len(self.exits))
if self.exitswitch:
@@ -241,7 +242,7 @@
def closeblock(self, *exits):
assert self.exits == [], "block already closed"
self.recloseblock(*exits)
-
+
def recloseblock(self, *exits):
for exit in exits:
exit.prevblock = self
@@ -274,7 +275,7 @@
def renamed(self):
return self._name is not self.dummyname
renamed = property(renamed)
-
+
def __init__(self, name=None):
self._name = self.dummyname
self._nr = -1
@@ -341,7 +342,7 @@
self.offset = offset # offset in code string
def __eq__(self, other):
- return (self.__class__ is other.__class__ and
+ return (self.__class__ is other.__class__ and
self.opname == other.opname and
self.args == other.args and
self.result == other.result)
diff --git a/rpython/flowspace/specialcase.py b/rpython/flowspace/specialcase.py
--- a/rpython/flowspace/specialcase.py
+++ b/rpython/flowspace/specialcase.py
@@ -20,8 +20,8 @@
elif opname == 'getattr' and len(args_w) == 3:
return space.do_operation('simple_call', Constant(getattr),
*args_w)
else:
- raise Exception, "should call %r with exactly %d arguments" % (
- fn, Arity[opname])
+ raise Exception("should call %r with exactly %d arguments" % (
+ fn, Arity[opname]))
# completely replace the call with the underlying
# operation and its limited implicit exceptions semantic
return getattr(space, opname)(*args_w)
@@ -79,4 +79,3 @@
locals: sc_locals}
for fn in OperationName:
SPECIAL_CASES[fn] = sc_operator
-
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit