Page MenuHomePhabricator crashes when run against private wikis
Closed, ResolvedPublicBUG REPORT


Steps to Reproduce:

./ privatefamily

Actual Results:

Generating family file from
Private wiki detected. Login is required.
Please enter your username? Valid User
Traceback (most recent call last):
  File "", line 227, in <module>
  File "", line 56, in run
    self.wikis[w.lang] = w
AttributeError: 'MWSite' object has no attribute 'lang'
CRITICAL: Exiting due to uncaught exception <class 'AttributeError'>

You get some extra info if you force logging on:

VERBOSE:pywiki:MW 1.17+ detection failed: TypeError('Abstract Family class Family cannot be instantiated; subclass it instead',)

Event Timeline

What is the output of python version?

family and mylang are not set.
Defaulting to family='test' and mylang='test'.
Pywikibot: [ssh] home-gary-git-pywikibot (457ec40, g11595, 2019/10/17, 16:40:40, OUTDATED)
Release version: 3.1.dev0
requests version: 2.22.0
  cacerts: /home/gary/.local/lib/python3.6/site-packages/certifi/cacert.pem
    certificate test: ok
Python: 3.6.8 (default, Jun 11 2019, 15:15:01) 
[GCC 4.8.5 20150623 (Red Hat 4.8.5-39)]
Config base dir: /home/gary/projects/pywikibot

It's more-or-lest recent git, with the patch from on top.

The error message is not clear, but it seems to me Pywikibot can not detect wiki API at the url given. MWSite should change to Site immediately after MediaWiki API is found, thus lang should work correctly after that, which it doesn't. What MW version does your wiki use?

Or wiki API has been detected, but Pywikibot can not read from API somehow. Anyway this only happens with your patch, I hope this is the issue of yout implementation then.

And I agree with @zhuyifei1999, you should save the login credentials to your OS connection config and not deal with them inside Pywikibot's code, at least not this way at this place on every fetch. This just doesn't look right to me and I'm not much surprised it does not actually work.

Xqt triaged this task as Medium priority.Oct 17 2019, 11:18 PM

Change 543107 had a related patch set uploaded (by Gary Benson; owner: Gary Benson):
[pywikibot/core@master] [bugfix] Fix for private wikis

@Dvorapa, change 542456 is unrelated to this failure, I can reproduce this failure with unmodified PyWikibot.

I've uploaded an updated fix for this task, change 543107, with a testcase:

nosetests-3 -v tests.site_detect_tests.PrivateWikiTestCase

You can revert the fix and watch the test fail :)

Change 543107 merged by jenkins-bot:
[pywikibot/core@master] [bugfix] Fix for private wikis