[Django] #37067: Deprecation warnings skip past packages named "django_*"

10 views
Skip to first unread message

Django

unread,
Apr 25, 2026, 6:01:52 PM (3 days ago) Apr 25
to django-...@googlegroups.com
#37067: Deprecation warnings skip past packages named "django_*"
----------------------------------------+------------------------------
Reporter: Mike Edmunds | Owner: Mike Edmunds
Type: Bug | Status: assigned
Component: Utilities | Version: 6.0
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
----------------------------------------+------------------------------
The `django_file_prefixes()` utility doesn't include a trailing path
separator, so also matches other packages whose installation directories
start with "django". As a result, use of deprecated features in those
packages will be mis-attributed to some other code outside those packages.

Django's implementation frequently has code like this:

{{{#!python
# django.some_module

import warnings
from django.utils.deprecation import RemovedInDjangoXXWarning,
django_file_prefixes

def _some_helper():
...
warnings.warn(
"This is deprecated.",
RemovedInDjangoXXWarning,
skip_file_prefixes=django_file_prefixes(),
)

def some_django_feature():
...
_some_helper()
...
}}}

The intent is a caller to `some_django_feature()` outside Django gets a
deprecation warning pointed at their own code. (Not pointing at the call
to `_some_helper()` in Django's implementation.)

As
[https://github.com/django/django/blob/8ee73415270a1a54daaec9bb529ad82c6f7a6d4c/django/utils/deprecation.py#L13-L18
currently implemented], `django_file_prefixes()` returns the directory
where Django is installed (in a tuple). E.g., `("/venv/site-
packages/django",)`.

If `some_django_feature()` is called from a (hypothetical)
`django_goodies` package installed in `/venv/site-
packages/django_goodies/__init__.py`, the warning's `skip_file_prefixes`
will skip it too. (That filename `str.startswith()`
`django_file_prefixes()`.) The resulting warning will point to the first
stack frame outside `django_goodies`, which may be completely disconnected
from the deprecated feature usage.
--
Ticket URL: <https://code.djangoproject.com/ticket/37067>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Apr 25, 2026, 6:05:56 PM (3 days ago) Apr 25
to django-...@googlegroups.com
#37067: Deprecation warnings skip past packages named "django_*"
------------------------------+----------------------------------------
Reporter: Mike Edmunds | Owner: Mike Edmunds
Type: Bug | Status: assigned
Component: Utilities | Version: 6.0
Severity: Normal | Resolution:
Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
------------------------------+----------------------------------------
Description changed by Mike Edmunds:

Old description:
New description:
packages/django_goodies/__init__.py`, the warning will skip it too: that
filename [https://docs.python.org/3/library/stdtypes.html#str.startswith
startswith] the django_file_prefixes. The resulting warning will point to
the first stack frame outside `django_goodies`, which may be completely
disconnected from the deprecated feature usage.

--
--
Ticket URL: <https://code.djangoproject.com/ticket/37067#comment:1>

Django

unread,
Apr 25, 2026, 8:06:13 PM (3 days ago) Apr 25
to django-...@googlegroups.com
#37067: Deprecation warnings skip past packages named "django_*"
------------------------------+----------------------------------------
Reporter: Mike Edmunds | Owner: Mike Edmunds
Type: Bug | Status: assigned
Component: Utilities | Version: 6.0
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
------------------------------+----------------------------------------
Changes (by Tim Graham):

* stage: Unreviewed => Accepted

--
Ticket URL: <https://code.djangoproject.com/ticket/37067#comment:2>

Django

unread,
Apr 27, 2026, 5:34:32 PM (2 days ago) Apr 27
to django-...@googlegroups.com
#37067: Deprecation warnings skip past packages named "django_*"
------------------------------+------------------------------------
Reporter: Mike Edmunds | Owner: (none)
Type: Bug | Status: new
Component: Utilities | Version: 6.0
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
------------------------------+------------------------------------
Changes (by Mike Edmunds):

* easy: 0 => 1
* owner: Mike Edmunds => (none)
* status: assigned => new

--
Ticket URL: <https://code.djangoproject.com/ticket/37067#comment:3>

Django

unread,
Apr 27, 2026, 9:48:54 PM (2 days ago) Apr 27
to django-...@googlegroups.com
#37067: Deprecation warnings skip past packages named "django_*"
------------------------------+--------------------------------------------
Reporter: Mike Edmunds | Owner: Artyom Kotovskiy
Type: Bug | Status: assigned
Component: Utilities | Version: 6.0
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
------------------------------+--------------------------------------------
Changes (by Artyom Kotovskiy):

* owner: (none) => Artyom Kotovskiy
* status: new => assigned

--
Ticket URL: <https://code.djangoproject.com/ticket/37067#comment:4>

Django

unread,
Apr 28, 2026, 4:13:18 PM (9 hours ago) Apr 28
to django-...@googlegroups.com
#37067: Deprecation warnings skip past packages named "django_*"
------------------------------+----------------------------------------
Reporter: Mike Edmunds | Owner: Fashad Ahmed
Type: Bug | Status: assigned
Component: Utilities | Version: 6.0
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
------------------------------+----------------------------------------
Changes (by Fashad Ahmed):

* owner: Artyom Kotovskiy => Fashad Ahmed

Comment:

Hi Artyom, I’m interested in helping with this ticket. It seems like a
straightforward fix in django.utils.deprecation by ensuring
django_file_prefixes adds a trailing os.sep to the paths. Are you
currently working on a patch, or would you mind if I took a shot at it?
Thanks!
--
Ticket URL: <https://code.djangoproject.com/ticket/37067#comment:5>

Django

unread,
Apr 28, 2026, 4:21:24 PM (9 hours ago) Apr 28
to django-...@googlegroups.com
#37067: Deprecation warnings skip past packages named "django_*"
------------------------------+--------------------------------------------
Reporter: Mike Edmunds | Owner: Artyom Kotovskiy
Type: Bug | Status: assigned
Component: Utilities | Version: 6.0
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
------------------------------+--------------------------------------------
Changes (by Artyom Kotovskiy):

* owner: Fashad Ahmed => Artyom Kotovskiy

Comment:

Replying to [comment:5 Fashad Ahmed]:
> Hi Artyom, I’m interested in helping with this ticket. It seems like a
straightforward fix in django.utils.deprecation by ensuring
django_file_prefixes adds a trailing os.sep to the paths. Would you mind
if I took a shot at it? Thanks!
I already fixed it just have to do a pr
--
Ticket URL: <https://code.djangoproject.com/ticket/37067#comment:6>

Django

unread,
Apr 28, 2026, 4:26:06 PM (8 hours ago) Apr 28
to django-...@googlegroups.com
#37067: Deprecation warnings skip past packages named "django_*"
------------------------------+--------------------------------------------
Reporter: Mike Edmunds | Owner: Artyom Kotovskiy
Type: Bug | Status: assigned
Component: Utilities | Version: 6.0
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
------------------------------+--------------------------------------------
Changes (by Artyom Kotovskiy):

* has_patch: 0 => 1

Comment:

PR --> [https://github.com/django/django/pull/21185]
--
Ticket URL: <https://code.djangoproject.com/ticket/37067#comment:7>

Django

unread,
Apr 28, 2026, 9:03:01 PM (4 hours ago) Apr 28
to django-...@googlegroups.com
#37067: Deprecation warnings skip past packages named "django_*"
-------------------------------------+-------------------------------------
Reporter: Mike Edmunds | Owner: Artyom
| Kotovskiy
Type: Bug | Status: assigned
Component: Utilities | Version: 6.0
Severity: Release blocker | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Jacob Walls):

* severity: Normal => Release blocker

Comment:

Bug in f42b89f1bf49a5b89ed852b60f79342320a81c5e and
34bd3ed944bf38792c631b55e581963d44d52284 before refactor in
7b26b64a63b5fc15134426a6ee0534dca2a1a855.
--
Ticket URL: <https://code.djangoproject.com/ticket/37067#comment:8>
Reply all
Reply to author
Forward
0 new messages