Skip to content

Conversation

@MHendricks
Copy link
Collaborator

For windows based non-console apps sys.stderr can be None which causes a silent error. Switching to print accounts for this.

This prevents errors like this.

Traceback (most recent call last):
  File "C:\blur\dev\qt_py\src\Qt.py", line 1761, in _setup
    submodule = _import_sub_module(module, name)
  File "C:\blur\dev\qt_py\src\Qt.py", line 1737, in _import_sub_module
    module = __import__(module.__name__ + "." + name)
ImportError: DLL load failed while importing QtQuick: The specified procedure could not be found.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\blur\dev\qt_py\src\Qt.py", line 1766, in _setup
    submodule = __import__(name)
ModuleNotFoundError: No module named 'QtQuick'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\blur/freezer/plugins\managecannedbatchjobs.py", line 4, in <module>
    from Qt.QtCore import Qt
  File "C:\blur\dev\qt_py\src\Qt.py", line 2408, in <module>
    _install()
  File "C:\blur\dev\qt_py\src\Qt.py", line 2344, in _install
    available[name]()
  File "C:\blur\dev\qt_py\src\Qt.py", line 2096, in _pyqt5
    _setup(module, [])
  File "C:\blur\dev\qt_py\src\Qt.py", line 1768, in _setup
    _warn_import_error(e, name)
  File "C:\blur\dev\qt_py\src\Qt.py", line 1752, in _warn_import_error
    _warn("ImportError(%s): %s" % (module, msg))
  File "C:\blur\dev\qt_py\src\Qt.py", line 2158, in _warn
    sys.stderr.write
AttributeError: 'NoneType' object has no attribute 'write'

I used this code to allow me to capture the error without a console.

import sys
import traceback

def except_hook(*exc_info):
    f = open("C:/temp/test.log", "w")
    traceback.print_exception(*exc_info, file=f)

sys.excepthook = except_hook

For windows based non-console apps sys.stderr can be None which causes
a silent error. Switching to print accounts for this.
@MHendricks MHendricks merged commit 83cff23 into mottosso:master Jan 29, 2026
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant