jenkins-bot merged this change.

View Change

Approvals: Xqt: Looks good to me, approved jenkins-bot: Verified
page.Link.langlinkUnsafe: Always set _namespace to a Namespace object

APISite.pagelanglinks creates link objects using Link.langlinkUnsafe.
If the links was in the main namespace, Page(link).namespace() was an
int object which caused attribute errors.

Fix the docstring of NamespacesDict.__getattr__.

Bug: T203491
Change-Id: Ic2ab6707a88f2980049b92517cb98713f9e6a14e
---
M pywikibot/page.py
M pywikibot/site.py
2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/pywikibot/page.py b/pywikibot/page.py
index a249933..126fb95 100644
--- a/pywikibot/page.py
+++ b/pywikibot/page.py
@@ -5897,14 +5897,14 @@
link._section = None
link._source = source

- link._namespace = 0
-
+ link._namespace = link._site.namespaces[0]
if ':' in title:
ns, t = title.split(':', 1)
ns = link._site.namespaces.lookup_name(ns)
if ns:
link._namespace = ns
title = t
+
if u"#" in title:
t, sec = title.split(u'#', 1)
title, link._section = t.rstrip(), sec.lstrip()
diff --git a/pywikibot/site.py b/pywikibot/site.py
index d48f808..5ac00c9 100644
--- a/pywikibot/site.py
+++ b/pywikibot/site.py
@@ -543,8 +543,8 @@
"""
Get the namespace with the given key.

- @param key: namespace key
- @type key: Namespace, int or str
+ @param attr: namespace key
+ @type attr: Namespace, int or str
@rtype: Namespace
"""
# lookup_name access _namespaces

To view, visit change 458359. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: Ic2ab6707a88f2980049b92517cb98713f9e6a14e
Gerrit-Change-Number: 458359
Gerrit-PatchSet: 6
Gerrit-Owner: Dalba <dalba.wiki@gmail.com>
Gerrit-Reviewer: John Vandenberg <jayvdb@gmail.com>
Gerrit-Reviewer: Xqt <info@gno.de>
Gerrit-Reviewer: jenkins-bot (75)