Page MenuHomePhabricator

Parsing error for Link instances
Closed, ResolvedPublic


Originally from:
Reported by: xqt
Created on: 2013-07-14 14:07:44.612000
Subject: Parsing error for Link instances
Original description:
I get a parsing error for Link.parse() e.g. for the following statements:

>>> import pwb; import pywikibot as wp
>>> l = wp.Link(u'w:de:Foo')
>>> l
Traceback (most recent call last):
  File "<pyshell#135>", line 1, in <module>
  File "pywikibot\", line 2931, in __repr__
    return ", %r)" % (self.title,
  File "pywikibot\", line 3101, in title
  File "pywikibot\", line 3007, in parse
    % self._text)
Error: Improperly formatted interwiki link 'w:de:Foo'

using wikipedia: instead of w: the Link is wrong:

>>> l = wp.Link(u'wikipedia:de:Foo')
>>> l'De:Foo', Site("de", "wikipedia"))

It works right for wikt: and wiktionary:

>>> l = wp.Link(u'wikt:de:Foo')
>>> l'Foo', Site("de", "wiktionary"))
>>> l = wp.Link(u'wikt:de:Foo')
>>> l'Foo', Site("de", "wiktionary"))
>>> l = wp.Link(u'wiktionary:de:Foo')
>>> l'Foo', Site("de", "wiktionary"))

Version: core-(2.0)
Severity: normal
See Also:



Related Objects


Event Timeline

bzimport raised the priority of this task from to High.Nov 22 2014, 2:21 AM
bzimport set Reference to bz55133.
bzimport added a subscriber: Unknown Object (????).

@Xqt: if you have set family = 'wikipedia' and mylang = 'de' in your, the parser may get confused about interwiki links to the same family.

Anyway either u'w:de:Foo' or u'wikipedia:de:Foo' are valid links and Link.parse() should be able to deal with them

Change 149629 had a related patch set uploaded by John Vandenberg:
Add basic tests for Link(), with 34 errors

Change 149629 merged by jenkins-bot:
Add basic tests for Link(), with 20 errors

Tests in; time for some fixes.

jayvdb claimed this task.

The bugs in Link which were identified by those tests are all fixed. And:

>>> import pywikibot
>>> = 'wikipedia'
>>> pywikibot.config.mylang = 'de'
>>> l = wp.Link(u'w:de:Foo')
>>> l'Foo', Site("de", "wikipedia"))

So I think we are done here.