[Django] #36961: django_file_prefixes() raises AttributeError if Django is imported by namespace

1 view
Skip to first unread message

Django

unread,
Feb 27, 2026, 2:41:10 PM (23 hours ago) Feb 27
to django-...@googlegroups.com
#36961: django_file_prefixes() raises AttributeError if Django is imported by
namespace
-------------------------------------------+-----------------------------
Reporter: Jacob Walls | Owner: Jacob Walls
Type: Bug | Status: assigned
Component: Utilities | Version: 6.0
Severity: Release blocker | Keywords:
Triage Stage: Unreviewed | Has patch: 1
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-------------------------------------------+-----------------------------
cd one level above your django checkout, and launch a python shell.

Calling django_file_prefixes will fail:

{{{#!py
>>> import django
>>> django.__file__ is None
True
>>> from django.utils.deprecation import django_file_prefixes
>>> django_file_prefixes()
Traceback (most recent call last):
File "<python-input-1>", line 5, in <module>
django_file_prefixes()
~~~~~~~~~~~~~~~~~~~~^^
File "/Users/jwalls/django/django/utils/deprecation.py", line 18, in
django_file_prefixes
return (os.path.dirname(file),)
~~~~~~~~~~~~~~~^^^^^^
File "<frozen posixpath>", line 178, in dirname
TypeError: expected str, bytes or os.PathLike object, not NoneType
}}}
----
How I found this was by testing deprecation warnings, so what I'm
concluding is that deprecation warnings might crash in 6.0 if you import
Django by namespace.
--
Ticket URL: <https://code.djangoproject.com/ticket/36961>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
Reply all
Reply to author
Forward
0 new messages