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

Calling .suffix on a dir raises IndexError #120

Closed
pjbull opened this issue Feb 11, 2021 · 1 comment · Fixed by #209
Closed

Calling .suffix on a dir raises IndexError #120

pjbull opened this issue Feb 11, 2021 · 1 comment · Fixed by #209
Labels
bug Something isn't working good first issue Good for newcomers

Comments

@pjbull
Copy link
Member

pjbull commented Feb 11, 2021

Path("/dir").suffix returns the empty string, and we should do the same.

S3Path("s3://bucket/dir").suffix results in:

---------------------------------------------------------------------------
IndexError                                Traceback (most recent call last)
<ipython-input-21-161bf2e9d1ca> in <module>
----> 1 S3Path("s3://bucket/dir").suffix

~/miniconda3/envs/zamba-algorithms/lib/python3.6/site-packages/cloudpathlib/cloudpath.py in suffix(self)
    522     @property
    523     def suffix(self):
--> 524         return self._dispatch_to_path("suffix")
    525 
    526     @property

~/miniconda3/envs/zamba-algorithms/lib/python3.6/site-packages/cloudpathlib/cloudpath.py in _dispatch_to_path(self, func, *args, **kwargs)
    470 
    471         if isinstance(path_version, collections.abc.Sequence) and isinstance(
--> 472             path_version[0], PurePosixPath
    473         ):
    474             return [

IndexError: string index out of range

@pjbull pjbull added bug Something isn't working good first issue Good for newcomers labels Feb 11, 2021
@jayqi
Copy link
Member

jayqi commented Feb 8, 2022

Noting that this situation also results in an IndexError for the .suffixes property.

@jayqi jayqi closed this as completed in #209 Feb 8, 2022
jayqi added a commit that referenced this issue Feb 8, 2022
* Fix suffix and suffixes for no suffix. Fixes #120

* Have parents return as a tuple

Co-authored-by: Jay Qi <jayqi@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue Good for newcomers
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants