diff options
author | Benjamin Peterson <benjamin@python.org> | 2011-03-06 23:15:06 (GMT) |
---|---|---|
committer | Benjamin Peterson <benjamin@python.org> | 2011-03-06 23:15:06 (GMT) |
commit | c9c8d0edd6daaba167527d6e659fe95715042b7e (patch) | |
tree | 07e0b290921be73c2caf462d0ad9213c3fa0a07e /Lib/lib2to3 | |
parent | 63bd5f9fe32d54057ac7e96bf00fef22ecbf92c4 (diff) | |
parent | d86e4c86733736f938100bae85b6eb3fadf5f02c (diff) | |
download | cpython-c9c8d0edd6daaba167527d6e659fe95715042b7e.zip cpython-c9c8d0edd6daaba167527d6e659fe95715042b7e.tar.gz cpython-c9c8d0edd6daaba167527d6e659fe95715042b7e.tar.bz2 |
merge 3.1
Diffstat (limited to 'Lib/lib2to3')
-rw-r--r-- | Lib/lib2to3/pytree.py | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/Lib/lib2to3/pytree.py b/Lib/lib2to3/pytree.py index e3ce249..100232b 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 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 @@ 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.""" |