Fix cookiejar_from_lwp function

This commit is contained in:
James Taylor 2018-12-26 20:07:10 -08:00
parent fcbd8ebef6
commit 1cb0095536

View File

@ -37,10 +37,11 @@ def add_account(username, password, save):
return successful
def cookiejar_from_lwp_str(lwp_str):
lwp_str = "#LWP-Cookies-2.0\n" + lwp_str # header required by _really_load for reading from "file"
cookiejar = http.cookiejar.LWPCookieJar()
# HACK: cookiejar module insists on using filenames and reading files for you,
# so present a StringIO to this internal method which takes a filelike object
cookiejar._really_load(self, io.StringIO(lwp_str), "", False, False)
cookiejar._really_load(io.StringIO(lwp_str), "", False, False)
return cookiejar
def account_cookiejar(username):