Page MenuHomePhabricator interwiki is mw or mediawikiwiki, not mediawiki
Open, HighPublic


Steps to reproduce

  1. $ python shell
  2. insite = pywikibot.Site('cs') # or whatever else than mediawiki
  3. site = pywikibot.Site('mediawiki', 'mediawiki')
  4. pywikibot.Page(site, 'Page in site', insite=insite)


  1. $ python shell -family="wikipedia" -lang="cs" # or whatever else than mediawiki
  2. site = pywikibot.Site('mediawiki', 'mediawiki')
  3. pywikibot.Page(site, 'Page in site')

Expected behavior
The link should point from insite to site correctly.

Current behavior
The produced link is red, because it looks like: [[mediawiki:Page in site]], which is not valid mediawiki interwiki. See an example.

Python 3.6.4, Pywikibot latest commit in master

Event Timeline

Yes, I can confirm this. Dvorapa already added example which happening on my private wiki. :)

insite parameter of pywikibot.Page uses code of a specified Site. For Mediawiki (single site family) the code is the same as family: mediawiki. But interwiki is only either mediawikiwiki or mw. Therefore insite parameter should get and use interwiki prefix of the specified Site, not the actual code

Liuxinyu970226 renamed this task from Mediawiki interwiki is mw or mediawikiwiki, not mediawiki to interwiki is mw or mediawikiwiki, not mediawiki.Feb 24 2018, 9:48 AM
Xqt triaged this task as High priority.Feb 24 2018, 10:03 AM

I never noticed that. Seems this is to differentiate from MediaWiki namespace whereas the interwiki link for commonswiki is commons and the interwiki link for wikidatawiki is wikidata.

Change 414070 had a related patch set uploaded (by Zoranzoki21; owner: Xqt):
[pywikibot/core@master] [bugfix] iw link for mediawiki is mediawikiwiki

if insite:
    target_code = insite.code
    target_family =
    target_code = config.mylang
    target_family =
if force_interwiki or \
    and ( != target_family
         or != target_code)):
    if != target_family \
       and !=
        title = '%s:%s:%s' % (
  ,, title)
        # use this form for sites like commons, where the
        # code is the same as the family name
        title = '%s:%s' % (, title)

The last line causes this issue.

In my opinion it should use Site.interwiki_prefix() instead of Site.code (and the lines above too in some way).

Site.interwiki_prefix() needs to be fixed before:

The same issue is for test / testwiki

Change 509538 had a related patch set uploaded (by Dvorapa; owner: Dvorapa):
[pywikibot/core@master] [bugfix] Fix mediawikiwiki and testwiki shortcuts

Aklapper removed Xqt as the assignee of this task.Jul 2 2021, 5:15 AM

Removing task assignee due to inactivity, as this open task has been assigned for more than two years (see emails sent to assignee on May26 and Jun17, and T270544). Please assign this task to yourself again if you still realistically [plan to] work on this task - it would be very welcome!

(See for tips how to best manage your individual work in Phabricator.)