XZise has uploaded a new change for review.

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

Change subject: [FIX] Site: Only store complete mapping
......................................................................

[FIX] Site: Only store complete mapping

If the site is interrupted while loading the namespaces the stored
namespaces might be invalid/incomplete. This bufferes the namespaces and
only stores it after the mapping has been build.

Bug: 73122
Change-Id: I64418dca1b66418dfb893b83f8d141b372bd2380
---
M pywikibot/site.py
1 file changed, 6 insertions(+), 4 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/pywikibot/core 
refs/changes/15/171815/1

diff --git a/pywikibot/site.py b/pywikibot/site.py
index 8cf9f60..b167707 100644
--- a/pywikibot/site.py
+++ b/pywikibot/site.py
@@ -2011,7 +2011,7 @@
         return self.getmagicwords("pagenamee")
 
     def _build_namespaces(self):
-        self._namespaces = SelfCallDict()
+        _namespaces = SelfCallDict()
 
         # In MW 1.14, API siprop 'namespaces' added 'canonical',
         # and Image became File with Image as an alias.
@@ -2034,12 +2034,14 @@
             namespace = Namespace(ns, canonical_name, custom_name,
                                   use_image_name=not is_mw114,
                                   **nsdata)
-            self._namespaces[ns] = namespace
+            _namespaces[ns] = namespace
 
         for item in self.siteinfo.get('namespacealiases'):
             ns = int(item['id'])
-            if item['*'] not in self._namespaces[ns]:
-                self._namespaces[ns].aliases.append(item['*'])
+            if item['*'] not in _namespaces[ns]:
+                _namespaces[ns].aliases.append(item['*'])
+
+        self._namespaces = _namespaces
 
     @need_version("1.14")
     @deprecated("has_extension")

-- 
To view, visit https://gerrit.wikimedia.org/r/171815
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I64418dca1b66418dfb893b83f8d141b372bd2380
Gerrit-PatchSet: 1
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: XZise <commodorefabia...@gmx.de>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to