#36961 closed Bug (fixed)
django_file_prefixes() raises TypeError if Django is imported by namespace
| Reported by: | Jacob Walls | Owned by: | Jacob Walls |
|---|---|---|---|
| Component: | Utilities | Version: | 6.0 |
| Severity: | Release blocker | Keywords: | |
| Cc: | Triage Stage: | Ready for checkin | |
| Has patch: | yes | Needs documentation: | no |
| Needs tests: | no | Patch needs improvement: | no |
| Easy pickings: | no | UI/UX: | no |
Description
cd one level above your django checkout, and launch a python shell.
Calling django_file_prefixes will fail:
>>> 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.
Change History (7)
comment:1 by , 3 weeks ago
| Summary: | django_file_prefixes() raises AttributeError if Django is imported by namespace → django_file_prefixes() raises TypeError if Django is imported by namespace |
|---|
comment:2 by , 3 weeks ago
comment:3 by , 3 weeks ago
| Triage Stage: | Unreviewed → Accepted |
|---|
Thank you Jacob! I find "cd one level above your django checkout, and launch a python shell" a bit of a niche use case but the fix is quite straightforward, so accepting.
comment:4 by , 3 weeks ago
Yeah, I only expect this to happen "accidentally" in CI/CD pipelines when cwd is not managed cleanly, similar to the issues we see crop up when django's runtests.py is sometimes run from /tests versus /.
comment:5 by , 3 weeks ago
| Triage Stage: | Accepted → Ready for checkin |
|---|
PR