Rafidaslam has uploaded a new change for review. ( https://gerrit.wikimedia.org/r/402653 )
Change subject: imagecopy: Raise Tkinter ImportError before the first call of it ...................................................................... imagecopy: Raise Tkinter ImportError before the first call of it Raise `Tkinter` ImportError (if there's any) before the first call of `Tkinter` instead of raising it on the top of the module, so we don't get `Tkinter` ImportError when Tkinter fails to import when we import the `imagecopy` module, especially from the tests module. Change-Id: Iaf9195fc0e7096f0c1fa15869f6e720a489545fb --- M scripts/imagecopy.py 1 file changed, 7 insertions(+), 6 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/pywikibot/core refs/changes/53/402653/1 diff --git a/scripts/imagecopy.py b/scripts/imagecopy.py index 377f3c6..9424c52 100644 --- a/scripts/imagecopy.py +++ b/scripts/imagecopy.py @@ -54,7 +54,7 @@ # # Another rewrite by: # (C) Multichill 2008-2011 -# (C) Pywikibot team, 2007-2017 +# (C) Pywikibot team, 2007-2018 # # Distributed under the terms of the MIT license. # @@ -76,18 +76,15 @@ from scripts import image if not PY2: - import tkinter as Tkinter - from urllib.parse import urlencode from urllib.request import urlopen else: - import Tkinter - from urllib import urlencode, urlopen try: - from pywikibot.userinterfaces.gui import Tkdialog + from pywikibot.userinterfaces.gui import Tkdialog, Tkinter except ImportError as _tk_error: + Tkinter = _tk_error Tkdialog = object NL = '' @@ -383,6 +380,10 @@ def __init__(self, image_title, content, uploader, url, templates, commonsconflict=0): """Constructor.""" + # Check if `Tkinter` wasn't imported + if isinstance(Tkinter, ImportError): + raise Tkinter + super(TkdialogIC, self).__init__() self.root = Tkinter.Tk() # "%dx%d%+d%+d" % (width, height, xoffset, yoffset) -- To view, visit https://gerrit.wikimedia.org/r/402653 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Iaf9195fc0e7096f0c1fa15869f6e720a489545fb Gerrit-PatchSet: 1 Gerrit-Project: pywikibot/core Gerrit-Branch: master Gerrit-Owner: Rafidaslam <rafidt...@gmail.com> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits