summaryrefslogtreecommitdiff
path: root/django/utils/deprecation.py
diff options
context:
space:
mode:
authorAdam Johnson <me@adamj.eu>2025-09-12 09:35:01 +0100
committerGitHub <noreply@github.com>2025-09-12 10:35:01 +0200
commit7b26b64a63b5fc15134426a6ee0534dca2a1a855 (patch)
treed9b4adfe485e3de352269e1fc7dd13d25875054d /django/utils/deprecation.py
parent41bc48ac1ed1d515977ebe965993b1ef83eafd02 (diff)
Refs #35667 -- Cached Django file prefixes for warnings.
Diffstat (limited to 'django/utils/deprecation.py')
-rw-r--r--django/utils/deprecation.py11
1 files changed, 10 insertions, 1 deletions
diff --git a/django/utils/deprecation.py b/django/utils/deprecation.py
index 7d5289bd3c..376eb33fae 100644
--- a/django/utils/deprecation.py
+++ b/django/utils/deprecation.py
@@ -9,6 +9,15 @@ from asgiref.sync import iscoroutinefunction, markcoroutinefunction, sync_to_asy
import django
+@functools.cache
+def django_file_prefixes():
+ try:
+ file = django.__file__
+ except AttributeError:
+ return ()
+ return (os.path.dirname(file),)
+
+
class RemovedInDjango61Warning(DeprecationWarning):
pass
@@ -237,7 +246,7 @@ def deprecate_posargs(deprecation_warning, remappable_names, /):
f"Passing positional argument(s) {remapped_names_str} to {func_name}() "
"is deprecated. Use keyword arguments instead.",
deprecation_warning,
- skip_file_prefixes=(os.path.dirname(django.__file__),),
+ skip_file_prefixes=django_file_prefixes(),
)
return remaining_args, updated_kwargs