Page MenuHomePhabricator

Pywikibot can have a status which is neither logged in nor logged out
Closed, ResolvedPublicBUG REPORT

Description

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

D:\pwb\GIT\core>pwb -lang:en script_tests -v TestScriptGenerator.test_basic
tests: max_retries reduced from 15 to 1
create_isbn_edition depends on isbnlib, which isn't available
test_basic (__main__.TestScriptGenerator.test_basic)
Test running basic -simulate -page:Foobar -always -site:wikipedia:en. ... FAIL

======================================================================
FAIL: test_basic (__main__.TestScriptGenerator.test_basic)
Test running basic -simulate -page:Foobar -always -site:wikipedia:en.
----------------------------------------------------------------------
Traceback (most recent call last):
  File "D:\pwb\GIT\core\tests\script_tests.py", line 240, in test_script
    self.assertIn(error, err_result)
AssertionError: 'Script terminated successfully' not found in 'Retrieving 1 pages from wikipedia:en.\r\n@@ -57 +57 @@ ***\r\n- [[Category:Articles with example C code]] ***\r\n+ [[Category:Articles with example C code]]Test ***\r\n\r\nEdit summary: Bot: Changing ...\r\nWARNING: No user is logged in on site wikipedia:en\r\n'

----------------------------------------------------------------------
Ran 1 test in 5.775s

FAILED (failures=1)

See also https://github.com/wikimedia/pywikibot/actions/runs/3892935850/jobs/6658065107

After explicit login it gives:

D:\pwb\GIT\core>pwb login -lang:en
Logged in on wikipedia:en as Xqtest.

Execution time: 0 seconds

D:\pwb\GIT\core>pwb -lang:en script_tests -v TestScriptGenerator.test_basic
tests: max_retries reduced from 15 to 1
create_isbn_edition depends on isbnlib, which isn't available
test_basic (__main__.TestScriptGenerator.test_basic)
Test running basic -simulate -page:Foobar -always -site:wikipedia:en. ... ok

----------------------------------------------------------------------
Ran 1 test in 4.176s

OK

After deleting the lwp file is gives

D:\pwb\GIT\core>pwb -lang:en script_tests -v TestScriptGenerator.test_basic
tests: max_retries reduced from 15 to 1
create_isbn_edition depends on isbnlib, which isn't available
setUpClass (__main__.TestScriptGenerator) ... skipped 'TestScriptGenerator: Not able to login to wikipedia:en'

----------------------------------------------------------------------
Ran 0 tests in 1.726s

OK (skipped=1)

What should be happen:
Always login if required

Related Objects

Event Timeline

Xqt triaged this task as High priority.Jan 12 2023, 7:02 AM

I'm getting the same "No user is logged in" warning, but an explicit login doesn't help. Regular edits are saved as the correct username, but currently I cannot use patrol.py:

ERROR: User "None" does not have required user right "patrol" (UserRightsError)

Note that I was using the stable branch to hopefully prevent problems like this. I have reverted to 7.7.3 to be able to run patrol.py again.

I'm getting the same "No user is logged in" warning, but an explicit login doesn't help. Regular edits are saved as the correct username, but currently I cannot use patrol.py:

ERROR: User "None" does not have required user right "patrol" (UserRightsError)

I am not sure if T330488 is the same. @Dalba suggested to use site.login() within the script and it works, but is really a workaround.

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

[pywikibot/core@master] [bugfix] No longer lazy load cookies

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

Change 906547 merged by Xqt:

[pywikibot/core@master] [bugfix] No longer lazy load cookies

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

Xqt claimed this task.

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

[pywikibot/core@stable] [bugfix] No longer lazy load cookies

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

Change 908207 merged by Xqt:

[pywikibot/core@stable] [bugfix] No longer lazy load cookies

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

Tried on master and on stable, still getting ERROR: User "None" does not have required user right "patrol" (UserRightsError).

When doing:

python pwb.py login.py
python pwb.py patrol -family:wiktionary -newpages -pt:1

Tried on master and on stable, still getting ERROR: User "None" does not have required user right "patrol" (UserRightsError).

When doing:

python pwb.py login.py
python pwb.py patrol -family:wiktionary -newpages -pt:1

Wasn't able to reproduce it. Did you run python pwb.py login.py -family:wiktionary and do you have an entry like usernames['wiktionary']['<your preferred site code>'] = '<yourbotname>'] in your user-config.py?

After running login.py with -family:wiktionary it works. I didn't realize I'd have to login on every site separately.

After running login.py with -family:wiktionary it works. I didn't realize I'd have to login on every site separately.

obviously unified login works for all sites if a family but is does not work for different families. Maybe this can be a separate task to implement it. Unfortunately the cookie files aren't read to check whether a family is logged in which makes it complicate.

Obviously that wasn't obvious to me.

But why is this task resolved? It is still very possible for Pywikibot to "have a status which is neither logged in nor logged out". Is it OK for Pywikibot to think that the user is None with some API calls and not None with other API calls?