Opened at 2011-10-07T02:10:00Z
Last modified at 2012-03-29T23:27:02Z
#1555 closed enhancement
add check-miscaptures.py script to check for incorrect variable captures in for loops — at Initial Version
Reported by: | davidsarah | Owned by: | somebody |
---|---|---|---|
Priority: | major | Milestone: | 1.9.2 |
Component: | code | Version: | 1.9.0a2 |
Keywords: | miscapture coding-tools review-needed | Cc: | |
Launchpad Bug: |
Description
The attached script checks for errors in which a variable declared in a for loop is captured by a lambda or function definition. If the lambda/function is executed after the loop iteration in which it was created, it will refer to some later value of the variable, which is usually not what was intended.
The script currently produces false positives if a variable is declared and used in the same lambda/function within a for loop (i.e. it is not captured). I don't intend to fix that until after the Tahoe summit in November, probably. However, it produces relatively few false positives already, and found some genuine bugs (see next ticket).