From 99d136d355b5218d754f47e63f8143daa4a90084 Mon Sep 17 00:00:00 2001 From: Sukawat D Date: Wed, 28 Oct 2020 14:50:34 +0700 Subject: [PATCH] fix TypeError can not concat str to bytes --- routeros_api/sentence.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/routeros_api/sentence.py b/routeros_api/sentence.py index a146910..0664886 100644 --- a/routeros_api/sentence.py +++ b/routeros_api/sentence.py @@ -2,6 +2,7 @@ from routeros_api import exceptions from routeros_api import query +from six import string_types response_re = re.compile(b'^!(re|trap|fatal|done)$') @@ -56,6 +57,10 @@ def __init__(self, path, command, tag=None): def get_api_format(self): formated = [self.path + self.command] for key, value in self.attributes.items(): + if isinstance(key, string_types): + key = key.encode() + if isinstance(value, string_types): + value = value.encode() formated.append(b'=' + key + b'=' + value) for query in self.queries: formated.extend(query.get_api_format())