summaryrefslogtreecommitdiffstats
path: root/Lib/lib2to3
diff options
context:
space:
mode:
authorBenjamin Peterson <benjamin@python.org>2011-03-06 23:08:40 (GMT)
committerBenjamin Peterson <benjamin@python.org>2011-03-06 23:08:40 (GMT)
commitbf12cdc24a5d75c6938696fb55fd2ed4bf1ca08b (patch)
treecada5671c6093a57557c8daf838e491e54b7622a /Lib/lib2to3
parent5edae7ea5e7f63a81d975bfc960b4bb607e634a6 (diff)
downloadcpython-bf12cdc24a5d75c6938696fb55fd2ed4bf1ca08b.zip
cpython-bf12cdc24a5d75c6938696fb55fd2ed4bf1ca08b.tar.gz
cpython-bf12cdc24a5d75c6938696fb55fd2ed4bf1ca08b.tar.bz2
only do this sys.stderr replacing on CPython
Diffstat (limited to 'Lib/lib2to3')
-rw-r--r--Lib/lib2to3/pytree.py11
1 files changed, 7 insertions, 4 deletions
diff --git a/Lib/lib2to3/pytree.py b/Lib/lib2to3/pytree.py
index b24283e..c2fa800 100644
--- a/Lib/lib2to3/pytree.py
+++ b/Lib/lib2to3/pytree.py
@@ -743,9 +743,11 @@ class WildcardPattern(BasePattern):
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 don't do this on non-CPython implementation because
+ # they don't have this problem.
+ 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 @@ class WildcardPattern(BasePattern):
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."""