Merge lp:~frankban/python-shelltoolbox/called-process-error-fixes into lp:python-shelltoolbox

Proposed by Francesco Banconi
Status: Merged
Approved by: Graham Binns
Approved revision: 16
Merged at revision: 16
Proposed branch: lp:~frankban/python-shelltoolbox/called-process-error-fixes
Merge into: lp:python-shelltoolbox
Diff against target: 18 lines (+7/-3)
1 file modified
shelltoolbox/__init__.py (+7/-3)
To merge this branch: bzr merge lp:~frankban/python-shelltoolbox/called-process-error-fixes
Reviewer Review Type Date Requested Status
Graham Binns (community) code Approve
Review via email: mp+105786@code.launchpad.net

Description of the change

== Changes ==

Updated the run function to be compatible with Python < 2.7.
See comments in the diff.

== Tests ==

$ python tests.py ...........................................................
----------------------------------------------------------------------
Ran 59 tests in 0.119s

OK

To post a comment you must log in.
Revision history for this message
Graham Binns (gmb) :
review: Approve (code)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'shelltoolbox/__init__.py'
--- shelltoolbox/__init__.py 2012-03-19 11:42:36 +0000
+++ shelltoolbox/__init__.py 2012-05-15 09:45:32 +0000
@@ -418,9 +418,13 @@
418 close_fds=kwargs.pop('close_fds', True), **kwargs)418 close_fds=kwargs.pop('close_fds', True), **kwargs)
419 stdout, stderr = process.communicate()419 stdout, stderr = process.communicate()
420 if process.returncode:420 if process.returncode:
421 output = ''.join(filter(None, [stdout, stderr]))421 exception = subprocess.CalledProcessError(
422 raise subprocess.CalledProcessError(422 process.returncode, repr(args))
423 process.returncode, repr(args), output=output)423 # The output argument of `CalledProcessError` was introduced in Python
424 # 2.7. Monkey patch the output here to avoid TypeErrors in older
425 # versions of Python, still preserving the output in Python 2.7.
426 exception.output = ''.join(filter(None, [stdout, stderr]))
427 raise exception
424 return stdout428 return stdout
425429
426430

Subscribers

People subscribed via source and target branches