Skip to content

[Code scan] Import logging.handlers before simplify SMTP setup #1911

Description

@njzjz

This issue is from a Codex global scan of the repository.

simplify.run_iter() crashes when SMTP logging handlers are configured because logging.handlers is not imported.

Evidence:

import glob
import logging
import os
import queue
from collections import defaultdict

if mdata.get("handlers", None):
if mdata["handlers"].get("smtp", None):
que = queue.Queue(-1)
queue_handler = logging.handlers.QueueHandler(que)
smtp_handler = logging.handlers.SMTPHandler(**mdata["handlers"]["smtp"])
listener = logging.handlers.QueueListener(que, smtp_handler)
dlog.addHandler(queue_handler)
listener.start()

The module imports logging, but not logging.handlers. In Python, import logging alone does not expose logging.handlers, so any mdata["handlers"]["smtp"] configuration raises AttributeError: module 'logging' has no attribute 'handlers' before the workflow starts.

Expected behavior: import logging.handlers before using QueueHandler, SMTPHandler, and QueueListener, as the generator path does implicitly/explicitly where needed.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    Status
    Todo

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions