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

Python 3.12 beta1: no attribute 'parse_parts' #830

Closed
buhtz opened this issue May 25, 2023 · 3 comments · Fixed by #835
Closed

Python 3.12 beta1: no attribute 'parse_parts' #830

buhtz opened this issue May 25, 2023 · 3 comments · Fixed by #835

Comments

@buhtz
Copy link

buhtz commented May 25, 2023

Description

Yesterday the first Beta of Python 3.12 was released. So I triggered the TravisCI build and my testsuite with that Python version in my own project Back In Time.

There might be a problem with pyfakefs and Python 3.12 (--version on TravisCI returns Python 3.12.0a2+). But I'm not sure.

The error message from the test run is

======================================================================
ERROR: test_git_repo_info (test.test_diagnostics.Diagnostics_FakeFS.test_git_repo_info)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/travis/build/buhtz/backintime/common/test/test_diagnostics.py", line 108, in test_git_repo_info
    self.assertEqual(diagnostics.get_git_repository_info(), None)
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/travis/build/buhtz/backintime/common/diagnostics.py", line 278, in get_git_repository_info
    git_folder = path / '.git'
                 ~~~~~^~~~~~~~
  File "/opt/python/3.12-dev/lib/python3.12/pathlib.py", line 709, in _
```_truediv__
    return self._make_child((key,))
           ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/python/3.12-dev/lib/python3.12/pathlib.py", line 455, in _make_child
    drv, root, parts = self._parse_args(args)
                       ^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/python/3.12-dev/lib/python3.12/pathlib.py", line 426, in _parse_args
    return cls._flavour.parse_parts(parts)
           ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/travis/virtualenv/python3.12-dev/lib/python3.12/site-packages/pyfakefs/fake_path.py", line 481, in __getattr__
    return getattr(self._os_path, name)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: module 'posixpath' has no attribute 'parse_parts'

Reproduce

The code of the test can be found here.

https://github.com/buhtz/backintime/blob/1cb873c06305426dfb401353540a50149277c2c8/common/test/test_diagnostics.py#L103-L134

I'm not able to run Python 3.12 locally on my machine. So I'm not able to create an MWE. But I'll try to figuring out to do this with a Python3.12-docker-thing.

Research

Python 3.11 has pathlib._Flavour.parse_parts(). But it is gone in Python 3.12; including the class _Flavour.

I checked the commit and PR history and found nothing but I'm also not good in handling such git features.

I also can not see something relevant in the CHANGELOG.

I asked the CPython people: python/cpython#104921 and they gave detailed answers that might help you with fixing this.

@buhtz buhtz changed the title Python 3.12 Python 3.12: no attribute 'parse_parts' May 25, 2023
@buhtz buhtz changed the title Python 3.12: no attribute 'parse_parts' Python 3.12 beta1: no attribute 'parse_parts' May 25, 2023
@mrbean-bremen
Copy link
Member

Thanks - pyfakefs does not officially support Python 3.12 yet. Currently it supports the latest alpha version, which already had sufficient changes (pathlib got refactored again). I will adapt it to the beta as soon as I can, but I think it is sufficient to have a single issue for that.

mrbean-bremen added a commit to mrbean-bremen/pyfakefs that referenced this issue May 29, 2023
- distutils has been removed
- variable renamed in pathlib
- add workaround for patching open,
  comment out not working tests
- fixes pytest-dev#830 and pytest-dev#831
mrbean-bremen added a commit that referenced this issue May 30, 2023
- distutils has been removed
- variable renamed in pathlib
- add workaround for patching open, comment out not working tests
- hopefully fixes #830 and #831
@mrbean-bremen
Copy link
Member

Please check with the main branch and reopen if the issue is still there. Note that the code is no longer compatible with the latest alpha.

@buhtz
Copy link
Author

buhtz commented May 30, 2023

I can confirm you are right.

After TravisCI no supports Python 3.12.0b1+ there is no error anymore.

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 a pull request may close this issue.

2 participants