Message396456
Found the culprit - https://github.com/python/cpython/blob/769d7d0c66c5b86e2dd29b9ce67ac2daaab1bb38/Python/compile.c#L5268
Same goes for async with - https://github.com/python/cpython/blob/769d7d0c66c5b86e2dd29b9ce67ac2daaab1bb38/Python/compile.c#L5171
(Didn't test async with so I can be wrong there.)
Is this intentional? I removed these lines and the line number is coming correct. Can changing this affect other use cases?
Without the change:
Traceback (most recent call last):
File "C:\Users\shrey\Desktop\line_negative_one.py", line 8, in <module>
raise Exception("Normal Error")
Exception: Normal Error
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\shrey\Desktop\line_negative_one.py", line -1, in <module>
File "C:\Users\shrey\Desktop\line_negative_one.py", line 5, in __exit__
raise Exception("Frame is -1 if program is run from command line")
Exception: Frame is -1 if program is run from command line
With the change:
Traceback (most recent call last):
File "C:\Users\shrey\Desktop\line_negative_one.py", line 8, in <module>
raise Exception("Normal Error")
Exception: Normal Error
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\shrey\Desktop\line_negative_one.py", line 7, in <module>
with A():
File "C:\Users\shrey\Desktop\line_negative_one.py", line 5, in __exit__
raise Exception("Frame is -1 if program is run from command line")
Exception: Frame is not -1 anymore if program is run from command line |
|
Date |
User |
Action |
Args |
2021-06-24 07:03:44 | shreyanavigyan | set | recipients:
+ shreyanavigyan, gvanrossum, vstinner, Mark.Shannon, Anthony Sottile, pablogsal, domdfcoding |
2021-06-24 07:03:44 | shreyanavigyan | set | messageid: <1624518224.15.0.424664610893.issue44297@roundup.psfhosted.org> |
2021-06-24 07:03:44 | shreyanavigyan | link | issue44297 messages |
2021-06-24 07:03:43 | shreyanavigyan | create | |
|