bpo-40726: handle uninitalized end_lineno on ast.increment_lineno#20312
bpo-40726: handle uninitalized end_lineno on ast.increment_lineno#20312pablogsal merged 2 commits intopython:masterfrom
Conversation
|
I think this also needs some treatment: Lines 180 to 184 in c102a14 |
|
Hi @isidentical, thanks for fixing this. It seems to me that if all nodes have all their attributes defined, the calls to if (
"end_lineno" in child._attributes
and (end_lineno := getattr(child, "end_lineno", 0)) is not None
):
child.end_lineno = end_lineno + ncould be if child.end_lineno is not None:
child.end_lineno += n? |
Sorry, but I couldn't catch the reason. There is already a verification for Lines 183 to 184 in c102a14
That is just the current implementation, and in theory it might not exist at all as-well, which would prevent us from backporting this patch to 3.8 as it is. |
Sorry, I should have been more verbose. I know this is not a real-world use case, but here's an example: In the end, the value of |
Oh, this is an interesting case. Nice catch! |
7ab5685 to
2444b63
Compare
|
I can confirm that this does fix xonsh/xonsh#3581. |
|
Is this planed to get merged for v3.9.0? This currently blocks Python 3.9 adoption in Xonsh. |
|
Thanks @isidentical for the PR, and @pablogsal for merging it 🌮🎉.. I'm working now to backport this PR to: 3.8, 3.9. |
|
GH-21741 is a backport of this pull request to the 3.9 branch. |
…thonGH-20312) (cherry picked from commit 8f4380d) Co-authored-by: Batuhan Taskaya <batuhanosmantaskaya@gmail.com>
|
Sorry, @isidentical and @pablogsal, I could not cleanly backport this to |
|
GH-21742 is a backport of this pull request to the 3.8 branch. |
|
Thanks @pablogsal! |
…no (pythonGH-20312). (cherry picked from commit 8f4380d) Co-authored-by: Batuhan Taskaya <batuhanosmantaskaya@gmail.com>
…no (pythonGH-20312). (cherry picked from commit 8f4380d) Co-authored-by: Batuhan Taskaya <batuhanosmantaskaya@gmail.com>
…no (GH-21745) …no (GH-20312). (cherry picked from commit 8f4380d) Co-authored-by: Batuhan Taskaya <batuhanosmantaskaya@gmail.com> Automerge-Triggered-By: @pablogsal
|
Thanks @isidentical for the PR, and @pablogsal for merging it 🌮🎉.. I'm working now to backport this PR to: 3.9. |
|
Sorry, @isidentical and @pablogsal, I could not cleanly backport this to |
|
Ah, never mind, #21741 is the backport that's already merged. |
end_linenois declared as an optional attribute on the ASDL spec. This patch makesincrement_linenoaware that node'send_linenomight beNone.https://bugs.python.org/issue40726