jenkins-bot has submitted this change. ( https://gerrit.wikimedia.org/r/c/pywikibot/core/+/785341 )
Change subject: [bugfix] Prevent circular import in tools ......................................................................
[bugfix] Prevent circular import in tools
tools is imported by pywikibot earlier than logging import was completed. This lead the logging module to fail if it tries to import tools itself, e.g. deprecation wrappers.
Now import the logging module in tools instead of the debug function. This prevents the circular import exception.
Change-Id: I36526cd0fd29ce585b22506eee89f11e693d7183 --- M pywikibot/tools/__init__.py 1 file changed, 11 insertions(+), 9 deletions(-)
Approvals: Xqt: Looks good to me, approved jenkins-bot: Verified
diff --git a/pywikibot/tools/__init__.py b/pywikibot/tools/__init__.py index 3b68d81..3dcaa3c 100644 --- a/pywikibot/tools/__init__.py +++ b/pywikibot/tools/__init__.py @@ -28,7 +28,7 @@
import pkg_resources
-from pywikibot.logging import debug +import pywikibot.logging as _pylogging from pywikibot.tools._deprecate import ( # noqa: F401 skipcq: PY-W2000 ModuleDeprecationWrapper, add_decorated_full_name, @@ -504,8 +504,8 @@ 'Found "{}" in "{}"'.format(handled, version_match.group(2)) if version_match.group(2): - debug('Additional unused version part ' - '"{}"'.format(version_match.group(2))) + _pylogging.debug('Additional unused version part ' + '"{}"'.format(version_match.group(2))) self._dev_version = (4, )
self.suffix = version_match.group(2) or '' @@ -805,16 +805,17 @@
super().append(thd) thd.start() - debug("thread {} ('{}') started".format(len(self), type(thd))) + _pylogging.debug("thread {} ('{}') started" + .format(len(self), type(thd)))
def stop_all(self) -> None: """Stop all threads the pool.""" if self: - debug('EARLY QUIT: Threads: {}'.format(len(self))) + _pylogging.debug('EARLY QUIT: Threads: {}'.format(len(self))) for thd in self: thd.stop() - debug('EARLY QUIT: Queue size left in {}: {}' - .format(thd, thd.queue.qsize())) + _pylogging.debug('EARLY QUIT: Queue size left in {}: {}' + .format(thd, thd.queue.qsize()))
def intersect_generators(*iterables, allow_duplicates: bool = False): @@ -883,8 +884,9 @@ # If any iterable is empty, no pages are going to be returned for source in iterables: if not source: - debug('At least one iterable ({!r}) is empty and execution was ' - 'skipped immediately.'.format(source)) + _pylogging.debug('At least one iterable ({!r}) is empty and ' + 'execution was skipped immediately.' + .format(source)) return
# Item is cached to check that it is found n_gen times