Opened 2 years ago

Closed 14 months ago

#20083 closed Bug (worksforme)

Fix for #18985 makes it impossible to filter deprecation warnings

Reported by: aaugustin 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 2 years ago by epicserve

I agree. I ran into this same issue.

comment:2 Changed 2 years ago by jacob

  • Triage Stage changed from Unreviewed to Accepted

comment:3 Changed 15 months ago by guettli

  • Cc hv@… added

comment:4 Changed 14 months ago by Claude Paroz <claude@…>

In 8446a2438ffeab845e31cba4489f03fccc387298:

Added test about error filterwarnings

Refs #20083.

comment:5 Changed 14 months ago by claudep

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

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