Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix incorrect __getitem__ method in Path #506

Merged
merged 1 commit into from
Mar 13, 2020
Merged

Conversation

qoo2p5
Copy link
Contributor

@qoo2p5 qoo2p5 commented Mar 13, 2020

Plumbum doesn't support PathLike logics, because Path class is inherited from str and therefore considered as str in python libraries (__fspath__ method is never called). Before #455 everything was fine, but after the corresponding commit libraries are unable to use plumbum Path as string, because __getitem__ returns strange thinks for int and slice keys.

Consider the following example:

import os
import plumbum

print(os.path.splitext(plumbum.local.path('/test/file.ext')))

Before #455 the output is as expected:

('/test/file', '.ext')

But after the commit it is meaningless:

(<LocalPath /test/file.ext/slice(None, 10, None)>, <LocalPath /test/file.ext/slice(10, None, None)>)

I fix this bug by returning the old __getitem__ behaviour for int and slice keys.

@qoo2p5
Copy link
Contributor Author

qoo2p5 commented Mar 13, 2020

Also, I think a new version must be released, because this bug is really critical.

@henryiii henryiii merged commit eab1ad7 into tomerfiliba:master Mar 13, 2020
@henryiii
Copy link
Collaborator

Thanks!

@henryiii henryiii added this to the v1.7.0 milestone Feb 8, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants