From c6f7b2cb3db2db768f21f45a3aa10bbbd559ecb3 Mon Sep 17 00:00:00 2001 From: Kevin Hester Date: Wed, 10 Mar 2021 10:43:17 +0800 Subject: [PATCH] fix empty string for bytes() params (fixes --setchan psk "") --- meshtastic/__main__.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/meshtastic/__main__.py b/meshtastic/__main__.py index 79921ae..e4a3726 100644 --- a/meshtastic/__main__.py +++ b/meshtastic/__main__.py @@ -74,7 +74,9 @@ def fromStr(valstr): Args: valstr (string): A user provided string """ - if(valstr.startswith('0x')): + if(len(valstr) == 0): # Treat an emptystring as an empty bytes + val = bytes() + elif(valstr.startswith('0x')): # if needed convert to string with asBytes.decode('utf-8') val = bytes.fromhex(valstr[2:]) elif valstr in trueTerms: