Skip to content

Running the tests on Python 3.13 fails with debug logging enables #605

Closed as duplicate

Description

@jelly

When running the tests on Python 3.13 the test run fails due to logging exceptions. This did not happen under Python 3.12:

Traceback (most recent call last):
  File "/usr/lib/python3.13/logging/__init__.py", line 1153, in emit
    stream.write(msg + self.terminator)
    ~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^
ValueError: I/O operation on closed file.
Call stack:
  File "/usr/lib/python3.13/threading.py", line 1012, in _bootstrap
    self._bootstrap_inner()
  File "/usr/lib/python3.13/threading.py", line 1041, in _bootstrap_inner
    self.run()
  File "/usr/lib/python3.13/threading.py", line 1342, in run
    self.function(*self.args, **self.kwargs)
  File "/build/python-lsp-server/src/python-lsp-server-1.12.0/pylsp/_utils.py", line 43, in run
    return func(*args, **kwargs)
  File "/build/python-lsp-server/src/python-lsp-server-1.12.0/pylsp/python_lsp.py", line 445, in lint
    self._lint_text_document(
  File "/build/python-lsp-server/src/python-lsp-server-1.12.0/pylsp/python_lsp.py", line 456, in _lint_text_document
    flatten(self._hook("pylsp_lint", doc_uri, is_saved=is_saved)),
  File "/build/python-lsp-server/src/python-lsp-server-1.12.0/pylsp/python_lsp.py", line 260, in _hook
    return hook_handlers(
  File "/usr/lib/python3.13/site-packages/pluggy/_hooks.py", line 513, in __call__
    return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult)
  File "/build/python-lsp-server/src/python-lsp-server-1.12.0/pylsp/config/config.py", line 39, in _hookexec
    return self._inner_hookexec(hook_name, methods, kwargs, firstresult)
  File "/usr/lib/python3.13/site-packages/pluggy/_manager.py", line 476, in traced_hookexec
    outcome = Result.from_call(
  File "/usr/lib/python3.13/site-packages/pluggy/_result.py", line 62, in from_call
    result = func()
  File "/usr/lib/python3.13/site-packages/pluggy/_manager.py", line 477, in <lambda>
    lambda: oldcall(hook_name, hook_impls, caller_kwargs, firstresult)
  File "/usr/lib/python3.13/site-packages/pluggy/_callers.py", line 103, in _multicall
    res = hook_impl.function(*args)
  File "/build/python-lsp-server/src/python-lsp-server-1.12.0/pylsp/plugins/mccabe_lint.py", line 23, in pylsp_lint
    log.debug("Running mccabe lint with threshold: %s", threshold)
Message: 'Running mccabe lint with threshold: %s'
Arguments: (15,)
--- Logging error ---

I've worked around the issue by disabling the DEBUG loglevel in conftest.py and replaced it with INFO and then all the tests pass.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions