jenkins-bot submitted this change.

View Change

Approvals: Xqt: Looks good to me, approved jenkins-bot: Verified
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(-)

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.

To view, visit change 626911. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Change-Id: I1519fd7cde847ab82f378758e04024619410922f
Gerrit-Change-Number: 626911
Gerrit-PatchSet: 2
Gerrit-Owner: Gergő Tisza <gtisza@wikimedia.org>
Gerrit-Reviewer: D3r1ck01 <xsavitar.wiki@aol.com>
Gerrit-Reviewer: Isaacandy <isaac@iznd.xyz>
Gerrit-Reviewer: Mpaa <mpaa.wiki@gmail.com>
Gerrit-Reviewer: Siebrand <siebrand@kitano.nl>
Gerrit-Reviewer: Xqt <info@gno.de>
Gerrit-Reviewer: jenkins-bot
Gerrit-MessageType: merged