mirror of
https://github.com/python/cpython.git
synced 2025-11-01 18:51:43 +00:00
Issue2378: pdb would delete free variables when stepping into a class statement.
The problem was introduced by r53954, the correction is to restore the symmetry between PyFrame_FastToLocals and PyFrame_LocalsToFast
This commit is contained in:
parent
90d0717163
commit
e4921fec01
3 changed files with 28 additions and 3 deletions
|
|
@ -519,6 +519,24 @@ self.assert_(X.passed)
|
|||
self.assert_("x" not in varnames)
|
||||
self.assert_("y" in varnames)
|
||||
|
||||
def testLocalsClass_WithTrace(self):
|
||||
# Issue23728: after the trace function returns, the locals()
|
||||
# dictionary is used to update all variables, this used to
|
||||
# include free variables. But in class statements, free
|
||||
# variables are not inserted...
|
||||
import sys
|
||||
sys.settrace(lambda a,b,c:None)
|
||||
try:
|
||||
x = 12
|
||||
|
||||
class C:
|
||||
def f(self):
|
||||
return x
|
||||
|
||||
assert x == 12 # Used to raise UnboundLocalError
|
||||
finally:
|
||||
sys.settrace(None)
|
||||
|
||||
def testBoundAndFree(self):
|
||||
# var is bound and free in class
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue