OS: Ubuntu 22.04 LTS with python 3.10.4 and py-macaroon-bakery 1.3.1
With the move to python 3.10, attempts to store macaroons in http.cookiejar.MozillaCookieJar format files fail. Essentally, I have code that does the following:
Under python 3.10, this causes a traceback in the call to client.cookies.save() like so:
[ELIDED]
File "/usr/lib/python3.10/http/cookiejar.py", line 2120, in save
if cookie.has_nonstandard_attr(HTTPONLY_ATTR):
File "/usr/lib/python3.10/http/cookiejar.py", line 805, in has_nonstandard_attr
return name in self._rest
TypeError: argument of type 'NoneType' is not iterable
OS: Ubuntu 22.04 LTS with python 3.10.4 and py-macaroon-bakery 1.3.1
With the move to python 3.10, attempts to store macaroons in
http.cookiejar.MozillaCookieJar
format files fail. Essentally, I have code that does the following:Under python 3.10, this causes a traceback in the call to
client.cookies.save()
like so:In python 3.10 the commit https://github.com/python/cpython/commit/16ee68da6e12bb2d79751b32cc37523fe4f4bb48 adds a check for the HTTP Only flag in the MozillaCookieJar class, and in particular, this is checked for before writing out the cookie file via
Cookie.has_nonstandard_attr()
like so:(see https://github.com/python/cpython/blob/16ee68da6e12bb2d79751b32cc37523fe4f4bb48/Lib/http/cookiejar.py#L2120 )
Cookie.has_nonstandard_attr()
is implemented as the following:(see https://github.com/python/cpython/blame/main/Lib/http/cookiejar.py#L803 )
Unfortunately,
macaroonbakery/_utils/__init__.py.cookie()
creates aCookie
class withrest=None
https://github.com/go-macaroon-bakery/py-macaroon-bakery/blob/df0e18f91267640b2970b8fd0788be4a5e6c0d1c/macaroonbakery/_utils/__init__.py#L163 and that causes the traceback seen above, because you can't test for values present inNone
.Fixing (or working around, depending on whether you believe this is a bug in python's cookiejar) this in py-macaroon-bakery should be as simple as: