Page MenuHomePhabricator

UserWarning: Site wikipedia:be-tarask instantiated using different code "be-x-old"
Open, Needs TriagePublic

Description

When I run any script, this shows as warning: UserWarning: Site wikipedia:be-tarask instantiated using different code "be-x-old"

See example output:

kizule@kizule:~/development/pywikibot-core$ python3 pwb.py disambredir
/home/kizule/development/pywikibot-core/pywikibot/config2.py:1138: _ConfigurationDeprecationWarning: "sysopnames" present in our user-config.py is no longer a supported configuration variable. Please inform the maintainers if you depend on it.
  'depend on it.'.format(_key), _ConfigurationDeprecationWarning)
WARNING: /home/kizule/development/pywikibot-core/pywikibot/site.py:1893: UserWarning: Site wikipedia:be-tarask instantiated using different code "be-x-old"
  return pywikibot.Site(lang, site['code'])

Upstream: T235505: Rename be-x-old as be-tarask in Wikidata
Related: T111853: The href of be-tarask: interlanguage link points to the be-x-old domain

Event Timeline

On which site are you running that script? And what do you mean with "running any script"? The warning is valid as long as the script finds this old identifier.

On which site are you running that script? And what do you mean with "running any script"? The warning is valid as long as the script finds this old identifier.

Serbian Wikipedia. Running any script means running each script which pywikibot have throws this warning.

I have been getting this occasionally too. It does not occur every time (indeed, it happens rarely) so I am guessing there is a condition race going on somewhere in the code.

In further investigation: it happens only when I use pywikibot to query an item on Wikidata that has a sitelink for be_x_old, such as Q4048908. I am not sure why wikidata shows those sitelinks as be_x_old when the link itself goes to a page like be-tarask.wikipedia.or/wiki/foobar but in any case, I don't think fixing it upstream in Wikidata would be a realistic answer here. So my proposal is: when we run into be_x_old in a Wikidata query, we should gracefully ignore that and not show the warning above.

@Xqt what do you think?


Here is a piece of code that gives me the error every time:

page = pywikibot.Page(pywikibot.Site('en', 'wikipedia'), 'Category:Hidden categories')
item = pywikibot.ItemPage.fromPage(page)

The following patch might help: https://gerrit.wikimedia.org/r/#/c/mediawiki/extensions/WikimediaMaintenance/+/587863/
Two months waiting for a review

Still occurres with the sample given by Huji above. Wikidata accepts be_x_old as site code but it does not accept be-tarask.

Well, the patch to wikis will be deployed next thursday, then we can test, how our issues with be-tarask/be-x-old changed

In fact, I think after the patch to wiki is deployed (next week) some additional step needs to be taken (@Ladsgroup described it as "rebuild the interwiki cache" but I am not sure the effort involved) so it may take a bit longer until we can actually test this.

(@Ladsgroup described it as "rebuild the interwiki cache" but I am not sure the effort involved) so it may take a bit longer until we can actually test this.

It's just one command to be run, quick and easy to do.

Xqt claimed this task.
Xqt removed Xqt as the assignee of this task.Aug 3 2020, 10:24 AM

This isn't solved. The warning still occures.

Change 677383 had a related patch set uploaded (by Damian; author: Damian):

[pywikibot/core@master] [tests] Suppress all warnings

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

Change 677383 merged by jenkins-bot:

[pywikibot/core@master] [tests] Suppress all warnings

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