summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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):