summaryrefslogtreecommitdiff
path: root/astroid/builder.py
diff options
context:
space:
mode:
authorClaudiu Popa <pcmanticore@gmail.com>2018-06-09 16:56:56 -0700
committerClaudiu Popa <pcmanticore@gmail.com>2018-06-09 16:56:56 -0700
commitb9438ecf6c992094ff1148cd0a19fb667aeace8f (patch)
treea943d7bb2910b58b4b0d1372fe419f9ebf348a12 /astroid/builder.py
parent2c14c822d53087aa131c9fc2e14562d95577cdc7 (diff)
downloadastroid-git-b9438ecf6c992094ff1148cd0a19fb667aeace8f.tar.gz
Raise a ValueError if there's no body to extract from in extract_node()
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]