Author Oren Milman
Recipients Oren Milman
Date 2017-09-11.07:52:58
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1505116378.77.0.852325639547.issue31416@psf.upfronthosting.co.za>
In-reply-to
Content
The following code causes an assertion failure in warn_explicit() (in
Python/_warnings.c):

import warnings
warnings.filters = [(None, None, Warning, None, 0)]
warnings.warn_explicit(message='foo', category=Warning, filename='bar',
                       lineno=1)

this is because warn_explicit() assumes that get_filter() returned a string,
and passes the return value (of get_filter()) to _PyUnicode_EqualToASCIIString(),
which asserts it received a string.


In addition, get_filter() might return warnings.defaultaction, and so the
following code also causes an assertion failure in warn_explicit():

import warnings
warnings.defaultaction = None
warnings.filters = []
warnings.warn_explicit(message='foo', category=Warning, filename='bar',
                       lineno=1)
History
Date User Action Args
2017-09-11 07:52:58Oren Milmansetrecipients: + Oren Milman
2017-09-11 07:52:58Oren Milmansetmessageid: <1505116378.77.0.852325639547.issue31416@psf.upfronthosting.co.za>
2017-09-11 07:52:58Oren Milmanlinkissue31416 messages
2017-09-11 07:52:58Oren Milmancreate