Skip to content

Commit b36a6c4

Browse files
authored
Merge pull request #747 from amoffat/develop
v2.2.1
2 parents be9f8ea + 11f55d5 commit b36a6c4

File tree

4 files changed

+21
-1
lines changed

4 files changed

+21
-1
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Changelog
22

3+
## 2.2.1 - 1/9/25
4+
5+
- Bugfix where `async` and `return_cmd` does not raise exceptions [#746](https://github.com/amoffat/sh/pull/746)
6+
37
## 2.2.0 - 1/9/25
48

59
- `return_cmd` with `await` now works correctly [#743](https://github.com/amoffat/sh/issues/743)

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "sh"
3-
version = "2.2.0"
3+
version = "2.2.1"
44
description = "Python subprocess replacement"
55
authors = ["Andrew Moffat <arwmoffat@gmail.com>"]
66
readme = "README.rst"

sh.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -890,6 +890,9 @@ def __await__(self):
890890
async def wait_for_completion():
891891
await self.aio_output_complete.wait()
892892
if self.call_args["return_cmd"]:
893+
# We know the command has completed already,
894+
# but need to catch exceptions
895+
self.wait()
893896
return self
894897
else:
895898
return str(self)

tests/sh_test.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1802,6 +1802,19 @@ async def main():
18021802

18031803
asyncio.run(main())
18041804

1805+
def test_async_return_cmd_exc(self):
1806+
py = create_tmp_test(
1807+
"""
1808+
import sys
1809+
sys.exit(1)
1810+
"""
1811+
)
1812+
1813+
async def main():
1814+
await python(py.name, _async=True, _return_cmd=True)
1815+
1816+
self.assertRaises(sh.ErrorReturnCode_1, asyncio.run, main())
1817+
18051818
def test_handle_both_out_and_err(self):
18061819
py = create_tmp_test(
18071820
"""

0 commit comments

Comments
 (0)