Skip to content

Commit

Permalink
fix issue with tn-cli when fully formated json is not handled correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
or-else committed Apr 24, 2022
1 parent e35a8f5 commit 88953a8
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion tn-cli/tn-cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,10 +195,13 @@ def attachment(filename):
stdoutln("Error processing attachment '" + filename + "':", err)
return None

# encode_to_bytes takes an object/dictionary and converts it to json-formatted byte array.
# encode_to_bytes converts the src to json-formatted byte array.
# An object/dictionary is first converted to json, a string is directly converted to bytes.
def encode_to_bytes(src):
if src == None:
return None
if isinstance(src, str):
return src.encode('utf-8')
return json.dumps(src).encode('utf-8')

# Parse credentials
Expand Down

0 comments on commit 88953a8

Please sign in to comment.