Index: Lib/posixpath.py =================================================================== --- Lib/posixpath.py (révision 65973) +++ Lib/posixpath.py (copie de travail) @@ -11,6 +11,7 @@ """ import os +import sys import stat import genericpath from genericpath import * @@ -59,14 +60,23 @@ """Join two or more pathname components, inserting '/' as needed. If any component is an absolute path, all previous path components will be discarded.""" + use_bytes = any( isinstance(part, bytes) for part in (a,)+p ) path = a + sep = '/' + if use_bytes: + charset = sys.getfilesystemencoding() + sep = sep.encode(charset) + if use_bytes and isinstance(path, str): + path = path.encode(charset) for b in p: - if b.startswith('/'): + if use_bytes and isinstance(b, str): + b = b.encode(charset) + if b.startswith(sep): path = b - elif path == '' or path.endswith('/'): + elif path == '' or path.endswith(sep): path += b else: - path += '/' + b + path += sep + b return path