This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author filipp
Recipients filipp
Date 2020-01-07.20:27:12
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1578428833.37.0.29494253109.issue39250@roundup.psfhosted.org>
In-reply-to
Content
The documentation describes os.path.commonpath() as:

"Return the longest common sub-path of each pathname in the sequence paths. Raise ValueError if paths contain both absolute and relative pathnames, the paths are on the different drives or if paths is empty. Unlike commonprefix(), this returns a valid path."

However, in practice the function seems to always return the *shortest* common path. Steps to reproduce:

import os.path
paths = ['/var', '/var/log', '/var/log/nginx']
os.path.commonpath(paths)

Expected results:
'/var/log'

Actual results:
'/var'

I've tried this with Python 3.5, 3.6, 3.7 and 3.8.1 on both MacOS and Debian/Linux and the results are consistent.
History
Date User Action Args
2020-01-07 20:27:13filippsetrecipients: + filipp
2020-01-07 20:27:13filippsetmessageid: <1578428833.37.0.29494253109.issue39250@roundup.psfhosted.org>
2020-01-07 20:27:13filipplinkissue39250 messages
2020-01-07 20:27:12filippcreate