@@ -427,44 +427,9 @@ def close(fignum=None):
427427# locale utilities
428428
429429
430- def check_output (* popenargs , ** kwargs ):
431- # shamelessly taken from Python 2.7 source
432- r"""Run command with arguments and return its output as a byte string.
433-
434- If the exit code was non-zero it raises a CalledProcessError. The
435- CalledProcessError object will have the return code in the returncode
436- attribute and output in the output attribute.
437-
438- The arguments are the same as for the Popen constructor. Example:
439-
440- >>> check_output(["ls", "-l", "/dev/null"])
441- 'crw-rw-rw- 1 root root 1, 3 Oct 18 2007 /dev/null\n'
442-
443- The stdout argument is not allowed as it is used internally.
444- To capture standard error in the result, use stderr=STDOUT.
445-
446- >>> check_output(["/bin/sh", "-c",
447- ... "ls -l non_existent_file ; exit 0"],
448- ... stderr=STDOUT)
449- 'ls: non_existent_file: No such file or directory\n'
450- """
451- if 'stdout' in kwargs :
452- raise ValueError ('stdout argument not allowed, it will be overridden.' )
453- process = subprocess .Popen (stdout = subprocess .PIPE , stderr = subprocess .PIPE ,
454- * popenargs , ** kwargs )
455- output , unused_err = process .communicate ()
456- retcode = process .poll ()
457- if retcode :
458- cmd = kwargs .get ("args" )
459- if cmd is None :
460- cmd = popenargs [0 ]
461- raise subprocess .CalledProcessError (retcode , cmd , output = output )
462- return output
463-
464-
465430def _default_locale_getter ():
466431 try :
467- raw_locales = check_output (['locale -a' ], shell = True )
432+ raw_locales = subprocess . check_output (['locale -a' ], shell = True )
468433 except subprocess .CalledProcessError as e :
469434 raise type (e )("{exception}, the 'locale -a' command cannot be found "
470435 "on your system" .format (exception = e ))
0 commit comments