jenkins-bot has submitted this change. ( https://gerrit.wikimedia.org/r/c/pywikibot/core/+/626911 )
Change subject: Use ignore_discard for login cookie container ......................................................................
Use ignore_discard for login cookie container
Allow saving and loading cookies with the discard flag (ie. session cookies). This allows saving bot password sessions, which did not work before (normal sessions did since they can fall back on the user_token cookie which is non-session). Since session cookies do not have an expiry, the login will be valid as long as the session exists on the server (e.g. for Wikimedia servers this is nowadays 24 hours).
Bug: T261066 Change-Id: I1519fd7cde847ab82f378758e04024619410922f --- M pywikibot/comms/http.py M pywikibot/data/api.py 2 files changed, 2 insertions(+), 2 deletions(-)
Approvals: Xqt: Looks good to me, approved jenkins-bot: Verified
diff --git a/pywikibot/comms/http.py b/pywikibot/comms/http.py index 165d4c8..74e5f98 100644 --- a/pywikibot/comms/http.py +++ b/pywikibot/comms/http.py @@ -61,7 +61,7 @@ file_mode_checker(cookie_file_path, create=True) cookie_jar = cookiejar.LWPCookieJar(cookie_file_path) try: - cookie_jar.load() + cookie_jar.load(ignore_discard=True) except cookiejar.LoadError: debug('Loading cookies failed.', _logger) else: diff --git a/pywikibot/data/api.py b/pywikibot/data/api.py index 4c896fd..db15452 100644 --- a/pywikibot/data/api.py +++ b/pywikibot/data/api.py @@ -3154,7 +3154,7 @@
def storecookiedata(self, data): """Ignore data; cookies are set by threadedhttp module.""" - http.cookie_jar.save() + http.cookie_jar.save(ignore_discard=True)
def get_login_token(self) -> str: """Fetch login token from action=query&meta=tokens.