This issue tracker has been migrated to GitHub ,
and is currently read-only.
For more information,
see the GitHub FAQs in the Python's Developer Guide.
| Author | belopolsky |
|---|---|
| Recipients | amaury.forgeotdarc, belopolsky, nedbat |
| Date | 2008年03月29日.18:25:16 |
| SpamBayes Score | 0.0019030201 |
| Marked as misclassified | No |
| Message-id | <1206815117.79.0.709308031464.issue2506@psf.upfronthosting.co.za> |
| In-reply-to |
| Content | |
|---|---|
I think this is not a bug. Here is a simpler way to illustrate the issue: def f(x): for i in range(10): if x: pass continue f(True) f(False) If you run the code above under trace, you get the following coverage: 1: def f(x): 22: for i in range(10): 20: if x: 10: pass 10: continue 1: f(True) 1: f(False) Note that the 'continue' line is executed 10 instead of expected 20 times. This happens exactly as Amaury explained. If you disassemble f, you'll see 2 0 SETUP_LOOP 34 (to 37) 3 LOAD_GLOBAL 0 (range) 6 LOAD_CONST 1 (10) 9 CALL_FUNCTION 1 12 GET_ITER >> 13 FOR_ITER 20 (to 36) 16 STORE_FAST 1 (i) 3 19 LOAD_FAST 0 (x) 22 JUMP_IF_FALSE 4 (to 29) 25 POP_TOP 4 26 JUMP_ABSOLUTE 13 >> 29 POP_TOP 5 30 JUMP_ABSOLUTE 13 33 JUMP_ABSOLUTE 13 >> 36 POP_BLOCK >> 37 LOAD_CONST 0 (None) 40 RETURN_VALUE Note how peephole optimizer replaced jump to the 'continue' line (5) from the 'pass' line (4) with a jump to the 'for' line by replacing 4 26 JUMP_FORWARD 1 (to 30) with 4 26 JUMP_ABSOLUTE 13 I say this is not a bug because trace is correct in showing that the continue statement is never reached when executing f(True). |
|
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2008年03月29日 18:25:18 | belopolsky | set | spambayes_score: 0.00190302 -> 0.0019030201 recipients: + belopolsky, amaury.forgeotdarc, nedbat |
| 2008年03月29日 18:25:17 | belopolsky | set | spambayes_score: 0.00190302 -> 0.00190302 messageid: <1206815117.79.0.709308031464.issue2506@psf.upfronthosting.co.za> |
| 2008年03月29日 18:25:16 | belopolsky | link | issue2506 messages |
| 2008年03月29日 18:25:16 | belopolsky | create | |