From: Benjamin Peterson Date: Tue, 25 Sep 2012 15:48:50 +0000 (-0400) Subject: switch assertion to an explicit ValueError X-Git-Tag: v3.2.4rc1~493 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=1654d74e9a6250491bfb923424c4cf83af2af7a6;p=thirdparty%2FPython%2Fcpython.git switch assertion to an explicit ValueError --- diff --git a/Lib/lib2to3/fixer_util.py b/Lib/lib2to3/fixer_util.py index 92f0da951620..2b5bb1dfd27c 100644 --- a/Lib/lib2to3/fixer_util.py +++ b/Lib/lib2to3/fixer_util.py @@ -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): diff --git a/Lib/lib2to3/refactor.py b/Lib/lib2to3/refactor.py index 7cd034a26958..38fb8ed9e22a 100644 --- a/Lib/lib2to3/refactor.py +++ b/Lib/lib2to3/refactor.py @@ -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