Page MenuHomePhabricator

atexit callback fails if an exception is raised in a very early state
Closed, ResolvedPublicBUG REPORT


List of steps to reproduce (step by step, including full links if applicable):

  • uninstall wikitextparser and mwparserfromhell
  • run pwb

What happens?:


Pywikibot is missing a MediaWiki markup parser which is necessary.
Please update the required module with either

    pip install "mwparserfromhell>=0.5.0"


    pip install "wikitextparser>=0.47.5"

Exception ignored in atexit callback: <function flush at 0x0000020C5DDD2EF0>
Traceback (most recent call last):
  File "C:\pwb\GIT\core\pywikibot\comms\", line 88, in flush
    log('Closing network session.')
  File "C:\pwb\GIT\core\pywikibot\", line 193, in log
    logoutput(text, decoder, newline, VERBOSE, **kwargs)
  File "C:\pwb\GIT\core\pywikibot\", line 79, in logoutput
  File "C:\pwb\GIT\core\pywikibot\", line 38, in _init
  File "C:\pwb\GIT\core\pywikibot\tools\", line 487, in wrapper
    return obj(*new_args, **new_kwargs)
  File "C:\pwb\GIT\core\pywikibot\", line 398, in init_handlers
    if pywikibot.Site.__doc__ != 'TEST':  # set by aspects.DisableSiteMixin
AttributeError: module 'pywikibot' has no attribute 'Site'


The reason might be that is not fully imported and the logger handler is not initialized when the atexit callback is called in this early state.

What should have happened instead?:

No exception should be shown

Software version (if not a Wikimedia wiki), browser information, screenshots, other information, etc:
Pywikibot 7.0 (master), 6.6.3 (stable). 6.5, 6.4, 6.3. It works as expected with 6.2

Event Timeline

Xqt triaged this task as Medium priority.Dec 30 2021, 8:11 AM

Change 750698 had a related patch set uploaded (by Xqt; author: Xqt):

[pywikibot/core@master] [bugfix] Don't greate a Site object if pywikibot is not fully imported

Change 750698 merged by jenkins-bot:

[pywikibot/core@master] [bugfix] Don't create a Site object if pywikibot is not fully imported

Xqt claimed this task.