Page MenuHomePhabricator

No warning is given if a user does not exists and the username is greater than the last known user
Closed, ResolvedPublicBUG REPORT

Description

Steps to replicate the issue (include links if applicable):

import pywikibot
s = pywikibot.Site('comprehensibleinputwiki:en')
s.login(user='unknown user 47110815')

or

s = pywikibot.Site('comprehensibleinputwiki:en', user='unknown user 47110815')
s.login()

What happens?:

WARNING: No user is logged in on site comprehensibleinputwiki:en
Traceback (most recent call last):
  File "<pyshell#95>", line 1, in <module>
    s.login(user='unknown user 47110815')  # or s.login()
  File "D:\pwb\GIT\core\pywikibot\site\_apisite.py", line 417, in login
    if login_manager.login(retry=True, autocreate=autocreate):
  File "D:\pwb\GIT\core\pywikibot\login.py", line 282, in login
    self.check_user_exists()
  File "D:\pwb\GIT\core\pywikibot\login.py", line 136, in check_user_exists
    user = next(data)
  File "<frozen _collections_abc>", line 330, in __next__
  File "D:\pwb\GIT\core\pywikibot\tools\collections.py", line 275, in send
    return next(self._started_gen)
StopIteration

This occurres if the given name is behind the last account name.

What should have happened instead?:

The warning should be as follows:

WARNING: No user is logged in on site wikipedia:de
Traceback (most recent call last):
  File "<pyshell#99>", line 1, in <module>
    s.login(user='unknown user 47110815')
  File "D:\pwb\GIT\core\pywikibot\site\_apisite.py", line 417, in login
    if login_manager.login(retry=True, autocreate=autocreate):
  File "D:\pwb\GIT\core\pywikibot\login.py", line 282, in login
    self.check_user_exists()
  File "D:\pwb\GIT\core\pywikibot\login.py", line 146, in check_user_exists
    raise NoUsernameError("Username '{}' does not exist on {}"
pywikibot.exceptions.NoUsernameError: Username 'Unknown user 47110815' does not exist on wikipedia:de

Software version:
Pywikibot 7.0.0 (and earlier but cannot be tested due to syntax changes of Python 3.11

Event Timeline

Xqt changed the task status from Open to In Progress.Jan 1 2023, 2:46 PM
Xqt claimed this task.
Xqt triaged this task as High priority.

Change 874023 had a related patch set uploaded (by Xqt; author: Xqt):

[pywikibot/core@master] [bugfix] Use a default result for allusers() if next() leads to StopIteration

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

Xqt renamed this task from comprehensibleinputwiki does not give a warning if a user does not exists to No warning is given if a user does not exists and the username is greater than the last known user.Jan 8 2023, 3:02 PM
Xqt closed this task as Resolved.
Xqt removed a project: affects-Miraheze.
Xqt updated the task description. (Show Details)

Change 874023 merged by jenkins-bot:

[pywikibot/core@master] [bugfix] Use a default result for allusers() if next() leads to StopIteration

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