[Python-Dev] [Python-checkins] r85902 - in python/branches/py3k/Lib: os.py test/test_os.py (original) (raw)

Nick Coghlan ncoghlan at gmail.com
Sun Oct 31 15:01:47 CET 2010


On Fri, Oct 29, 2010 at 10:38 AM, victor.stinner <python-checkins at python.org> wrote:

try: -        pathlist = env.get('PATH') +        # ignore BytesWarning warning +        with warnings.catchwarnings(record=True): +            pathlist = 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')

I'll also echo Benjamin's concern with the embedded import. Of such things, deadlocks are created. If there's a dependency problem between os and the warnings build process in a fresh build, then it is better to simply fix that rather than risking the deadlock.

Cheers, Nick.

-- Nick Coghlan   |   ncoghlan at gmail.com   |   Brisbane, Australia



More information about the Python-Dev mailing list