bbremote: fix the exit usage
PATCH 1/1 bbremote: fix the exit usage
Unlike the sys.exit() function the builtin exit() function don't take an argument. Fix it by using the exit function from the sys module which is already imported.
--- scripts/remote/main.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
scripts/remote/main.py +5 -5
@@ -14,7 +14,7 @@ try: import serial except: print("error: No python-serial package found", file=sys.stderr) - exit(2) + sys.exit(2) def versiontuple(v):
@@ -279,15 +279,15 @@ logging.basicConfig(level=VERBOSITY[args.verbose], format='%(levelname)-8s %(module)-8s %(funcName)-16s %(message)s') try: res = args.func(args) - exit(res) + sys.exit(res) except RatpError as detail: print("Ratp error:", detail, file=sys.stderr); - exit(127) + sys.exit(127) except KeyboardInterrupt: print("\nInterrupted", file=sys.stderr); - exit(1) + sys.exit(1) #try: # res = args.func(args) #except Exception as e: # print("error: failed to establish connection: %s" % e, file=sys.stderr) -# exit(2) +# sys.exit(2)
Signature · 7 lines
2.29.2 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
Hi,
Quoted 3 lines · Marco Felsch
Unlike the
sys.exit()function the builtinexit()function don't take an argument. Fix it by using the exit function from the sys module which is already imported.
This is not entirely correct, the builtin exit() function also takes an exit code and works fine when I tested this:
$ python3 -c "exit(1)"; echo $? 1 $
Nevertheless the documentation [1] says that sys.exit() should be used in scripts. So the patch is fine, but the justification not entirely correct.
[1]: https://docs.python.org/3/library/constants.html#constants-added-by-the-site-module
Regards,
Rouven Czerwinski
_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
Marco,
Quoted 14 lines · Rouven Czerwinski
Hi,
Quoted 3 lines · Marco Felsch
Unlike the
sys.exit()function the builtinexit()function don't take an argument. Fix it by using the exit function from the sys module which is already imported.This is not entirely correct, the builtin
exit()function also takes an exit code and works fine when I tested this:$ python3 -c "exit(1)"; echo $? 1 $
Quoted 5 lines
Nevertheless the documentation [1] says that
sys.exit()should be used in scripts. So the patch is fine, but the justification not entirely correct.[1]: https://docs.python.org/3/library/constants.html#constants-added-by-the-site-module
Could you adjust the commit message accordingly?
Sascha
Signature · 9 lines
Pengutronix e.K. | | Steuerwalder Str. 21 | http://www.pengutronix.de/ | 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 | _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox