Skip to content

Commit 59f36e7

Browse files
[fix] Crash when parsing an empty arbitrary expression with extract_node (#2736)
Closes #2734
1 parent 3636bc2 commit 59f36e7

File tree

3 files changed

+9
-0
lines changed

3 files changed

+9
-0
lines changed

ChangeLog

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,9 @@ What's New in astroid 3.3.11?
3737
=============================
3838
Release date: TBA
3939

40+
* Fix a crash when parsing an empty arbitrary expression with ``extract_node`` (``extract_node("__()")``).
4041

42+
Closes #2734
4143

4244
What's New in astroid 3.3.10?
4345
=============================

astroid/builder.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -317,6 +317,7 @@ def _extract_expressions(node: nodes.NodeNG) -> Iterator[nodes.NodeNG]:
317317
isinstance(node, nodes.Call)
318318
and isinstance(node.func, nodes.Name)
319319
and node.func.name == _TRANSIENT_FUNCTION
320+
and node.args
320321
):
321322
real_expr = node.args[0]
322323
assert node.parent

tests/test_regrtest.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -498,3 +498,9 @@ def _get_option(self, option):
498498
)
499499
)
500500
assert node.inferred()[0].value == "mystr"
501+
502+
503+
def test_regression_no_crash_during_build() -> None:
504+
node: nodes.Attribute = extract_node("__()")
505+
assert node.args == []
506+
assert node.as_string() == "__()"

0 commit comments

Comments
 (0)