Commit ba66c228 authored by Benjamin Peterson's avatar Benjamin Peterson

switch assertion to an explicit ValueError

parent 0dea936e
...@@ -274,9 +274,9 @@ def find_root(node): ...@@ -274,9 +274,9 @@ def find_root(node):
"""Find the top level namespace.""" """Find the top level namespace."""
# Scamper up to the top level namespace # Scamper up to the top level namespace
while node.type != syms.file_input: while node.type != syms.file_input:
assert node.parent, "Tree is insane! root found before "\
"file_input node was found."
node = node.parent node = node.parent
if not node:
raise ValueError("root found before file_input node was found.")
return node return node
def does_tree_import(package, name, node): def does_tree_import(package, name, node):
......
...@@ -445,7 +445,7 @@ class RefactoringTool(object): ...@@ -445,7 +445,7 @@ class RefactoringTool(object):
try: try:
find_root(node) find_root(node)
except AssertionError: except ValueError:
# this node has been cut off from a # this node has been cut off from a
# previous transformation ; skip # previous transformation ; skip
continue continue
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment