mirror of
https://github.com/python/cpython.git
synced 2024-12-04 23:34:42 +08:00
merge 3.1
This commit is contained in:
commit
c9c8d0edd6
@ -743,9 +743,11 @@ class WildcardPattern(BasePattern):
|
|||||||
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
|
||||||
save_stderr = sys.stderr
|
# implementations don't have this nasty bug in the first place.
|
||||||
sys.stderr = StringIO()
|
if hasattr(sys, "getrefcount"):
|
||||||
|
save_stderr = sys.stderr
|
||||||
|
sys.stderr = StringIO()
|
||||||
try:
|
try:
|
||||||
for count, r in self._recursive_matches(nodes, 0):
|
for count, r in self._recursive_matches(nodes, 0):
|
||||||
if self.name:
|
if self.name:
|
||||||
@ -759,7 +761,8 @@ class WildcardPattern(BasePattern):
|
|||||||
r[self.name] = nodes[:count]
|
r[self.name] = nodes[:count]
|
||||||
yield count, r
|
yield count, r
|
||||||
finally:
|
finally:
|
||||||
sys.stderr = save_stderr
|
if hasattr(sys, "getrefcount"):
|
||||||
|
sys.stderr = save_stderr
|
||||||
|
|
||||||
def _iterative_matches(self, nodes):
|
def _iterative_matches(self, nodes):
|
||||||
"""Helper to iteratively yield the matches."""
|
"""Helper to iteratively yield the matches."""
|
||||||
|
Loading…
Reference in New Issue
Block a user