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 serhiy.storchaka
Recipients dingo_dasher, dmi.baranov, ezio.melotti, flox, georg.brandl, giampaolo.rodola, icordasc, kushal.das, lesmana, ncoghlan, petri.lehtinen, psss, r.david.murray, serhiy.storchaka, terry.reedy
Date 2014-11-01.10:16:18
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1414836978.27.0.251053108041.issue12458@psf.upfronthosting.co.za>
In-reply-to
Content
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.
History
Date User Action Args
2014-11-01 10:16:18serhiy.storchakasetrecipients: + 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:18serhiy.storchakasetmessageid: <1414836978.27.0.251053108041.issue12458@psf.upfronthosting.co.za>
2014-11-01 10:16:18serhiy.storchakalinkissue12458 messages
2014-11-01 10:16:18serhiy.storchakacreate