@@ -115,7 +115,8 @@ def which(prog):
115115 def find_python_no_venv ():
116116 # FIXME: does it makes sense now that this script is in Python?
117117
118- result = subprocess .run (["pwd" ], capture_output = True , text = True )
118+ result = SphinxDependencyChecker .run (["pwd" ], capture_output = True ,
119+ text = True )
119120 cur_dir = result .stdout .strip ()
120121
121122 python_names = ["python3" , "python" ]
@@ -135,12 +136,23 @@ def find_python_no_venv():
135136 def run (* args , ** kwargs ):
136137 """Excecute a command, hiding its output by default"""
137138
138- if not kwargs .get ('capture_output' , False ):
139+ capture_output = kwargs .pop ('capture_output' , False )
140+
141+ if capture_output :
142+ if 'stdout' not in kwargs :
143+ kwargs ['stdout' ] = subprocess .PIPE
144+ if 'stderr' not in kwargs :
145+ kwargs ['stderr' ] = subprocess .PIPE
146+ else :
139147 if 'stdout' not in kwargs :
140148 kwargs ['stdout' ] = subprocess .DEVNULL
141149 if 'stderr' not in kwargs :
142150 kwargs ['stderr' ] = subprocess .DEVNULL
143151
152+ # Don't break with older Python versions
153+ if 'text' in kwargs and sys .version_info < (3 , 7 ):
154+ kwargs ['universal_newlines' ] = kwargs .pop ('text' )
155+
144156 return subprocess .run (* args , ** kwargs )
145157
146158 #
0 commit comments