saper added a comment.
After fighting this for some time now today I figure out that `pywikibot.userinterfaces` are indeed the root case of T281643: Pywikibot: avoid double logging of output <https://phabricator.wikimedia.org/T281643>. If I comment out the interface initialization: diff --git a/pywikibot/bot.py b/pywikibot/bot.py index 8a369a6dd..ce4c703b1 100644 --- a/pywikibot/bot.py +++ b/pywikibot/bot.py @@ -532,7 +532,7 @@ def writelogheader() -> None: _log('=' * 57) -add_init_routine(init_handlers) +# add_init_routine(init_handlers) # User input functions ... then I can enable propagation and nothing bad happens: """ Test for https://phabricator.wikimedia.org/T281643 """ import pywikibot import logging pywikibot.output("Normal output") logger = logging.getLogger('pywiki') logger.setLevel(logging.INFO) # set for other logging purposes logging.basicConfig(level=logging.WARNING) # Undo https://gerrit.wikimedia.org/r/c/pywikibot/core/+/785879 logger.propagate = True pywikibot.output("Double output") logger.setLevel(logging.WARNING) pywikibot.output("No output") This produces the following output only: INFO:pywiki:Double output Unfortunately, just `import pywikibot` will cause initialization, because it imports `bot` submodule and during the import `add_init_routine(init_handlers)` is called. This is unexpected; this should happen only if I am explicitly using `bot` submodule interface. I think `add_init_routine` should be moved away. TASK DETAIL https://phabricator.wikimedia.org/T326650 EMAIL PREFERENCES https://phabricator.wikimedia.org/settings/panel/emailpreferences/ To: saper Cc: saper, Xqt, William_Avery, Aklapper, pywikibot-bugs-list, RoySmith, mevo, PotsdamLamb, Jyoo1011, JohnsonLee01, SHEKH, Dijkstra, Khutuck, Zkhalido, Aram, Viztor, Wenyi, Tbscho, MayS, Mdupont, JJMC89, Dvorapa, Altostratus, Avicennasis, Hannolans, mys_721tx, jayvdb, Masti, Alchimista
_______________________________________________ pywikibot-bugs mailing list -- [email protected] To unsubscribe send an email to [email protected]
