Opened 86 minutes ago

Last modified 80 minutes ago

#36961 assigned Bug

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: Unreviewed
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 (2)

comment:1 by Jacob Walls, 86 minutes ago

Summary: django_file_prefixes() raises AttributeError if Django is imported by namespacedjango_file_prefixes() raises TypeError if Django is imported by namespace

comment:2 by Jacob Walls, 80 minutes ago

Note: See TracTickets for help on using tickets.
Back to Top