You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* Update `test_call.py` from 3.13.7
* Update `test_yield_from.py` from 3.13.7
* Update more tests to 3.13.7
* More tests to 3.13.7
* Remove patch from passing test
Copy file name to clipboardExpand all lines: Lib/test/test_scope.py
+76-4Lines changed: 76 additions & 4 deletions
Original file line number
Diff line number
Diff line change
@@ -177,6 +177,57 @@ def bar():
177
177
self.assertEqual(foo(a=42), 50)
178
178
self.assertEqual(foo(), 25)
179
179
180
+
deftestCellIsArgAndEscapes(self):
181
+
# We need to be sure that a cell passed in as an arg still
182
+
# gets wrapped in a new cell if the arg escapes into an
183
+
# inner function (closure).
184
+
185
+
defexternal():
186
+
value=42
187
+
definner():
188
+
returnvalue
189
+
cell, =inner.__closure__
190
+
returncell
191
+
cell_ext=external()
192
+
193
+
defspam(arg):
194
+
defeggs():
195
+
returnarg
196
+
returneggs
197
+
198
+
eggs=spam(cell_ext)
199
+
cell_closure, =eggs.__closure__
200
+
cell_eggs=eggs()
201
+
202
+
self.assertIs(cell_eggs, cell_ext)
203
+
self.assertIsNot(cell_eggs, cell_closure)
204
+
205
+
deftestCellIsLocalAndEscapes(self):
206
+
# We need to be sure that a cell bound to a local still
207
+
# gets wrapped in a new cell if the local escapes into an
208
+
# inner function (closure).
209
+
210
+
defexternal():
211
+
value=42
212
+
definner():
213
+
returnvalue
214
+
cell, =inner.__closure__
215
+
returncell
216
+
cell_ext=external()
217
+
218
+
defspam(arg):
219
+
cell=arg
220
+
defeggs():
221
+
returncell
222
+
returneggs
223
+
224
+
eggs=spam(cell_ext)
225
+
cell_closure, =eggs.__closure__
226
+
cell_eggs=eggs()
227
+
228
+
self.assertIs(cell_eggs, cell_ext)
229
+
self.assertIsNot(cell_eggs, cell_closure)
230
+
180
231
deftestRecursion(self):
181
232
182
233
deff(x):
@@ -641,10 +692,7 @@ def dec(self):
641
692
self.assertEqual(c.dec(), 1)
642
693
self.assertEqual(c.dec(), 0)
643
694
644
-
# TODO: RUSTPYTHON, figure out how to communicate that `y = 9` should be
645
-
# stored as a global rather than a STORE_NAME, even when
646
-
# the `global y` is in a nested subscope
647
-
@unittest.expectedFailure
695
+
@unittest.expectedFailure# TODO: RUSTPYTHON; figure out how to communicate that `y = 9` should be stored as a global rather than a STORE_NAME, even when the `global y` is in a nested subscope
648
696
deftestGlobalInParallelNestedFunctions(self):
649
697
# A symbol table bug leaked the global statement from one
650
698
# function to other nested functions in the same block.
@@ -763,6 +811,30 @@ def dig(self):
763
811
gc_collect() # For PyPy or other GCs.
764
812
self.assertIsNone(ref())
765
813
814
+
deftest_multiple_nesting(self):
815
+
# Regression test for https://github.com/python/cpython/issues/121863
0 commit comments