Skip to content

Add Py3k warning for list comprehension target rebinding and regression test#45

Open
Eddy114514 wants to merge 3 commits intosoftdevteam:migrationfrom
Eddy114514:listcomp_new
Open

Add Py3k warning for list comprehension target rebinding and regression test#45
Eddy114514 wants to merge 3 commits intosoftdevteam:migrationfrom
Eddy114514:listcomp_new

Conversation

@Eddy114514
Copy link
Collaborator

List comprehensions that rebind an outer name (e.g. x in [x = ...; [x for x in ...]] can cause 2.x vs 3.x behavior differences. Specifically, in python 2, it will rebind the outer variable, but in 3.x, it will not.

I added a symbol-table check in symtable.c to detect listcomp target rebinding and emit the warning. I add test in test_grammer.py and it passed on my local machine.

return 1;
}

static int
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AFAICS the return int is either 0 or 1 so a bool in disguise? I'm not sure what true/false mean here though: there was/wasn't an error?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants