Benjamin Peterson  committed fd9ffd1

switch assertion to an explicit ValueError

  • Participants
  • Parent commits b624059
  • Branches 2.7

Comments (0)

Files changed (2)

File Lib/lib2to3/

     """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):

File Lib/lib2to3/

-                        except AssertionError:
+                        except ValueError:
                             # this node has been cut off from a
                             # previous transformation ; skip