Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## 2.2.1 - 1/9/25

- Bugfix where `async` and `return_cmd` does not raise exceptions [#746](https://github.com/amoffat/sh/pull/746)

## 2.2.0 - 1/9/25

- `return_cmd` with `await` now works correctly [#743](https://github.com/amoffat/sh/issues/743)
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "sh"
version = "2.2.0"
version = "2.2.1"
description = "Python subprocess replacement"
authors = ["Andrew Moffat <[email protected]>"]
readme = "README.rst"
Expand Down
3 changes: 3 additions & 0 deletions sh.py
Original file line number Diff line number Diff line change
Expand Up @@ -890,6 +890,9 @@ def __await__(self):
async def wait_for_completion():
await self.aio_output_complete.wait()
if self.call_args["return_cmd"]:
# We know the command has completed already,
# but need to catch exceptions
self.wait()
return self
else:
return str(self)
Expand Down
13 changes: 13 additions & 0 deletions tests/sh_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -1802,6 +1802,19 @@ async def main():

asyncio.run(main())

def test_async_return_cmd_exc(self):
py = create_tmp_test(
"""
import sys
sys.exit(1)
"""
)

async def main():
await python(py.name, _async=True, _return_cmd=True)

self.assertRaises(sh.ErrorReturnCode_1, asyncio.run, main())

def test_handle_both_out_and_err(self):
py = create_tmp_test(
"""
Expand Down
Loading