From 96dc46032c32beca0a2d61e15f8dea94cf8b913f Mon Sep 17 00:00:00 2001 From: Ahmad Bilal Khalid Date: Sat, 29 Jun 2019 17:14:13 +0500 Subject: [PATCH] if arg of put is str don't decode it --- etcd_wrapper.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/etcd_wrapper.py b/etcd_wrapper.py index 07a9409..4620e84 100644 --- a/etcd_wrapper.py +++ b/etcd_wrapper.py @@ -2,6 +2,7 @@ import etcd3 import json from dataclasses import dataclass + @dataclass(init=False) class EtcdEntry: def __init__(self, meta, value, value_in_json=False): @@ -15,6 +16,7 @@ class EtcdEntry: key: str value: str + class Etcd3Wrapper(object): def __init__(self, *args, **kwargs): self.client = etcd3.client(*args, **kwargs) @@ -29,8 +31,11 @@ class Etcd3Wrapper(object): _key, _value = args if value_in_json: _value = json.dumps(_value) - return self.client.put(_key.decode("utf-8"), _value) + if not isinstance(_key, str): + _key = _key.decode("utf-8") + + return self.client.put(_key, _value, **kwargs) def get_prefix(self, *args, value_in_json=False, **kwargs): r = self.client.get_prefix(*args, **kwargs)