diff options
| -rw-r--r-- | django/utils/deprecation.py | 2 | ||||
| -rw-r--r-- | docs/releases/6.0.5.txt | 3 | ||||
| -rw-r--r-- | tests/deprecation/tests.py | 7 |
3 files changed, 10 insertions, 2 deletions
diff --git a/django/utils/deprecation.py b/django/utils/deprecation.py index 89c9f71e55..f856582454 100644 --- a/django/utils/deprecation.py +++ b/django/utils/deprecation.py @@ -16,7 +16,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 RemovedInNextVersionWarning(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): |
