Open nelsyeung opened 1 year ago
On Linux, invoke.sudo raises UnexpectedExit instead of AuthFailure on incorrect password.
invoke.sudo
UnexpectedExit
AuthFailure
>>> import invoke >>> invoke.sudo("ls", password="a") [sudo] password: Sorry, try again. [sudo] password: Sorry, try again. [sudo] password: sudo: 3 incorrect password attempts Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/home/nelson/foo/.venv/lib/python3.7/site-packages/invoke/__init__.py", line 68, in sudo return Context().sudo(command, **kwargs) File "/home/nelson/foo/.venv/lib/python3.7/site-packages/invoke/context.py", line 170, in sudo return self._sudo(runner, command, **kwargs) File "/home/nelson/foo/.venv/lib/python3.7/site-packages/invoke/context.py", line 215, in _sudo return runner.run(cmd_str, watchers=watchers, **kwargs) File "/home/nelson/foo/.venv/lib/python3.7/site-packages/invoke/runners.py", line 376, in run return self._run_body(command, **kwargs) File "/home/nelson/foo/.venv/lib/python3.7/site-packages/invoke/runners.py", line 432, in _run_body return self.make_promise() if self._asynchronous else self._finish() File "/home/nelson/foo/.venv/lib/python3.7/site-packages/invoke/runners.py", line 499, in _finish raise UnexpectedExit(result) invoke.exceptions.UnexpectedExit: Encountered a bad command exit code! Command: "sudo -S -p '[sudo] password: ' ls" Exit code: 1 Stdout: already printed Stderr: already printed
invoke: 2.0.0 (also tested on 1.7.1) OS: Ubuntu 20.04.5 LTS Python: 3.7.13 (also tested on 3.8.13 and 3.10.5)
2.0.0
1.7.1
3.7.13
3.8.13
3.10.5
I tested this on macOS and it raises AuthFailure as expected.
On Linux,
invoke.sudo
raisesUnexpectedExit
instead ofAuthFailure
on incorrect password.Version info
invoke:
2.0.0
(also tested on1.7.1
) OS: Ubuntu 20.04.5 LTS Python:3.7.13
(also tested on3.8.13
and3.10.5
)I tested this on macOS and it raises
AuthFailure
as expected.