jenkins-bot has submitted this change and it was merged.
Change subject: Bug 58053 - py3k-ify pwb.py, check py version
......................................................................
Bug 58053 - py3k-ify pwb.py, check py version
- Use builtins instead of __builtin__
- Check for PY3 environment variable before complaining
- check for the right py version including py3k
Change-Id: If9090c10cf00154b275053fc2aa60f33ba85181b
---
M pwb.py
1 file changed, 21 insertions(+), 6 deletions(-)
Approvals:
Xqt: Looks good to me, but someone else must approve
Merlijn van Deen: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pwb.py b/pwb.py
index ae9190a..86c9b9e 100644
--- a/pwb.py
+++ b/pwb.py
@@ -48,7 +48,10 @@
main_mod = imp.new_module('__main__')
sys.modules['__main__'] = main_mod
main_mod.__file__ = filename
- main_mod.__builtins__ = sys.modules['__builtin__']
+ if sys.version_info[0] == 2:
+ main_mod.__builtins__ = sys.modules['__builtin__']
+ else:
+ main_mod.builtins = sys.modules['builtins']
# Set sys.argv and the first path element properly.
old_argv = sys.argv
@@ -73,11 +76,23 @@
#### end of snippet
-if sys.version_info[0] != 2:
- raise RuntimeError("ERROR: Pywikipediabot only runs under Python 2")
-if sys.version_info[1] < 6:
- raise RuntimeError("ERROR: Pywikipediabot only runs under Python 2.6 "
- "or higher")
+if not os.environ.get("PY3", False):
+ if sys.version_info[0] != 2:
+ raise RuntimeError("ERROR: Pywikibot only runs under Python 2")
+ if sys.version_info[1] < 6:
+ raise RuntimeError("ERROR: Pywikibot only runs under Python 2.6 "
+ "or higher")
+else:
+ if sys.version_info[0] not in (2, 3):
+ raise RuntimeError("ERROR: Pywikipediabot only runs under Python 2 "
+ "or Python 3")
+ version = tuple(sys.version_info)[:3]
+ if version < (2, 6):
+ raise RuntimeError("ERROR: Pywikibot only runs under Python 2.6 "
+ "or higher")
+ if version >= (3, ) and version < (3, 3):
+ raise RuntimeError("ERROR: Pywikibot only runs under Python 3.3 "
+ "or higher")
rewrite_path = os.path.dirname(sys.argv[0])
if not os.path.isabs(rewrite_path):
--
To view, visit https://gerrit.wikimedia.org/r/98385
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: If9090c10cf00154b275053fc2aa60f33ba85181b
Gerrit-PatchSet: 8
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Merlijn van Deen <[email protected]>
Gerrit-Reviewer: Ladsgroup <[email protected]>
Gerrit-Reviewer: Merlijn van Deen <[email protected]>
Gerrit-Reviewer: Xqt <[email protected]>
Gerrit-Reviewer: jenkins-bot
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits