On Mon, Nov 1, 2010 at 12:01 AM, Nick Coghlan <[email protected]> wrote:
> On Fri, Oct 29, 2010 at 10:38 AM, victor.stinner
> <[email protected]> wrote:
>> try:
>> - path_list = env.get('PATH')
>> + # ignore BytesWarning warning
>> + with warnings.catch_warnings(record=True):
>> + path_list = env.get('PATH')
>
> This looks odd to me. You're requesting that the warnings be saved,
> but not actually retrieving the list object where they're recorded
> from the __enter__ method.
>
> The correct way to suppress a specific warning type is:
>
> with warnings.catch_warnings():
> warnings.simplefilter("ignore", BytesWarning)
> path_list = env.get('PATH')
Alternatively, specifically in the test suite, you can use:
with test.support.check_warnings(('', BytesWarning), quiet=True):
path_list = env.get('PATH')
(Without the "quiet=True" the test would fail in release mode, when
the warning *isn't* issued)
Cheers,
Nick.
--
Nick Coghlan | [email protected] | Brisbane, Australia
_______________________________________________
Python-Dev mailing list
[email protected]
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe:
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com