Skip to content

Commit

Permalink
Merge pull request #747 from amoffat/develop
Browse files Browse the repository at this point in the history
v2.2.1
  • Loading branch information
amoffat authored Jan 9, 2025
2 parents be9f8ea + 11f55d5 commit b36a6c4
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 1 deletion.
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 <arwmoffat@gmail.com>"]
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

0 comments on commit b36a6c4

Please sign in to comment.