diff options
| author | SaJH <wogur981208@gmail.com> | 2025-09-24 00:11:31 +0900 |
|---|---|---|
| committer | Sarah Boyce <42296566+sarahboyce@users.noreply.github.com> | 2025-09-25 11:38:28 +0200 |
| commit | 68aae8878ff90dd787db55ecc44ee712525ccdc6 (patch) | |
| tree | bbfac434178df870bd04d3c1b4eb72e6794cb546 /django | |
| parent | 5cbd96003ce13621ac247f8b09c1b625daf9c7c8 (diff) | |
Fixed #36434 -- Preserved unbuffered stdio (-u) in autoreloader child.
Signed-off-by: SaJH <wogur981208@gmail.com>
Diffstat (limited to 'django')
| -rw-r--r-- | django/utils/autoreload.py | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/django/utils/autoreload.py b/django/utils/autoreload.py index c6716215f5..99812979d7 100644 --- a/django/utils/autoreload.py +++ b/django/utils/autoreload.py @@ -268,6 +268,19 @@ def trigger_reload(filename): def restart_with_reloader(): new_environ = {**os.environ, DJANGO_AUTORELOAD_ENV: "true"} + orig = getattr(sys, "orig_argv", ()) + if any( + (arg == "-u") + or ( + arg.startswith("-") + and not arg.startswith(("--", "-X", "-W")) + and len(arg) > 2 + and arg[1:].isalpha() + and "u" in arg + ) + for arg in orig[1:] + ): + new_environ.setdefault("PYTHONUNBUFFERED", "1") args = get_child_arguments() while True: p = subprocess.run(args, env=new_environ, close_fds=False) |
