summaryrefslogtreecommitdiff
path: root/astroid/builder.py
diff options
context:
space:
mode:
Diffstat (limited to 'astroid/builder.py')
-rw-r--r--astroid/builder.py3
1 files changed, 3 insertions, 0 deletions
diff --git a/astroid/builder.py b/astroid/builder.py
index dec83674..549379a7 100644
--- a/astroid/builder.py
+++ b/astroid/builder.py
@@ -389,6 +389,9 @@ def extract_node(code, module_name=''):
requested_lines.append(idx + 1)
tree = parse(code, module_name=module_name)
+ if not tree.body:
+ raise ValueError('Empty tree, cannot extract from it')
+
extracted = []
if requested_lines:
extracted = [_find_statement_by_line(tree, line) for line in requested_lines]