New submission from akira:
`pathlib.PurePath.parents` is a sequence [1] but it rejects negative indexes:
>>> from pathlib import PurePath
>>> PurePath('a/b/c').parents[-2]
Traceback (most recent call last):
...
IndexError: -2
Sequences in Python interpret negative indexes as `len(seq) + i` [2]
I've included the patch that fixes the issue and adds corresponding tests. No
documentation changes are needed.
[1]: http://docs.python.org/3/library/pathlib#pathlib.PurePath.parents
[2]:
http://docs.python.org/3/library/stdtypes.html#sequence-types-list-tuple-range
----------
components: Library (Lib)
files: pathlib-parents-allow-negative-index.patch
keywords: patch
messages: 214642
nosy: akira
priority: normal
severity: normal
status: open
title: pathlib.PurePath.parents rejects negative indexes
versions: Python 3.4, Python 3.5
Added file:
http://bugs.python.org/file34595/pathlib-parents-allow-negative-index.patch
_______________________________________
Python tracker <[email protected]>
<http://bugs.python.org/issue21041>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com