Skip to content
Merged
Prev Previous commit
Next Next commit
Revert unpacking
  • Loading branch information
nineteendo committed Apr 16, 2024
commit 98674d592b8bd762178e532f7547aa1e4c5dae79
8 changes: 5 additions & 3 deletions Lib/posixpath.py
Original file line number Diff line number Diff line change
Expand Up @@ -558,8 +558,10 @@ def commonpath(paths):
try:
split_paths = [path.split(sep) for path in paths]

if len({p.startswith(sep) for p in paths}) != 1:
raise ValueError("Can't mix absolute and relative paths")
try:
isabs, = {p.startswith(sep) for p in paths}
except ValueError:
raise ValueError("Can't mix absolute and relative paths") from None

split_paths = [[c for c in s if c and c != curdir] for s in split_paths]
s1 = min(split_paths)
Expand All @@ -570,7 +572,7 @@ def commonpath(paths):
common = s1[:i]
break

prefix = sep if paths[0].startswith(sep) else sep[:0]
prefix = sep if isabs else sep[:0]
return prefix + sep.join(common)
except (TypeError, AttributeError):
genericpath._check_arg_types('commonpath', *paths)
Expand Down