#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.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion visit 
https://groups.google.com/d/msgid/django-updates/0107019dc6a9c033-e6e167a2-c045-4c85-b8c1-bf4f422ea679-000000%40eu-central-1.amazonses.com.

Reply via email to