Index: Lib/os.py =================================================================== --- Lib/os.py (révision 85851) +++ Lib/os.py (copie de travail) @@ -382,18 +382,24 @@ *env* must be an environment variable dict or None. If *env* is None, os.environ will be used. """ + import warnings + if env is None: env = environ try: - path_list = env.get('PATH') - except (TypeError, BytesWarning): + # Catch BytesWarning + with warnings.catch_warnings(): + path_list = env.get('PATH') + except (TypeError,): path_list = None if supports_bytes_environ: try: - path_listb = env[b'PATH'] - except (KeyError, TypeError, BytesWarning): + # Catch BytesWarning + with warnings.catch_warnings(): + path_listb = env[b'PATH'] + except (KeyError, TypeError): pass else: if path_list is not None: