String with unicode fails during put

Bug #1990356 reported by Ansil H
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
etcd3gw
New
Undecided
Unassigned

Bug Description

Create a file with 'En DASH' (\u2013)

$ cat >input.txt<<EOF
\s+–\s
EOF

Put the file to etcd

$ cat >save.py<<EOF
from etcd3gw.client import Etcd3Client

with open("input.txt", "r") as file:
    data = file.read()

client = Etcd3Client(host='localhost', port=2379, api_path='/v3beta/')
client.put("/test",data)
EOF

$ python3 save.py
Traceback (most recent call last):
  File "/home/ubuntu/save.py", line 7, in <module>
    client.put("/test",data)
  File "/home/ubuntu/.local/lib/python3.10/site-packages/etcd3gw/client.py", line 189, in put
    "value": _encode(value)
  File "/home/ubuntu/.local/lib/python3.10/site-packages/etcd3gw/utils.py", line 28, in _encode
    data = str(data).encode("latin-1")
UnicodeEncodeError: 'latin-1' codec can't encode character '\u2013' in position 3: ordinal not in range(256)

Ansil H (ansilh)
description: updated
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.