Skip to content

Commit 2134a44

Browse files
authored
Fix interpolation in filtered log calls (#478)
Fixes #476
1 parent 87cdcaf commit 2134a44

File tree

3 files changed

+24
-2
lines changed

3 files changed

+24
-2
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,12 @@ This prevents crashes if something different than a string is passed for the *ev
2222
[#475](https://github.com/hynek/structlog/pull/475)
2323

2424

25+
### Fixed
26+
27+
- String interpolation doesn't cause crashes in filtered log call anymore.
28+
[#478](https://github.com/hynek/structlog/pull/478)
29+
30+
2531
## [22.2.0](https://github.com/hynek/structlog/compare/22.1.0...22.2.0) - 2022-11-19
2632

2733
### Deprecated

src/structlog/_log_levels.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,11 +71,11 @@ def add_log_level(
7171
return event_dict
7272

7373

74-
def _nop(self: Any, event: str, **kw: Any) -> Any:
74+
def _nop(self: Any, event: str, *args: Any, **kw: Any) -> Any:
7575
return None
7676

7777

78-
async def _anop(self: Any, event: str, **kw: Any) -> Any:
78+
async def _anop(self: Any, event: str, *args: Any, **kw: Any) -> Any:
7979
return None
8080

8181

tests/test_log_levels.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,22 @@ async def test_async_one_below(self, bl, cl):
6161

6262
assert [] == cl.calls
6363

64+
def test_filtered_interp(self, bl, cl):
65+
"""
66+
Passing interpolation args works if the log entry is filtered out.
67+
"""
68+
bl.debug("hello %s!", "world")
69+
70+
assert [] == cl.calls
71+
72+
async def test_async_filtered_interp(self, bl, cl):
73+
"""
74+
Passing interpolation args works if the log entry is filtered out.
75+
"""
76+
await bl.adebug("hello %s!", "world")
77+
78+
assert [] == cl.calls
79+
6480
def test_no_args(self, bl, cl):
6581
"""
6682
If no args are passed, don't attempt intepolation.

0 commit comments

Comments
 (0)