[Python-checkins] r57922 - sandbox/trunk/2to3/refactor.py

collin.winter python-checkins at python.org
Mon Sep 3 08:23:25 CEST 2007


Author: collin.winter
Date: Mon Sep  3 08:23:25 2007
New Revision: 57922

Modified:
   sandbox/trunk/2to3/refactor.py
Log:
Fix a bug in refactor.py where parse errors would cause fatal exceptions.

Modified: sandbox/trunk/2to3/refactor.py
==============================================================================
--- sandbox/trunk/2to3/refactor.py	(original)
+++ sandbox/trunk/2to3/refactor.py	Mon Sep  3 08:23:25 2007
@@ -225,7 +225,7 @@
                 self.log_message("No doctest changes in %s", filename)
         else:
             tree = self.refactor_string(input, filename)
-            if tree.was_changed:
+            if tree and tree.was_changed:
                 self.write_file(str(tree), filename)
             elif self.options.verbose:
                 self.log_message("No changes in %s", filename)
@@ -273,7 +273,7 @@
                 self.log_message("No doctest changes in stdin")
         else:
             tree = self.refactor_string(input, "<stdin>")
-            if tree.was_changed:
+            if tree and tree.was_changed:
                 self.write_file(str(tree), "<stdin>", input)
             elif self.options.verbose:
                 self.log_message("No changes in stdin")


More information about the Python-checkins mailing list