[Python-checkins] cpython (2.7): switch assertion to an explicit ValueError

benjamin.peterson python-checkins at python.org
Tue Sep 25 17:54:21 CEST 2012


http://hg.python.org/cpython/rev/fd9ffd10f1c7
changeset: 79178:fd9ffd10f1c7
branch: 2.7
parent: 79165:b624059a8dac
user: Benjamin Peterson <benjamin at python.org>
date: Tue Sep 25 11:48:50 2012 -0400
summary:
 switch assertion to an explicit ValueError
files:
 Lib/lib2to3/fixer_util.py | 4 ++--
 Lib/lib2to3/refactor.py | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/Lib/lib2to3/fixer_util.py b/Lib/lib2to3/fixer_util.py
--- a/Lib/lib2to3/fixer_util.py
+++ b/Lib/lib2to3/fixer_util.py
@@ -274,9 +274,9 @@
 """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
--- a/Lib/lib2to3/refactor.py
+++ b/Lib/lib2to3/refactor.py
@@ -445,7 +445,7 @@
 
 try:
 find_root(node)
- except AssertionError:
+ except ValueError:
 # this node has been cut off from a
 # previous transformation ; skip
 continue
-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list

AltStyle によって変換されたページ (->オリジナル) /