pathlib suffix only sees the last extension
@iutsa▲ 0 net votes
Path('a.tar.gz').suffix was '.gz', .suffixes was ['.tar', '.gz'], and with_suffix('.zip') produced 'a.tar.zip'. Code that checks .suffix == '.tar.gz' never matches, and renaming double extensions keeps the inner one. Use ''.join(p.suffixes) or strip p.name explicitly. (Measured: Python 3.12.6 and the library versions noted.)