Page MenuHomePhabricator

pywikibot warnings during early initialization, before pywikibot.bot.init_handlers, are not shown
Closed, ResolvedPublic

Description

Observed in T188246, warnings such as in config2.py is not shown (T188246#4006645), unless logging is preconfigued before running pwb.py (T188246#4006944). This may hinders users' and developers' ability to find the root cause of issues that happens during early initialization.

To reproduce, choose whatever method to invoke warning() in config2.py, such as, chown user-config.py to someone else (non-windows), chmod it to world-writable (non-windows), set PYWIKIBOT2_NO_USER_CONFIG to != 2 or 0, use invalid editor, unset family and language in user-config.py, etc. The warnings will be unexpectedly silenced.

Event Timeline

zhuyifei1999 renamed this task from pywikibot warnings during early initialization, before pywikibot.bot.init_handlersinit_handlers, are not shown to pywikibot warnings during early initialization, before pywikibot.bot.init_handlers, are not shown.Feb 27 2018, 6:23 PM
Dalba triaged this task as High priority.Feb 28 2018, 4:41 AM

I cannot reproduce this in Python 3.6.3. Probably a python2-only issue.

Python 3.2 has added a last resort handler: https://docs.python.org/3.2/library/logging.html#logging.lastResort
We can manually do that for python2 inside the logging module.
Patch coming...

Change 415248 had a related patch set uploaded (by Dalba; owner: Dalba):
[pywikibot/core@master] logging.py: Add a last resort logging handler for python 2

https://gerrit.wikimedia.org/r/415248

Xqt assigned this task to Dalba.

Change 415248 merged by jenkins-bot:
[pywikibot/core@master] logging.py: Add a last resort logging handler for python 2

https://gerrit.wikimedia.org/r/415248