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: 'PosixPath' object has no attribute '_drv' #831

Closed
buhtz opened this issue May 25, 2023 · 4 comments
Closed

Python 3.12 beta1: 'PosixPath' object has no attribute '_drv' #831

buhtz opened this issue May 25, 2023 · 4 comments

Comments

@buhtz
Copy link

buhtz commented May 25, 2023

Related to #830

--version on TravisCI returns Python 3.12.0a2+. Not sure if this is different from "3.12 beta1".

Here is another error in a pyfakefs using unittest.

======================================================================
ERROR: test_uuid_via_filesystem (test.test_tools.TestTools.test_uuid_via_filesystem)
Extract UUID from /dev filesystem.
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/opt/python/3.12-dev/lib/python3.12/pathlib.py", line 464, in __str__
    return self._str
           ^^^^^^^^^
AttributeError: 'PosixPath' object has no attribute '_str'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/travis/virtualenv/python3.12-dev/lib/python3.12/site-packages/pyfakefs/fake_filesystem_unittest.py", line 142, in wrapped
    return f(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^
  File "/home/travis/build/bit-team/backintime/common/test/test_tools.py", line 482, in test_uuid_via_filesystem
    fake_fs.create_dir(path_dev)
  File "/home/travis/virtualenv/python3.12-dev/lib/python3.12/site-packages/pyfakefs/fake_filesystem.py", line 2037, in create_dir
    dir_path = self.make_string_path(directory_path)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/travis/virtualenv/python3.12-dev/lib/python3.12/site-packages/pyfakefs/fake_filesystem.py", line 2015, in make_string_path
    path_str = make_string_path(path)
               ^^^^^^^^^^^^^^^^^^^^^^
  File "/home/travis/virtualenv/python3.12-dev/lib/python3.12/site-packages/pyfakefs/helpers.py", line 123, in make_string_path
    return cast(AnyStr, os.fspath(dir_name))
                        ^^^^^^^^^^^^^^^^^^^
  File "/opt/python/3.12-dev/lib/python3.12/pathlib.py", line 471, in __fspath__
    return str(self)
           ^^^^^^^^^
  File "/opt/python/3.12-dev/lib/python3.12/pathlib.py", line 466, in __str__
    self._str = self._format_parsed_parts(self._drv, self._root,
                                          ^^^^^^^^^
AttributeError: 'PosixPath' object has no attribute '_drv'

The related code
https://github.com/buhtz/backintime/blob/a80b655229207f90cd2552bec4bc869e597aa024/common/test/test_tools.py#L473-L513

@hugovk
Copy link
Member

hugovk commented May 25, 2023

Python 3.12.0a2+. Not sure if this is different from "3.12 beta1".

3.12.0a2 means "Python 3.12.0 alpha 2" (released 2022-11-14). The + usually indicates it some commits later than the tag, but probably before alpha 3.

So Travis is quite far behind. GitHub Actions is more up-to-date, and this project's CI is already testing 3.12 which is good to see 👍

Here's a build from last week, showing it using 3.12.0-alpha.7 (released 2023-04-04):

@mrbean-bremen
Copy link
Member

GH Actions are up to date, they already use 3.12 beta1 as of today.
Fixing this will take a bit more time, I think - there are hundreds of tests failing, mainly because faking open doesn't work anymore. There are also some more changes to pathlib, though I did expect this, given the history.

I will see if I can get this done over the weekend - I hope that the problem with open is relatively easy to solve.

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 if the problem still happens with the main branch, and with beta 1. I actually consider this invalid, as it was tested with alpha2, which had never been supported. The callstack shows that the respective pathlib code has sufficiently changed meanwhile. I'm going to close this - please write new issues if you find problems with the beta1 (or later) Python version.

@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

No branches or pull requests

3 participants