Benjamin Peterson  committed fdd70fa

switch assertion to an explicit ValueError

  • Participants
  • Parent commits 6bd658a
  • Branches 3.2

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