Message359535
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. |
|
Date |
User |
Action |
Args |
2020-01-07 20:27:13 | filipp | set | recipients:
+ filipp |
2020-01-07 20:27:13 | filipp | set | messageid: <1578428833.37.0.29494253109.issue39250@roundup.psfhosted.org> |
2020-01-07 20:27:13 | filipp | link | issue39250 messages |
2020-01-07 20:27:12 | filipp | create | |
|