Page MenuHomePhabricator

pywikibot.exceptions.NoUsername should not happen if user type incorrect password when use login.py script
Open, LowPublicBug

Description

Steps to Reproduce:

  1. Run python pwb.py login
  2. Type incorrect password

Actual Results:
You will get this:

1zoran@zoran-notebook:~/development/core$ nano user-config.py
2zoran@zoran-notebook:~/development/core$ python3 pwb.py login
3Password for user Zoranzoki21 on wikipedia:sr (no characters will be shown):
4Logging in to wikipedia:sr as Zoranzoki21
5ERROR: Login failed (Failed).
6Traceback (most recent call last):
7 File "/home/zoran/development/core/pywikibot/login.py", line 313, in login
8 cookiedata = self.getCookie()
9 File "/home/zoran/development/core/pywikibot/tools/__init__.py", line 1823, in wrapper
10 return obj(*new_args, **new_kwargs)
11 File "/home/zoran/development/core/pywikibot/data/api.py", line 3301, in getCookie
12 raise APIError(code=login_result['login']['result'], info=info)
13pywikibot.data.api.APIError: Failed: Incorrect username or password entered. Please try again.
14
15During handling of the above exception, another exception occurred:
16
17Traceback (most recent call last):
18 File "pwb.py", line 257, in <module>
19 if not main():
20 File "pwb.py", line 250, in main
21 run_python_file(filename, [filename] + args, argvu, file_package)
22 File "pwb.py", line 119, in run_python_file
23 main_mod.__dict__)
24 File "./scripts/login.py", line 198, in <module>
25 main()
26 File "./scripts/login.py", line 180, in main
27 site.login(sysop, autocreate=autocreate)
28 File "/home/zoran/development/core/pywikibot/site.py", line 2104, in login
29 if login_manager.login(retry=True, autocreate=autocreate):
30 File "/home/zoran/development/core/pywikibot/login.py", line 329, in login
31 '{1}\n.{2}'.format(self.login_name, self.site, e.info))
32pywikibot.exceptions.NoUsername: Username "Zoranzoki21" does not have read permissions on wikipedia:sr
33.Incorrect username or password entered. Please try again.
34<class 'pywikibot.exceptions.NoUsername'>
35CRITICAL: Closing network session.
36zoran@zoran-notebook:~/development/core$

Expected Results:
pywikibot.exceptions.NoUsername should not happen and output should be something like this:

1zoran@zoran-notebook:~/development/core$ nano user-config.py
2zoran@zoran-notebook:~/development/core$ python3 pwb.py login
3Password for user Zoranzoki21 on wikipedia:sr (no characters will be shown):
4Logging in to wikipedia:sr as Zoranzoki21
5ERROR: Login failed (Failed). Incorrect username or password entered. Please try again.
6Password for user Zoranzoki21 on wikipedia:sr (no characters will be shown):

Version:

1zoran@zoran-notebook:~/development/core$ python3 pwb.py version
2Pywikibot: [ssh] pywikibot-core (73f07ba, g10390, 2018/11/09, 09:23:55, ok)
3Release version: 3.1.dev0
4requests version: 2.18.4
5 cacerts: /etc/ssl/certs/ca-certificates.crt
6 certificate test: ok
7Python: 3.6.6 (default, Sep 12 2018, 18:26:19)
8[GCC 8.0.1 20180414 (experimental) [trunk revision 259383]]
9PYWIKIBOT_DIR: Not set
10PYWIKIBOT_DIR_PWB:
11PYWIKIBOT_NO_USER_CONFIG: Not set
12Config base dir: /home/zoran/development/core
13Usernames for family "wikipedia":
14 sr: Zoranzoki21 (no sysop configured)
15Usernames for family "translatewiki":
16 en: Zoranzoki21-Bot (no sysop configured)
17Usernames for family "testwiki":
18 sr: Zoranzoki21 (also sysop)
19zoran@zoran-notebook:~/development/core$

Event Timeline

Restricted Application added subscribers: pywikibot-bugs-list, Aklapper. · View Herald TranscriptNov 9 2018, 9:38 PM
Zoranzoki21 updated the task description. (Show Details)Nov 9 2018, 9:43 PM
Zoranzoki21 updated the task description. (Show Details)Nov 9 2018, 9:49 PM
Xqt triaged this task as Low priority.Nov 9 2018, 10:44 PM