[Python-checkins] r67405 - sandbox/trunk/2to3/lib2to3/pytree.py
benjamin.peterson
python-checkins at python.org
Wed Nov 26 21:01:24 CET 2008
Author: benjamin.peterson
Date: Wed Nov 26 21:01:24 2008
New Revision: 67405
Log:
stop ugly messages about runtime errors being ignored
Modified:
sandbox/trunk/2to3/lib2to3/pytree.py
Modified: sandbox/trunk/2to3/lib2to3/pytree.py
==============================================================================
--- sandbox/trunk/2to3/lib2to3/pytree.py (original)
+++ sandbox/trunk/2to3/lib2to3/pytree.py Wed Nov 26 21:01:24 2008
@@ -11,6 +11,9 @@
__author__ = "Guido van Rossum <guido at python.org>"
+import sys
+from StringIO import StringIO
+
HUGE = 0x7FFFFFFF # maximum repeat count, default max
@@ -655,6 +658,11 @@
elif self.name == "bare_name":
yield self._bare_name_matches(nodes)
else:
+ # The reason for this is that hitting the recursion limit usually
+ # results in some ugly messages about how RuntimeErrors are being
+ # ignored.
+ save_stderr = sys.stderr
+ sys.stderr = StringIO()
try:
for count, r in self._recursive_matches(nodes, 0):
if self.name:
@@ -667,6 +675,8 @@
if self.name:
r[self.name] = nodes[:count]
yield count, r
+ finally:
+ sys.stderr = save_stderr
def _iterative_matches(self, nodes):
"""Helper to iteratively yield the matches."""
More information about the Python-checkins
mailing list