jenkins-bot has submitted this change and it was merged.
Change subject: Fix missing i18n git submodule on Python 3
......................................................................
Fix missing i18n git submodule on Python 3
Avoid implicit namespace package in messages_available()
and twget_keys().
Raise OSError in twget_keys() when i18n can not be loaded.
Bug: T110174
Change-Id: I7454bb13d499661e1467227e06a3d57286cb1dd0
---
M pywikibot/i18n.py
1 file changed, 8 insertions(+), 2 deletions(-)
Approvals:
XZise: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/i18n.py b/pywikibot/i18n.py
index de78688..9607c87 100644
--- a/pywikibot/i18n.py
+++ b/pywikibot/i18n.py
@@ -81,8 +81,12 @@
if _messages_available is not None:
return _messages_available
try:
- __import__(_messages_package_name)
+ mod = __import__(_messages_package_name, fromlist=[str('__path__')])
except ImportError:
+ _messages_available = False
+ return False
+
+ if not os.listdir(next(iter(mod.__path__))):
_messages_available = False
return False
@@ -612,11 +616,13 @@
Return all language codes for a special message.
@param twtitle: The TranslateWiki string title, in <package>-<key>
format
+
+ @raises OSError: the package i18n can not be loaded
"""
# obtain the directory containing all the json files for this package
package = twtitle.split("-")[0]
mod = __import__(_messages_package_name, fromlist=[str('__file__')])
- pathname = os.path.join(os.path.dirname(mod.__file__), package)
+ pathname = os.path.join(next(iter(mod.__path__)), package)
# build a list of languages in that directory
langs = [filename.partition('.')[0]
--
To view, visit
https://gerrit.wikimedia.org/r/233688
To unsubscribe, visit
https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I7454bb13d499661e1467227e06a3d57286cb1dd0
Gerrit-PatchSet: 2
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: Ladsgroup <ladsgroup(a)gmail.com>
Gerrit-Reviewer: Siebrand <siebrand(a)kitano.nl>
Gerrit-Reviewer: XZise <CommodoreFabianus(a)gmx.de>
Gerrit-Reviewer: jenkins-bot <>