Opened 4 years ago

Closed 3 years ago

#20083 closed Bug (worksforme)

Fix for #18985 makes it impossible to filter deprecation warnings

Reported by: Aymeric Augustin Owned by: nobody
Component: Core (Other) Version: 1.5
Severity: Normal Keywords:
Cc: hv@… Triage Stage: Accepted
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

The following does nothing on Python >= 2.7 because warnings are piped into logging since [44046e8a]:

warnings.filterwarnings(
    'error',
    r'django\.conf\.urls\.defaults is deprecated; use django\.conf\.urls instead',
    DeprecationWarning,
    r'django\.conf\.urls\.defaults')

That's a bit annoying.

Change History (5)

comment:1 Changed 4 years ago by Brent O'Connor

I agree. I ran into this same issue.

comment:2 Changed 4 years ago by Jacob

Triage Stage: UnreviewedAccepted

comment:3 Changed 3 years ago by Thomas Güttler

Cc: hv@… added

comment:4 Changed 3 years ago by Claude Paroz <claude@…>

In 8446a2438ffeab845e31cba4489f03fccc387298:

Added test about error filterwarnings

Refs #20083.

comment:5 Changed 3 years ago by Claude Paroz

Resolution: worksforme
Status: newclosed

Looking at the source code of the warnings module, it seems that raising the exception precedes the showwarning call, hence routing through logging should not affect error filters. I've just added a test for this. But it may be that recent commits with addition of DeprecationWarning subclasses for Django deprecations has also helped.

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