[pypy-svn] r11651 - in pypy/dist/pypy/interpreter: . test
arigo at codespeak.net
arigo at codespeak.net
Sat Apr 30 17:04:37 CEST 2005
Author: arigo
Date: Sat Apr 30 17:04:37 2005
New Revision: 11651
Modified:
pypy/dist/pypy/interpreter/nestedscope.py
pypy/dist/pypy/interpreter/test/test_nestedscope.py
Log:
CPython's locals() also contain the variables received from outer scopes.
Modified: pypy/dist/pypy/interpreter/nestedscope.py
==============================================================================
--- pypy/dist/pypy/interpreter/nestedscope.py (original)
+++ pypy/dist/pypy/interpreter/nestedscope.py Sat Apr 30 17:04:37 2005
@@ -72,9 +72,7 @@
PyInterpFrame.fast2locals(self)
# cellvars are values exported to inner scopes
# freevars are values coming from outer scopes
- # for locals we only want the ones exported to inner-scopes
- # XXX check more exactly how CPython does it
- freevarnames = self.code.co_cellvars # + self.code.co_freevars
+ freevarnames = self.code.co_cellvars + self.code.co_freevars
for name, cell in zip(freevarnames, self.cells):
try:
w_value = cell.get()
Modified: pypy/dist/pypy/interpreter/test/test_nestedscope.py
==============================================================================
--- pypy/dist/pypy/interpreter/test/test_nestedscope.py (original)
+++ pypy/dist/pypy/interpreter/test/test_nestedscope.py Sat Apr 30 17:04:37 2005
@@ -41,7 +41,7 @@
return locals()
return g()
d = f()
- assert d == {'i':3}
+ assert d == {'i':3, 'x':3}
def test_deeply_nested_scope_locals(self):
def f():
@@ -53,5 +53,7 @@
return locals(), h()
return g()
outer_locals, inner_locals = f()
- assert inner_locals == {'i':3}
- assert len(outer_locals) == 1, "len!=1 for %r" % (outer_locals,)
+ assert inner_locals == {'i':3, 'x':3}
+ keys = outer_locals.keys()
+ keys.sort()
+ assert keys == ['h', 'x']
More information about the Pypy-commit
mailing list