]> granicus.if.org Git - python/commitdiff
switch assertion to an explicit ValueError
authorBenjamin Peterson <benjamin@python.org>
Tue, 25 Sep 2012 15:48:50 +0000 (11:48 -0400)
committerBenjamin Peterson <benjamin@python.org>
Tue, 25 Sep 2012 15:48:50 +0000 (11:48 -0400)
Lib/lib2to3/fixer_util.py
Lib/lib2to3/refactor.py

index 30da8937118340a28d9c6c6126adedfd7e41aa23..350a62ad08d8ae72ef42b6ecdf1f37e22158bd8c 100644 (file)
@@ -274,9 +274,9 @@ def find_root(node):
     """Find the top level namespace."""
     # Scamper up to the top level namespace
     while node.type != syms.file_input:
-        assert node.parent, "Tree is insane! root found before "\
-                           "file_input node was found."
         node = node.parent
+        if not node:
+            raise ValueError("root found before file_input node was found.")
     return node
 
 def does_tree_import(package, name, node):
index badcac2fc73518e72662e177d7d504361cc2d236..a4c168df9e0dd435a9e2cc9980ed219aa00f3a2a 100644 (file)
@@ -445,7 +445,7 @@ class RefactoringTool(object):
 
                         try:
                             find_root(node)
-                        except AssertionError:
+                        except ValueError:
                             # this node has been cut off from a
                             # previous transformation ; skip
                             continue