Page MenuHomePhabricator

login.py doesn't work (critical error "due to uncaught exception")
Open, Needs TriagePublicBUG REPORT

Description

I tried after several years to use again the pywikibot framework. After downloading Python 3.9 + pip + lastest stable version of pywikibot, I managed after several attempts to configure my user file, and saved my password on a separate file.

Then when I tried to run the "py pwb.py login" command, the following happened:

WARNING: No user is logged in on site wikipedia:it
Logging in to wikipedia:it as SanniBot@BotPasswordName
Traceback (most recent call last):
  File "c:\Users\Utente\Desktop\pywikibot\pwb.py", line 363, in <module>
    if not main():
  File "c:\Users\Utente\Desktop\pywikibot\pwb.py", line 355, in main
    run_python_file(filename,
  File "c:\Users\Utente\Desktop\pywikibot\pwb.py", line 74, in run_python_file
    exec(compile(source, filename, 'exec', dont_inherit=True),
  File ".\scripts\login.py", line 190, in <module>
    main()
  File ".\scripts\login.py", line 172, in main
    site.login(autocreate=autocreate)
  File "c:\Users\Utente\Desktop\pywikibot\pywikibot\tools\__init__.py", line 1449, in wrapper
    return obj(*__args, **__kw)
  File "c:\Users\Utente\Desktop\pywikibot\pywikibot\site\__init__.py", line 1515, in login
    if login_manager.login(retry=True, autocreate=autocreate):
  File "c:\Users\Utente\Desktop\pywikibot\pywikibot\login.py", line 326, in login
    cookiedata = self.getCookie()
  File "c:\Users\Utente\Desktop\pywikibot\pywikibot\tools\__init__.py", line 1532, in wrapper
    return obj(*new_args, **new_kwargs)
  File "c:\Users\Utente\Desktop\pywikibot\pywikibot\data\api.py", line 3053, in getCookie
    and (response['messagecode'] == 'login-throttled'
KeyError: 'messagecode'
CRITICAL: Exiting due to uncaught exception <class 'KeyError'>

Since I double-checked the password, I think the problem is within the password file and/or there is a wrong configuration of the PATH file. Or is it something else?

Event Timeline

Restricted Application added subscribers: pywikibot-bugs-list, Aklapper. · View Herald Transcript

@Sannita: what is the MediaWiki version you are working on?

Xqt changed the subtype of this task from "Task" to "Bug Report".Dec 6 2020, 7:25 AM
Xqt added subscribers: Mpaa, Framawiki.

Change 645822 had a related patch set uploaded (by Xqt; owner: Xqt):
[pywikibot/core@master] [bugfix] fix KeyError for missing 'messagecode'

https://gerrit.wikimedia.org/r/645822

@Sannita: Are you able to review that patch?

@Sannita: what is the MediaWiki version you are working on?

It is literally the one WMF uses, since I'm trying to run my bot on Italian Wikipedia.

Yes, my bot is approved. Yes, I downloaded all that I had to. Yes, I got all the basics covered.

@Sannita: Are you able to review that patch?

I unfortunately am not, sorry :(

@Sannita: what is the MediaWiki version you are working on?

It is literally the one WMF uses, since I'm trying to run my bot on Italian Wikipedia.

Really strange: The current wikipedia:it release is '1.36.0-wmf.18' and the response should have 'messagecode' key.

Really strange: The current wikipedia:it release is '1.36.0-wmf.18' and the response should have 'messagecode' key.

Found this: https://www.mediawiki.org/wiki/Topic:Vrl03a6g6zrlpgps, T261061
But this seems another issue with same effect.

Change 645822 merged by jenkins-bot:
[pywikibot/core@master] [IMPR] Add additional info into log if 'messagecode' is missing during login

https://gerrit.wikimedia.org/r/645822