Code

Opened 13 months ago

Closed 6 weeks 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.

Attachments (0)

Change History (5)

comment:1 Changed 13 months ago by epicserve

I agree. I ran into this same issue.

comment:2 Changed 13 months ago by jacob

  • Triage Stage changed from Unreviewed to Accepted

comment:3 Changed 2 months ago by guettli

  • Cc hv@… added

comment:4 Changed 6 weeks ago by Claude Paroz <claude@…>

In 8446a2438ffeab845e31cba4489f03fccc387298:

Added test about error filterwarnings

Refs #20083.

comment:5 Changed 6 weeks 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.

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.