From e3007c6e2f1bbced178b8e71a543f42b8f9bf692 Mon Sep 17 00:00:00 2001 From: Jakob Date: Sat, 30 Nov 2019 17:44:27 -0600 Subject: [PATCH] Fix custom cookie jar bugs --- auth.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/auth.py b/auth.py index c305e43..299dd70 100644 --- a/auth.py +++ b/auth.py @@ -241,16 +241,22 @@ def get_access_token(storage_mgr, api_iface): class StorageMgrCookieJar(http.cookiejar.CookieJar): - def __init__(self, storage_mgr): + def __init__(self, storage_mgr, *args): + super().__init__(*args) self.storage_mgr = storage_mgr def load(self): if 'cookies' not in self.storage_mgr.keys(): - self.storage_mgr['cookies'] = {} - self._cookies = self.storage_mgr['cookies'] + self.storage_mgr['cookies'] = [] + with self._cookies_lock: + self._cookies = {} + for dict_ in self.storage_mgr['cookies']: + self.set_cookie(http.cookiejar.Cookie(**dict_)) def save(self): - self.storage_mgr['cookies'] = self._cookies + lambda fix_dict = lambda d: {k.strip('_'): v for (k, v) in d.items()} + dicts = [fix_dict(c.__dict__) for c in self] + self.storage_mgr['cookies'] = dicts class CookieAuthHandler(urllib.request.HTTPCookieProcessor): -- 2.30.2