summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFashad Ahmed <fashad.ahmed20@gmail.com>2026-04-28 22:38:36 +0200
committerJacob Walls <jacobtylerwalls@gmail.com>2026-04-29 13:48:32 -0400
commit8bcd15beeff6542acc381b83f50b061d62284c2b (patch)
tree292278af9a0bac4ea8c6e13c2c63cbd72f75ff25
parent3cdec6454fb86e8d03a06944c0c68025733ed93f (diff)
[6.0.x] Fixed #37067 -- Added trailing slash in django_file_prefixes().
Ensure skip_file_prefixes does not match sibling packages like django*. Bug in f42b89f1bf49a5b89ed852b60f79342320a81c5e and 34bd3ed944bf38792c631b55e581963d44d52284. Backport of 60a9c70496e5d7b971928ce3da5b47c8836a4def from main.
-rw-r--r--django/utils/deprecation.py2
-rw-r--r--docs/releases/6.0.5.txt3
-rw-r--r--tests/deprecation/tests.py7
3 files changed, 10 insertions, 2 deletions
diff --git a/django/utils/deprecation.py b/django/utils/deprecation.py
index 11a37f05bc..017c69bf7e 100644
--- a/django/utils/deprecation.py
+++ b/django/utils/deprecation.py
@@ -15,7 +15,7 @@ def django_file_prefixes():
file = getattr(django, "__file__", None)
if file is None:
return ()
- return (os.path.dirname(file),)
+ return (os.path.join(os.path.dirname(file), ""),)
class RemovedInDjango61Warning(DeprecationWarning):
diff --git a/docs/releases/6.0.5.txt b/docs/releases/6.0.5.txt
index 91443c52ae..1e7e1b2c3b 100644
--- a/docs/releases/6.0.5.txt
+++ b/docs/releases/6.0.5.txt
@@ -14,3 +14,6 @@ Bugfixes
``django/contrib/admin/templates/admin/change_list.html`` template added in
Django 6.0 that could be problematic when overriding the ``pagination`` block
(:ticket:`37029`).
+
+* Fixed a bug in Django 6.0 where deprecation warnings incorrectly skipped
+ lines from third-party packages prefixed with "django" (:ticket:`37067`).
diff --git a/tests/deprecation/tests.py b/tests/deprecation/tests.py
index ac610b4928..0993e8a450 100644
--- a/tests/deprecation/tests.py
+++ b/tests/deprecation/tests.py
@@ -1,5 +1,6 @@
import os
import warnings
+from pathlib import Path
import django
from django.test import SimpleTestCase
@@ -31,7 +32,11 @@ class DjangoFilePrefixesTests(SimpleTestCase):
prefixes = django_file_prefixes()
self.assertIsInstance(prefixes, tuple)
self.assertEqual(len(prefixes), 1)
- self.assertTrue(prefixes[0].endswith(f"{os.path.sep}django"))
+ self.assertTrue(prefixes[0].endswith(f"{os.path.sep}django{os.path.sep}"))
+
+ def test_does_not_match_packages_prefixed_with_django(self):
+ other_file = Path(django.__file__).parent.parent / "djangoextra" / "__init__.py"
+ self.assertFalse(str(other_file).startswith(django_file_prefixes()))
class RenameManagerMethods(RenameMethodsBase):