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

48 views
Skip to first unread message

Django

unread,
Apr 25, 2026, 6:01:52 PMApr 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 PMApr 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 PMApr 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 PMApr 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 PMApr 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 PMApr 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 PMApr 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 PMApr 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 PMApr 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>

Django

unread,
Apr 29, 2026, 12:29:42 PMApr 29
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: Release blocker | Resolution:
Keywords: | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Jacob Walls):

* owner: Artyom Kotovskiy => (none)
* stage: Accepted => Ready for checkin
* status: assigned => new

Comment:

Fashad, although I'm merging your PR in the interest of efficiency, since
it took fewer manual edits to polish, next time please respect the
existing owner on Trac. It had only been a few hours since it was claimed.
--
Ticket URL: <https://code.djangoproject.com/ticket/37067#comment:9>

Django

unread,
Apr 29, 2026, 12:30:39 PMApr 29
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: 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 Mike Edmunds):

* stage: Ready for checkin => Accepted

Comment:

Just to clarify, the deprecation warnings are still issued even with the
bug. They just show a less-helpful stack frame than intended.

[I'm not sure I follow the history references, but they seem to confirm
code using `skip_file_prefixes` had the same problem before the
centralized `django_file_prefixes()` was created.]
--
Ticket URL: <https://code.djangoproject.com/ticket/37067#comment:10>

Django

unread,
Apr 29, 2026, 12:31:24 PMApr 29
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: Release blocker | Resolution:
Keywords: | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Mike Edmunds):

* stage: Accepted => Ready for checkin

Comment:

(Sorry, Trac bug changed more than I intended)
--
Ticket URL: <https://code.djangoproject.com/ticket/37067#comment:11>

Django

unread,
Apr 29, 2026, 1:04:41 PMApr 29
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: Release blocker | Resolution:
Keywords: | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by Jacob Walls):

Thanks for the review!

Replying to [comment:10 Mike Edmunds]:

> [I'm not sure I follow the history references, but they seem to confirm
code using `skip_file_prefixes` had the same problem before the
centralized `django_file_prefixes()` was created.]

Right, all I mean was that it's a "bug" in the "new features" contributed
in those commits that they cite the less appropriate stack frames, so we
should backport.
--
Ticket URL: <https://code.djangoproject.com/ticket/37067#comment:12>

Django

unread,
Apr 29, 2026, 1:12:08 PMApr 29
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: Release blocker | Resolution:
Keywords: | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Jacob Walls):

* owner: (none) => Fashad Ahmed
* status: new => assigned

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

Django

unread,
Apr 29, 2026, 1:48:01 PMApr 29
to django-...@googlegroups.com
#37067: Deprecation warnings skip past packages named "django_*"
-------------------------------------+-------------------------------------
Reporter: Mike Edmunds | Owner: Fashad
| Ahmed
Type: Bug | Status: closed
Component: Utilities | Version: 6.0
Severity: Release blocker | Resolution: fixed
Keywords: | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Jacob Walls <jacobtylerwalls@…>):

* resolution: => fixed
* status: assigned => closed

Comment:

In [changeset:"60a9c70496e5d7b971928ce3da5b47c8836a4def" 60a9c70]:
{{{#!CommitTicketReference repository=""
revision="60a9c70496e5d7b971928ce3da5b47c8836a4def"
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.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/37067#comment:14>

Django

unread,
Apr 29, 2026, 1:49:05 PMApr 29
to django-...@googlegroups.com
#37067: Deprecation warnings skip past packages named "django_*"
-------------------------------------+-------------------------------------
Reporter: Mike Edmunds | Owner: Fashad
| Ahmed
Type: Bug | Status: closed
Component: Utilities | Version: 6.0
Severity: Release blocker | Resolution: fixed
Keywords: | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by Jacob Walls <jacobtylerwalls@…>):

In [changeset:"8bcd15beeff6542acc381b83f50b061d62284c2b" 8bcd15b]:
{{{#!CommitTicketReference repository=""
revision="8bcd15beeff6542acc381b83f50b061d62284c2b"
[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.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/37067#comment:15>

Django

unread,
Apr 30, 2026, 6:05:18 AMApr 30
to django-...@googlegroups.com
#37067: Deprecation warnings skip past packages named "django_*"
-------------------------------------+-------------------------------------
Reporter: Mike Edmunds | Owner: Fashad
| Ahmed
Type: Bug | Status: closed
Component: Utilities | Version: 6.0
Severity: Release blocker | Resolution: fixed
Keywords: | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by Fashad Ahmed):

Replying to [comment:9 Jacob Walls]:
> Fashad, although I'm merging your PR in the interest of efficiency,
since it took fewer manual edits to polish, next time please respect the
existing owner on Trac. It had only been a few hours since it was claimed.



Thanks for merging and polishing the PR, I appreciate it. Apologies for
stepping in while the ticket was already assigned. I’ll make sure to check
ownership more carefully before contributing next time. Glad this fix made
it in!
--
Ticket URL: <https://code.djangoproject.com/ticket/37067#comment:16>
Reply all
Reply to author
Forward
0 new messages