Author: Alex Gaynor <[email protected]>
Branch:
Changeset: r62386:701326293cc2
Date: 2013-03-17 10:58 -0700
http://bitbucket.org/pypy/pypy/changeset/701326293cc2/
Log: Small cleanup
diff --git a/pypy/interpreter/nestedscope.py b/pypy/interpreter/nestedscope.py
--- a/pypy/interpreter/nestedscope.py
+++ b/pypy/interpreter/nestedscope.py
@@ -1,11 +1,13 @@
-from pypy.interpreter.error import OperationError
-from pypy.interpreter import function, pycode, pyframe
-from pypy.interpreter.baseobjspace import Wrappable
-from pypy.interpreter.mixedmodule import MixedModule
-from pypy.interpreter.astcompiler import consts
from rpython.rlib import jit
from rpython.tool.uid import uid
+from pypy.interpreter import function, pycode, pyframe
+from pypy.interpreter.astcompiler import consts
+from pypy.interpreter.baseobjspace import Wrappable
+from pypy.interpreter.error import OperationError
+from pypy.interpreter.mixedmodule import MixedModule
+
+
class Cell(Wrappable):
"A simple container for a wrapped value."
@@ -20,7 +22,7 @@
def get(self):
if self.w_value is None:
- raise ValueError, "get() from an empty cell"
+ raise ValueError("get() from an empty cell")
return self.w_value
def set(self, w_value):
@@ -28,9 +30,9 @@
def delete(self):
if self.w_value is None:
- raise ValueError, "delete() on an empty cell"
+ raise ValueError("delete() on an empty cell")
self.w_value = None
-
+
def descr__cmp__(self, space, w_other):
other = space.interpclass_w(w_other)
if not isinstance(other, Cell):
@@ -46,10 +48,10 @@
return space.cmp(self.w_value, other.w_value)
def descr__reduce__(self, space):
- 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('cell_new')
- if self.w_value is None: #when would this happen?
+ if self.w_value is None: # when would this happen?
return space.newtuple([new_inst, space.newtuple([])])
tup = [self.w_value]
return space.newtuple([new_inst, space.newtuple([]),
@@ -57,7 +59,7 @@
def descr__setstate__(self, space, w_state):
self.w_value = space.getitem(w_state, space.wrap(0))
-
+
def __repr__(self):
""" representation for debugging purposes """
if self.w_value is None:
@@ -74,10 +76,9 @@
raise OperationError(space.w_ValueError, space.wrap("Cell is
empty"))
-
super_initialize_frame_scopes = pyframe.PyFrame.initialize_frame_scopes
-super_fast2locals = pyframe.PyFrame.fast2locals
-super_locals2fast = pyframe.PyFrame.locals2fast
+super_fast2locals = pyframe.PyFrame.fast2locals
+super_locals2fast = pyframe.PyFrame.locals2fast
class __extend__(pyframe.PyFrame):
@@ -132,7 +133,7 @@
def fast2locals(self):
super_fast2locals(self)
# cellvars are values exported to inner scopes
- # freevars are values coming from outer scopes
+ # freevars are values coming from outer scopes
freevarnames = list(self.pycode.co_cellvars)
if self.pycode.co_flags & consts.CO_OPTIMIZED:
freevarnames.extend(self.pycode.co_freevars)
@@ -197,11 +198,11 @@
except ValueError:
varname = self.getfreevarname(varindex)
if self.iscellvar(varindex):
- message = "local variable '%s' referenced before
assignment"%varname
+ message = "local variable '%s' referenced before assignment" %
varname
w_exc_type = self.space.w_UnboundLocalError
else:
message = ("free variable '%s' referenced before assignment"
- " in enclosing scope"%varname)
+ " in enclosing scope" % varname)
w_exc_type = self.space.w_NameError
raise OperationError(w_exc_type, self.space.wrap(message))
else:
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit