mirror of
https://github.com/python/cpython.git
synced 2025-11-09 10:01:42 +00:00
only do this sys.stderr replacing on CPython
This commit is contained in:
parent
81638f1351
commit
d86e4c8673
1 changed files with 7 additions and 4 deletions
|
|
@ -743,7 +743,9 @@ def generate_matches(self, nodes):
|
||||||
else:
|
else:
|
||||||
# The reason for this is that hitting the recursion limit usually
|
# The reason for this is that hitting the recursion limit usually
|
||||||
# results in some ugly messages about how RuntimeErrors are being
|
# results in some ugly messages about how RuntimeErrors are being
|
||||||
# ignored.
|
# 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
|
save_stderr = sys.stderr
|
||||||
sys.stderr = StringIO()
|
sys.stderr = StringIO()
|
||||||
try:
|
try:
|
||||||
|
|
@ -759,6 +761,7 @@ def generate_matches(self, nodes):
|
||||||
r[self.name] = nodes[:count]
|
r[self.name] = nodes[:count]
|
||||||
yield count, r
|
yield count, r
|
||||||
finally:
|
finally:
|
||||||
|
if hasattr(sys, "getrefcount"):
|
||||||
sys.stderr = save_stderr
|
sys.stderr = save_stderr
|
||||||
|
|
||||||
def _iterative_matches(self, nodes):
|
def _iterative_matches(self, nodes):
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue