Skip to content

Preserve falsey supplied loggers and output files - #1345

Open
Quinnod345 wants to merge 1 commit into
python-hyper:masterfrom
Quinnod345:fix/preserve-falsey-logging
Open

Quinnod345 wants to merge 1 commit into
python-hyper:masterfrom
Quinnod345:fix/preserve-falsey-logging

Conversation

@Quinnod345

Copy link
Copy Markdown

Passing a conforming custom logger whose empty record buffer makes it falsey to H2Configuration(logger=...) silently replaces it with DummyLogger. OutputLogger(file=...) has the same fallback for a valid falsey writable stream, so its output goes to stderr instead of the selected stream.

Select the defaults only when the argument is None. The new regressions cover an empty logger and a falsey writable stream with trace enabled and disabled. The existing default tests continue to pass.

Validation on CPython 3.13.11/macOS:

  • The three new regressions fail on upstream a90a82d before the implementation changes.
  • All 69 configuration tests and the complete 1,687-test suite pass after the change.
  • The project-required 100% line and branch coverage, source Ruff checks and strict-bytes Mypy checks pass.

I maintain Ponder. Its review flagged this case; the regressions reproduce it.

Choose the default logger and output stream only for None. Conforming
objects with an empty record buffer or a false truth value must retain
their identity and receive the requested debug and trace output.

Add regressions for a falsey logger and both trace modes of a falsey
writable stream. All three fail before the repair. The 69 configuration
tests and 1687-test suite pass afterward on CPython3.13.11/macOS, with
100% line and branch coverage, source Ruff and strict-bytes Mypy.