main icon indicating copy to clipboard operation
main copied to clipboard

incorrect generator variable scope

Open ironpythonbot opened this issue 11 years ago • 2 comments

IronPython 2.7.2.1 fails the attached IronPythonTestCase.test_generator_scope test.

$ ipy -m testipy IronPythonTestCase.test_generator_scope

E

ERROR: test_generator_scope ( ** main ** .IronPythonTestCase)

Test the scopes of the variables in a nested generator.

Traceback (most recent call last):
File "Z:\Developer\qmdl_test\lib\testipy.py", line 50, in test_generator_scope

columns = {row['column_name']: row['data_type'].lower()

File "Z:\Developer\qmdl_test\lib\testipy.py", line 53, in

any(p.lower() in row['column_name'].lower()

NameError: global name 'row' is not defined

Ran 1 test in 0.219s

FAILED (errors=1)

Work Item Details

Original CodePlex Issue: Issue 32465 Status: Proposed Reason Closed: Unassigned Assigned to: Unassigned Reported on: Mar 20, 2012 at 5:17 PM Reported by: jonathanhiga Updated on: Feb 22, 2013 at 2:09 AM Updated by: jonathanhiga

Plaintext Attachments

CodePlex Issue #32465 Plain Text Attachments

ironpythonbot avatar Dec 09 '14 18:12 ironpythonbot

On 2012-03-21 04:22:10 UTC, jonathanhiga commented:

Interactive summary:

IronPython 2.7.2.1 (2.7.0.40) on .NET 4.0.30319.239 (32-bit) Type "help", "copyright", "credits" or "license" for more information.

metadata = [{'column_name': 'splunge', 'data_type': 'varchar(128)'}] patterns = ['lunge'] columns = {row['column_name']: row['data_type'].lower() ... for row in metadata ... if patterns is None or ... any(p.lower() in row['column_name'].lower() ... for p in patterns)} Traceback (most recent call last): File "", line 1, in File "", line 4, in NameError: global name 'row' is not defined

ironpythonbot avatar Dec 09 '14 18:12 ironpythonbot

stuff = ["a", "b", "c"]

x = None
tmp = [x for x in stuff if any(x is None for _ in stuff)]
assert x == "c"
assert not tmp

x = None
tmp = {x: True for x in stuff if any(x is None for _ in stuff)}
assert x is None
assert not tmp

slozier avatar Nov 16 '16 22:11 slozier