bottle icon indicating copy to clipboard operation
bottle copied to clipboard

WSGIHeaderDict fails to get item if it's present and None in original dict

Open Andrey-mp opened this issue 5 months ago • 5 comments

get key with not None value

>>> import bottle
>>> x = bottle.WSGIHeaderDict({"HTTP_X": "y", "HTTP_Z": None})
>>> print(x.get("x"))
y

get absent key

>>> print(x.get("w"))
None

get key with None value

>>> print(x.get("z"))
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib64/python3.6/_collections_abc.py", line 660, in get
    return self[key]
  File "/root/work/build/debug/config/vnc_openstack/.tox/py36/lib/python3.6/site-packages/bottle.py", line 2331, in __getitem__
    val = val.decode('utf8')
AttributeError: 'NoneType' object has no attribute 'decode'

Andrey-mp avatar Sep 09 '24 20:09 Andrey-mp