File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -743,9 +743,11 @@ def generate_matches(self, nodes):
743743 else :
744744 # The reason for this is that hitting the recursion limit usually
745745 # results in some ugly messages about how RuntimeErrors are being
746- # ignored.
747- save_stderr = sys .stderr
748- sys .stderr = StringIO ()
746+ # ignored. We only have to do this on CPython, though, because other
747+ # implementations don't have this nasty bug in the first place.
748+ if hasattr (sys , "getrefcount" ):
749+ save_stderr = sys .stderr
750+ sys .stderr = StringIO ()
749751 try :
750752 for count , r in self ._recursive_matches (nodes , 0 ):
751753 if self .name :
@@ -759,7 +761,8 @@ def generate_matches(self, nodes):
759761 r [self .name ] = nodes [:count ]
760762 yield count , r
761763 finally :
762- sys .stderr = save_stderr
764+ if hasattr (sys , "getrefcount" ):
765+ sys .stderr = save_stderr
763766
764767 def _iterative_matches (self , nodes ):
765768 """Helper to iteratively yield the matches."""
You can’t perform that action at this time.
0 commit comments