mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH] bbremote: fix the exit usage
@ 2021-02-24 10:15 Marco Felsch
  2021-02-24 13:22 ` Rouven Czerwinski
  0 siblings, 1 reply; 3+ messages in thread
From: Marco Felsch @ 2021-02-24 10:15 UTC (permalink / raw)
  To: barebox

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.

Signed-off-by: Marco Felsch <m.felsch@pengutronix.de>
---
 scripts/remote/main.py | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/scripts/remote/main.py b/scripts/remote/main.py
index cef5d92ee2..37be5a35f0 100644
--- a/scripts/remote/main.py
+++ b/scripts/remote/main.py
@@ -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)
-- 
2.29.2


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] bbremote: fix the exit usage
  2021-02-24 10:15 [PATCH] bbremote: fix the exit usage Marco Felsch
@ 2021-02-24 13:22 ` Rouven Czerwinski
  2021-03-01 15:50   ` Sascha Hauer
  0 siblings, 1 reply; 3+ messages in thread
From: Rouven Czerwinski @ 2021-02-24 13:22 UTC (permalink / raw)
  To: Marco Felsch, barebox

Hi,

On Wed, 2021-02-24 at 11:15 +0100, Marco Felsch wrote:
> 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.

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
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] bbremote: fix the exit usage
  2021-02-24 13:22 ` Rouven Czerwinski
@ 2021-03-01 15:50   ` Sascha Hauer
  0 siblings, 0 replies; 3+ messages in thread
From: Sascha Hauer @ 2021-03-01 15:50 UTC (permalink / raw)
  To: Rouven Czerwinski; +Cc: barebox, Marco Felsch

Marco,

On Wed, Feb 24, 2021 at 02:22:38PM +0100, Rouven Czerwinski wrote:
> Hi,
> 
> On Wed, 2021-02-24 at 11:15 +0100, Marco Felsch wrote:
> > 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.
> 
> 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

Could you adjust the commit message accordingly?

Sascha

-- 
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
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-03-01 15:52 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-02-24 10:15 [PATCH] bbremote: fix the exit usage Marco Felsch
2021-02-24 13:22 ` Rouven Czerwinski
2021-03-01 15:50   ` Sascha Hauer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox