[Python-checkins] (merge 3.1 -> default): merge 3.1

benjamin.peterson python-checkins at python.org
Mon Mar 7 00:15:40 CET 2011


http://hg.python.org/cpython/rev/6a7c312cc3ff
changeset: 68311:6a7c312cc3ff
parent: 68308:bb2a9ea5c7d0
parent: 68310:7d442fd36c96
user: Benjamin Peterson <benjamin at python.org>
date: Sun Mar 06 17:15:06 2011 -0600
summary:
 merge 3.1
files:
 
diff --git a/Lib/lib2to3/pytree.py b/Lib/lib2to3/pytree.py
--- a/Lib/lib2to3/pytree.py
+++ b/Lib/lib2to3/pytree.py
@@ -743,9 +743,11 @@
 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()
+ # ignored. We only have to do this on CPython, though, because other
+ # implementations don't have this nasty bug in the first place.
+ if hasattr(sys, "getrefcount"):
+ save_stderr = sys.stderr
+ sys.stderr = StringIO()
 try:
 for count, r in self._recursive_matches(nodes, 0):
 if self.name:
@@ -759,7 +761,8 @@
 r[self.name] = nodes[:count]
 yield count, r
 finally:
- sys.stderr = save_stderr
+ if hasattr(sys, "getrefcount"):
+ sys.stderr = save_stderr
 
 def _iterative_matches(self, nodes):
 """Helper to iteratively yield the matches."""
-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list

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