[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:28:51 CET 2010
- Previous message: [Python-Dev] [Python-checkins] r85902 - in python/branches/py3k/Lib: os.py test/test_os.py
- Next message: [Python-Dev] [Python-checkins] r86000 - python/branches/py3k/Lib/test/test_fileio.py
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On Mon, Nov 1, 2010 at 12:01 AM, Nick Coghlan <ncoghlan at gmail.com> wrote:
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.catchwarnings(): warnings.simplefilter("ignore", BytesWarning) pathlist = 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 | ncoghlan at gmail.com | Brisbane, Australia
- Previous message: [Python-Dev] [Python-checkins] r85902 - in python/branches/py3k/Lib: os.py test/test_os.py
- Next message: [Python-Dev] [Python-checkins] r86000 - python/branches/py3k/Lib/test/test_fileio.py
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]