diff --git a/airflow/utils/log/secrets_masker.py b/airflow/utils/log/secrets_masker.py index 4200056abc5b2..17234bf4082ea 100644 --- a/airflow/utils/log/secrets_masker.py +++ b/airflow/utils/log/secrets_masker.py @@ -271,6 +271,7 @@ class RedactedIO(TextIO): def __init__(self): self.target = sys.stdout + self.fileno = sys.stdout.fileno def write(self, s: str) -> int: s = redact(s) diff --git a/tests/utils/log/test_secrets_masker.py b/tests/utils/log/test_secrets_masker.py index c07be27bb7ae0..6de30eb574787 100644 --- a/tests/utils/log/test_secrets_masker.py +++ b/tests/utils/log/test_secrets_masker.py @@ -18,9 +18,11 @@ import contextlib import inspect +import io import logging import logging.config import os +import sys import textwrap import pytest @@ -363,3 +365,13 @@ def test_write(self, capsys): RedactedIO().write(p) stdout = capsys.readouterr().out assert stdout == "***" + + def test_input_builtin(self, monkeypatch): + """ + Test that when redirect is inplace the `input()` builtin works. + + This is used by debuggers! + """ + monkeypatch.setattr(sys, 'stdin', io.StringIO("a\n")) + with contextlib.redirect_stdout(RedactedIO()): + assert input() == "a"