You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
posixpath.commonpath: Check for empty iterables broken #114709
This came up in python/typeshed#11310: When passing an empty sequence to commonpath(), a ValueError is raised with an appropriate error message. When an "empty" iterable is passed, an IndexError is raised instead, although iterables otherwise work fine:
fromposixpathimportcommonpathcommonpath([]) # -> ValueError: commonpath() arg is an empty sequencecommonpath(iter([])) # -> IndexError: tuple index out of range
The fix is trivial, I'll send a PR. Technically this is an API change, though, although the old API is unexpected.
It did not supported arbitrary iterables initially, it only worked with sequences. Then in 3.6 it started working with non-empty iterables by accident, but it was not intentional change, it was an implementation detail.
Accepting an arbitrary iterable is a new feature. This change can only go in future 3.13.
Activity
serhiy-storchaka commentedon Jan 29, 2024
It did not supported arbitrary iterables initially, it only worked with sequences. Then in 3.6 it started working with non-empty iterables by accident, but it was not intentional change, it was an implementation detail.
Accepting an arbitrary iterable is a new feature. This change can only go in future 3.13.
gh-114709: Fix exceptions raised by posixpath.commonpath (#114710)
serhiy-storchaka commentedon Feb 18, 2024
Please revert the change in
versionchanged:: 3.6and addversionchanged:: 3.13.pythongh-114709: Mark commonpath behaviour as changed in 3.13
gh-114709: Mark commonpath behaviour as changed in 3.13 (#115639)
hauntsaninja commentedon Feb 18, 2024
Thanks, done in #115639
pythongh-114709: Fix exceptions raised by posixpath.commonpath (pytho…
pythongh-114709: Mark commonpath behaviour as changed in 3.13 (python…
pythongh-114709: Fix exceptions raised by posixpath.commonpath (pytho…
pythongh-114709: Mark commonpath behaviour as changed in 3.13 (python…
pythongh-114709: Fix exceptions raised by posixpath.commonpath (pytho…
pythongh-114709: Mark commonpath behaviour as changed in 3.13 (python…