Skip to content

Update llbase JSON logging for Python 3.13 compatibility #21

Description

@serhii-zhbanov-pe

llbase.lljsonlog.JsonFormatter currently imports and supports cgitb for exception formatting. The cgitb module was removed in Python 3.13, so any code path that imports llbase.lljsonlog can fail or require local workarounds when running on Python 3.13.

We recently worked around this in the Join Django app by adding an internal JSON log formatter that is compatible with llbase.lljsonlog.JsonFormatter but does not import cgitb. That workaround keeps Join unblocked, but the underlying compatibility issue still exists in the shared python-llbase library.

Current library location:

llbase/lljsonlog.py

Current problem areas:

  • import cgitb happens at module import time.
  • _fmt_exc_cgitb() depends on cgitb.Hook.
  • JsonFormatter(exception_formatter="cgitb") cannot be supported on Python 3.13 without a replacement implementation.
  • The module still carries Python 2 compatibility code, which may make the Python 3.13 update harder to reason about.

Expected outcome:

  • llbase.lljsonlog.JsonFormatter should be importable on Python 3.13.
  • The default traceback formatter should continue to work.
  • Existing users of JsonFormatter() should not need app-level replacements.
  • If exception_formatter="cgitb" is still needed, either provide a Python 3.13-safe replacement or clearly document/deprecate that option.
  • Add or update tests covering import and basic formatting behavior on supported Python versions.

This should let Join remove its local compatibility formatter once the shared library has a Python 3.13-compatible release.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions