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

Path test failure with Python 3.12 #1934

Closed
QuLogic opened this issue Jun 26, 2023 · 6 comments
Closed

Path test failure with Python 3.12 #1934

QuLogic opened this issue Jun 26, 2023 · 6 comments
Assignees

Comments

@QuLogic
Copy link
Contributor

QuLogic commented Jun 26, 2023

Small description
It appears that the pathlib wrapper seems to use some internals of Path, which will change in Python 312, and causes a failure of the test.

Expected result
Tests pass.

Actual result with screenshot

________________________ TestVisidataPath.test_withName ________________________
self = <visidata.tests.test_path.TestVisidataPath object at 0x3ff82351e50>
    def test_withName(self):
        'tests for visidata.Path().with_name'
    
        file_path = Path('sample_data/sample.tsv')
        url_path = Path('https://visidata.org/hello/sample.tsv')
    
>       assert 'sample_data/b.tsv' == str(file_path.with_name('b.tsv')), '{} should be sample_data/b.tsv'.format(file_path.with_name('b.tsv'))
visidata/tests/test_path.py:13: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
visidata/path.py:321: in with_name
    return Path(self._from_parsed_parts(self._drv, self._root, self._parts[:-1] + [name]))
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
self = <visidata.path.Path object at 0x3ff500d37d0>, k = '_parts'
    def __getattr__(self, k):
        if hasattr(self.__dict__, k):
            r = getattr(self.__dict__, k)
        else:
            if self.__dict__.get('_path', None) is not None:
>               r = getattr(self._path, k)
E               AttributeError: 'PosixPath' object has no attribute '_parts'. Did you mean: 'parts'?
visidata/path.py:171: AttributeError

Additional context
VisiData 2.11 and Python 3.12 b3
See full log here: https://koji.fedoraproject.org/koji/taskinfo?taskID=102609485

@QuLogic QuLogic added the bug label Jun 26, 2023
@anjakefala
Copy link
Collaborator

Oh man, that is tricky news. Thank you so much for the heads up.

Frustrating that that was not included here: https://docs.python.org/3.12/whatsnew/3.12.html#pathlib

@anjakefala
Copy link
Collaborator

I believe this is the relevant PR: python/cpython#102476

@anjakefala anjakefala self-assigned this Jun 27, 2023
@anjakefala
Copy link
Collaborator

@QuLogic are you able to test the develop branch, and see if there are any other problems? If everything looks fine, I will start a point release branch in preparation for Python 3.12.

It seems like Python 3.12 is not supported by conda yet, or I would test it myself.

@anjakefala
Copy link
Collaborator

(And I really do appreciate you letting us know.)

anjakefala added a commit that referenced this issue Jun 27, 2023
`pathlib.Path._parts` has been removed in Python 3.12:
python/cpython#102476

Switch to pathlib.Path.parts which is a tuple.

Closes #1934
@anjakefala anjakefala mentioned this issue Jun 27, 2023
@QuLogic
Copy link
Contributor Author

QuLogic commented Jun 27, 2023

Thanks for the quick fix! I backported the patch and the build with Python 3.12 succeeded: https://koji.fedoraproject.org/koji/taskinfo?taskID=102650843

@anjakefala
Copy link
Collaborator

@QuLogic Ahhhhh, thank you!

We will prepare a patch release of VisiData!

anjakefala added a commit that referenced this issue Jul 16, 2023
`pathlib.Path._parts` has been removed in Python 3.12:
python/cpython#102476

Switch to pathlib.Path.parts which is a tuple.

Closes #1934
anjakefala added a commit that referenced this issue Jul 17, 2023
`pathlib.Path._parts` has been removed in Python 3.12:
python/cpython#102476

Switch to pathlib.Path.parts which is a tuple.

Closes #1934
anjakefala added a commit that referenced this issue Jul 17, 2023
`pathlib.Path._parts` has been removed in Python 3.12:
python/cpython#102476

Switch to pathlib.Path.parts which is a tuple.

Closes #1934
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants