This repository was archived by the owner on May 30, 2024. It is now read-only.

Description
I was investigating using this library. I've had Consul running and tried to run the asyncio example script from the docs by copying and pasting it into a file.
I expected it to run but if failed and reported the following error:
demo.py:8: DeprecationWarning: "@coroutine" decorator is deprecated since Python 3.8, use "async def" instead
def go():
Traceback (most recent call last):
File "demo.py", line 26, in <module>
loop.run_until_complete(go())
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/asyncio/base_events.py", line 616, in run_until_complete
return future.result()
File "demo.py", line 15, in go
response = yield from c.kv.put(b'foo', b'bar')
File "/consul-demo/venv/lib/python3.8/site-packages/consul/base.py", line 3018, in put
assert not key.startswith('/'), \
TypeError: startswith first arg must be bytes or a tuple of bytes, not str
The error is caused because the put function has an assert statement to check whether the key begins with the string '/'. However, the arguments being passed to the function are bytes which causes the error.
Arguments used in other example scripts are all strings. I'm assuming that the API used to take either bytes or strings but changed to only strings at some point and this particular example script did not get updated to reflect a recent change to only use strings.
It seems like a docs update is needed.