diff --git a/Lib/posixpath.py b/Lib/posixpath.py index 16b8d9091c5a84..000fe70e41807a 100644 --- a/Lib/posixpath.py +++ b/Lib/posixpath.py @@ -558,7 +558,7 @@ def commonpath(paths): try: split_paths = [path.split(sep) for path in paths] - if len({p.startswith(sep) for p in paths}) != 1: + if len({p[:1] == sep for p in paths}) != 1: raise ValueError("Can't mix absolute and relative paths") split_paths = [[c for c in s if c and c != curdir] for s in split_paths] @@ -570,7 +570,7 @@ def commonpath(paths): common = s1[:i] break - prefix = sep if paths[0].startswith(sep) else sep[:0] + prefix = sep if paths[0][:1] == sep else sep[:0] return prefix + sep.join(common) except (TypeError, AttributeError): genericpath._check_arg_types('commonpath', *paths)