[issue44576] AttributeError: incorrect line identified in Python 3.10
Alex Hall
report at bugs.python.org
Wed Jul 7 07:38:26 EDT 2021
Alex Hall <alex.mojaki at gmail.com> added the comment:
I believe this is the outcome of https://bugs.python.org/issue39316 which I filed, so I'm pulling in . Naturally I think the new behaviour is not a bug but a feature.
I think it's more important for the traceback to show the attribute access (`two`) than the value (`one`). That's what the frame was doing at the time which led to the error.
The difference becomes even more important when calling a method with no arguments. Given this script:
class A:
def b(self):
1 / 0
x = (
A()
.b()
)
The 3.9 traceback points to the line with `A()` in the `<module>` frame, while 3.10 correctly points to `.b()`, which makes the following line 'in b' make more sense.
Where the old behaviour has really gotten to me is when I run the pycharm debugger and put a breakpoint on the .b() line and it never gets hit. Not being sure what lines 'count', I sometimes defensively put breakpoints on a cluster of lines, then spend more time removing them later. Having that fixed in 3.10 is great.
----------
components: +Interpreter Core
nosy: +Mark.Shannon, alexmojaki
type: -> behavior
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue44576>
_______________________________________
More information about the Python-bugs-list
mailing list