File tree 2 files changed +6
-9
lines changed
2 files changed +6
-9
lines changed Original file line number Diff line number Diff line change @@ -482,11 +482,6 @@ def InitParser(parser):
482
482
return parser
483
483
484
484
485
- # This is a poor replacement for subprocess.run until we require Python 3.6+.
486
- class RunError (Exception ):
487
- """Error when running a command failed."""
488
-
489
-
490
485
def run_command (cmd , ** kwargs ):
491
486
"""Run |cmd| and return its output."""
492
487
check = kwargs .pop ("check" , False )
@@ -544,7 +539,8 @@ def run_command(cmd, **kwargs):
544
539
545
540
_print_output ("stdout" , ret .stdout )
546
541
_print_output ("stderr" , ret .stderr )
547
- raise RunError (ret )
542
+ # This will raise subprocess.CalledProcessError for us.
543
+ ret .check_returncode ()
548
544
549
545
return ret
550
546
@@ -668,7 +664,7 @@ def run_git(*args, **kwargs):
668
664
file = sys .stderr ,
669
665
)
670
666
sys .exit (1 )
671
- except RunError :
667
+ except subprocess . CalledProcessError :
672
668
raise CloneFailure ()
673
669
674
670
@@ -850,7 +846,8 @@ def _GetRepoConfig(name):
850
846
f"repo: error: git { ' ' .join (cmd )} failed:\n { ret .stderr } " ,
851
847
file = sys .stderr ,
852
848
)
853
- raise RunError ()
849
+ # This will raise subprocess.CalledProcessError for us.
850
+ ret .check_returncode ()
854
851
855
852
856
853
def _InitHttp ():
Original file line number Diff line number Diff line change @@ -126,7 +126,7 @@ def test_check(self):
126
126
self .wrapper .run_command (["true" ], check = False )
127
127
self .wrapper .run_command (["true" ], check = True )
128
128
self .wrapper .run_command (["false" ], check = False )
129
- with self .assertRaises (self . wrapper . RunError ):
129
+ with self .assertRaises (subprocess . CalledProcessError ):
130
130
self .wrapper .run_command (["false" ], check = True )
131
131
132
132
You can’t perform that action at this time.
0 commit comments