Code

#18780 closed Cleanup/optimization (duplicate)

Set stacklevel when warning about depreciated function views

Reported by: paulb@… Owned by: nickmartini
Component: Generic views Version: 1.4
Severity: Normal Keywords:
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: yes UI/UX: no

Description

It would be handy if the depreciation warning messages gave a clue as to the cause of warning. This can be done by adding severity to the warning.

Eg

#django.views.generic.simple.py

import warnings
warnings.warn(
    'Function-based generic views have been deprecated; use class-based views instead.',
    DeprecationWarning, stacklevel=2
)

Attachments (0)

Change History (4)

comment:1 Changed 20 months ago by aaugustin

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Triage Stage changed from Unreviewed to Accepted
  • Type changed from Uncategorized to Cleanup/optimization

Actually, it may be a good idea to always set stacklevel appropriately (is 2 always the "right" value?) wherever Django raises a DeprecationWarning.

comment:2 Changed 20 months ago by nickmartini

  • Owner changed from nobody to nickmartini

comment:3 Changed 20 months ago by nickmartini

  • Has patch set

All DeprecationWarning are now stacklevel=2. I made no changes to PendingDeprecationWarning.

https://github.com/django/django/pull/349

Last edited 20 months ago by nickmartini (previous) (diff)

comment:4 Changed 20 months ago by aaugustin

  • Resolution set to duplicate
  • Status changed from new to closed

This is actually a duplicate of #18127, the same pull request was posted to both tickets.

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.