From b5750b9f6414865200221d9c0dc568ae6b551294 Mon Sep 17 00:00:00 2001 From: Mariusz Felisiak Date: Sun, 19 Nov 2023 16:29:13 +0100 Subject: [PATCH] [4.2.x] Refs #34118 -- Fixed stacklevel in complex_setting_changed on Python 3.12. This fix is unnecessary in Django 5.0 since e83a88566a71a2353cebc35992c110be0f8628af because signals no longer use sync_to_async(). --- django/test/signals.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/django/test/signals.py b/django/test/signals.py index 94a5161e82..1358101b98 100644 --- a/django/test/signals.py +++ b/django/test/signals.py @@ -14,6 +14,7 @@ from django.utils import timezone from django.utils.formats import FORMAT_SETTINGS, reset_format_cache from django.utils.functional import empty from django.utils.module_loading import import_string +from django.utils.version import PY312 template_rendered = Signal() @@ -183,7 +184,7 @@ def complex_setting_changed(*, enter, setting, **kwargs): # this stacklevel shows the line containing the override_settings call. warnings.warn( f"Overriding setting {setting} can lead to unexpected behavior.", - stacklevel=6, + stacklevel=5 if PY312 else 6, )