File tree Expand file tree Collapse file tree 4 files changed +21
-1
lines changed
Expand file tree Collapse file tree 4 files changed +21
-1
lines changed Original file line number Diff line number Diff line change 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 )
Original file line number Diff line number Diff line change 11[tool .poetry ]
22name = " sh"
3- version = " 2.2.0 "
3+ version = " 2.2.1 "
44description = " Python subprocess replacement"
55authors = [" Andrew Moffat <arwmoffat@gmail.com>" ]
66readme = " README.rst"
Original file line number Diff line number Diff 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 )
Original file line number Diff line number Diff 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 """
You can’t perform that action at this time.
0 commit comments