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.

@agammann agammann left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using an explicit is None fallback preserves a caller-supplied logger or output stream even when its truth value is false. The new tests exercise a falsey logger and a falsey file for both trace settings, and check that messages do not fall through to stderr. I reviewed the source and tests; I did not run them locally.

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.

2 participants