Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 1654d74

Browse files
committed
switch assertion to an explicit ValueError
1 parent a820c7c commit 1654d74

2 files changed

Lines changed: 3 additions & 3 deletions

File tree

Lib/lib2to3/fixer_util.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -274,9 +274,9 @@ def find_root(node):
274274
"""Find the top level namespace."""
275275
# Scamper up to the top level namespace
276276
while node.type != syms.file_input:
277-
assert node.parent, "Tree is insane! root found before "\
278-
"file_input node was found."
279277
node = node.parent
278+
if not node:
279+
raise ValueError("root found before file_input node was found.")
280280
return node
281281

282282
def does_tree_import(package, name, node):

Lib/lib2to3/refactor.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -445,7 +445,7 @@ def refactor_tree(self, tree, name):
445445

446446
try:
447447
find_root(node)
448-
except AssertionError:
448+
except ValueError:
449449
# this node has been cut off from a
450450
# previous transformation ; skip
451451
continue

0 commit comments

Comments
 (0)