jenkins-bot has submitted this change and it was merged. ( 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` and
`imagecopy_self` module, especially from the tests module.
Change-Id: Iaf9195fc0e7096f0c1fa15869f6e720a489545fb
---
M scripts/imagecopy.py
M scripts/imagecopy_self.py
M tests/script_tests.py
3 files changed, 14 insertions(+), 19 deletions(-)
Approvals:
John Vandenberg: Looks good to me, approved
jenkins-bot: Verified
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)
diff --git a/scripts/imagecopy_self.py b/scripts/imagecopy_self.py
index ab34888..dcbc8f1 100644
--- a/scripts/imagecopy_self.py
+++ b/scripts/imagecopy_self.py
@@ -44,7 +44,7 @@
# English Wikipedia specific bot by:
# (C) Multichill 2010-2012
#
-# (C) Pywikibot team, 2010-2017
+# (C) Pywikibot team, 2010-2018
#
# Distributed under the terms of the MIT license.
#
@@ -66,17 +66,14 @@
from scripts import imagerecat, image
if not PY2:
- import tkinter as Tkinter
-
from queue import Queue
else:
- import Tkinter
-
from Queue import Queue
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 = ''
@@ -694,6 +691,10 @@
categories
"""
"""Constructor."""
+ # Check if `Tkinter` wasn't imported
+ if isinstance(Tkinter, ImportError):
+ raise Tkinter
+
self.root = Tkinter.Tk()
# "%dx%d%+d%+d" % (width, height, xoffset, yoffset)
# Always appear the same size and in the bottom-left corner
diff --git a/tests/script_tests.py b/tests/script_tests.py
index 249ae42..77c516b 100644
--- a/tests/script_tests.py
+++ b/tests/script_tests.py
@@ -25,19 +25,12 @@
archive_path = join_root_path('scripts', 'archive')
-if PY2:
- TK_IMPORT = 'Tkinter'
-else:
- TK_IMPORT = 'tkinter'
-
# These dependencies are not always the package name which is in setup.py.
# e.g. 'PIL.ImageTk' is a object provided by several different pypi packages,
# and setup.py requests that 'Pillow' is installed to provide 'PIL.ImageTk'.
# Here, it doesnt matter which pypi package was requested and installed.
# Here, the name given to the module which will be imported is required.
script_deps = {
- 'imagecopy': [TK_IMPORT],
- 'imagecopy_self': [TK_IMPORT],
'script_wui': ['crontab', 'lua'],
# Note: package 'lunatic-python' provides module 'lua'
'flickrripper': ['flickrapi'],
--
To view, visit https://gerrit.wikimedia.org/r/402653
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Iaf9195fc0e7096f0c1fa15869f6e720a489545fb
Gerrit-PatchSet: 4
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Rafidaslam <rafidteam(a)gmail.com>
Gerrit-Reviewer: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: Rafidaslam <rafidteam(a)gmail.com>
Gerrit-Reviewer: Zoranzoki21 <zorandori4444(a)gmail.com>
Gerrit-Reviewer: jenkins-bot <>
jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/402650 )
Change subject: TerminalHandler.emit: Do not omit the last line even if it seems to be warn()
......................................................................
TerminalHandler.emit: Do not omit the last line even if it seems to be warn()
In T184368 we have a case that useful warning info are removed from the output.
This patch removes the lines responsible for removing the last line of a
warning message that appears to be a warn call.
In Pywikibot we usually fix warning stacklevel inside the warning
decorators (e.g. in issue_deprecation_warning). Even if we did not, we can
fix the code. Therefore, it seems unnecessary to remove the last line,
especially with the risk of removing useful information.
Bug: T184368
Change-Id: Iaf4b1dfb8939ce76b670e44f882e45504279a60a
---
M pywikibot/userinterfaces/terminal_interface_base.py
1 file changed, 0 insertions(+), 9 deletions(-)
Approvals:
jenkins-bot: Verified
Xqt: Looks good to me, approved
diff --git a/pywikibot/userinterfaces/terminal_interface_base.py b/pywikibot/userinterfaces/terminal_interface_base.py
index c37cc9e..7bc017c 100755
--- a/pywikibot/userinterfaces/terminal_interface_base.py
+++ b/pywikibot/userinterfaces/terminal_interface_base.py
@@ -510,15 +510,6 @@
if 'message' in record.__dict__:
return
- # Remove the last line, if it appears to be the warn() call
- msg = record.args[0]
- is_useless_source_output = any(
- s in msg for s in
- (str('warn('), str('exceptions.'), str('Warning)'), str('Warning,')))
-
- if is_useless_source_output:
- record.args = ('\n'.join(record.args[0].splitlines()[0:-1]),)
-
if 'newline' not in record.__dict__:
record.__dict__['newline'] = '\n'
--
To view, visit https://gerrit.wikimedia.org/r/402650
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Iaf4b1dfb8939ce76b670e44f882e45504279a60a
Gerrit-PatchSet: 2
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Dalba <dalba.wiki(a)gmail.com>
Gerrit-Reviewer: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: Zoranzoki21 <zorandori4444(a)gmail.com>
Gerrit-Reviewer: jenkins-bot <>
jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/402588 )
Change subject: ModuleDeprecationWrapper._add_deprecated_attr: Delete existing attribute
......................................................................
ModuleDeprecationWrapper._add_deprecated_attr: Delete existing attribute
In Python __getattr__ is only invoked if object does not have the requested
attribute. If the deprecated module has the attribute, then the __getattr__
method of ModuleDeprecationWrapper will not be invoked and therefore no
warning will be issued.
Bug: T184337
Change-Id: I4193481a0bd1b2fa310f15a8bddb7a4e2f090134
---
M pywikibot/tools/__init__.py
1 file changed, 3 insertions(+), 0 deletions(-)
Approvals:
jenkins-bot: Verified
Xqt: Looks good to me, approved
diff --git a/pywikibot/tools/__init__.py b/pywikibot/tools/__init__.py
index b9c99e0..8acdf51 100644
--- a/pywikibot/tools/__init__.py
+++ b/pywikibot/tools/__init__.py
@@ -1733,6 +1733,9 @@
else:
warning_message = u"{0}.{1} is deprecated."
+ if hasattr(self, name):
+ # __getattr__ will only be invoked if self.<name> does not exist.
+ delattr(self, name)
self._deprecated[name] = replacement_name, replacement, warning_message
def __setattr__(self, attr, value):
--
To view, visit https://gerrit.wikimedia.org/r/402588
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I4193481a0bd1b2fa310f15a8bddb7a4e2f090134
Gerrit-PatchSet: 1
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Dalba <dalba.wiki(a)gmail.com>
Gerrit-Reviewer: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: Zoranzoki21 <zorandori4444(a)gmail.com>
Gerrit-Reviewer: jenkins-bot <>