Message230445
Here is yet one example.
x = 1; y = 0; z = 0
(
1/x +
1/y +
1/z
)
The traceback looks correct:
Traceback (most recent call last):
File "1.py", line 4, in <module>
1/y +
ZeroDivisionError: division by zero
But for following code:
x = 0; y = 1; z = 0
(
1/x +
1/y +
1/z
)
the traceback is the same and it is totally wrong.
This is because generated bytecode is:
1 0 LOAD_CONST 0 (0)
3 STORE_NAME 0 (x)
6 LOAD_CONST 1 (1)
9 STORE_NAME 1 (y)
12 LOAD_CONST 0 (0)
15 STORE_NAME 2 (z)
4 18 LOAD_CONST 1 (1)
21 LOAD_NAME 0 (x)
24 BINARY_TRUE_DIVIDE
25 LOAD_CONST 1 (1)
28 LOAD_NAME 1 (y)
31 BINARY_TRUE_DIVIDE
32 BINARY_ADD
5 33 LOAD_CONST 1 (1)
36 LOAD_NAME 2 (z)
39 BINARY_TRUE_DIVIDE
40 BINARY_ADD
41 POP_TOP
42 LOAD_CONST 2 (None)
45 RETURN_VALUE
1/x and 1/y have the same line number. |
|
Date |
User |
Action |
Args |
2014-11-01 10:16:18 | serhiy.storchaka | set | recipients:
+ serhiy.storchaka, georg.brandl, terry.reedy, ncoghlan, giampaolo.rodola, ezio.melotti, psss, r.david.murray, flox, lesmana, petri.lehtinen, kushal.das, icordasc, dmi.baranov, dingo_dasher |
2014-11-01 10:16:18 | serhiy.storchaka | set | messageid: <1414836978.27.0.251053108041.issue12458@psf.upfronthosting.co.za> |
2014-11-01 10:16:18 | serhiy.storchaka | link | issue12458 messages |
2014-11-01 10:16:18 | serhiy.storchaka | create | |
|