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

venv.EnvBuilder.ensure_directories() no longer accepts Path for env_dir parameter #92675

Open
davidfstr opened this issue May 11, 2022 · 0 comments · May be fixed by #92676
Open

venv.EnvBuilder.ensure_directories() no longer accepts Path for env_dir parameter #92675

davidfstr opened this issue May 11, 2022 · 0 comments · May be fixed by #92676
Labels
stdlib type-bug

Comments

@davidfstr
Copy link
Contributor

@davidfstr davidfstr commented May 11, 2022

Bug report

The Poetry project's install-poetry.py setup script relies on the ability to pass a Path instance to venv.EnvBuilder.ensure_directories(), which is possible in Python 3.10. However Python 3.11b1 introduced code that assumed the use of a str path which crashes when given a Path.

Repro steps:

$ wget https://raw.githubusercontent.com/python-poetry/poetry/master/install-poetry.py
$ python3 install-poetry.py 
[...]
Installing Poetry (1.1.13): Creating environment
Traceback (most recent call last):
  File "/Users/davidf/Projects/trycast/install-poetry.py", line 908, in <module>
    sys.exit(main())
             ^^^^^^
  File "/Users/davidf/Projects/trycast/install-poetry.py", line 876, in main
    return installer.run()
           ^^^^^^^^^^^^^^^
  File "/Users/davidf/Projects/trycast/install-poetry.py", line 507, in run
    self.install(version)
    ^^^^^^^^^^^^^^^^^^^^^
  File "/Users/davidf/Projects/trycast/install-poetry.py", line 528, in install
    with self.make_env(version) as env:
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/contextlib.py", line 137, in __enter__
    return next(self.gen)
           ^^^^^^^^^^^^^^
  File "/Users/davidf/Projects/trycast/install-poetry.py", line 600, in make_env
    raise e
    ^^^^^^^
  File "/Users/davidf/Projects/trycast/install-poetry.py", line 586, in make_env
    yield VirtualEnvironment.make(env_path)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/davidf/Projects/trycast/install-poetry.py", line 292, in make
    builder.ensure_directories(target)
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/venv/__init__.py", line 119, in ensure_directories
    if os.pathsep in env_dir:
       ^^^^^^^^^^^^^^^^^^^^^
TypeError: argument of type 'PosixPath' is not iterable

Your environment

  • CPython 3.11b1

I have a patch to fix, which I will be posting as a PR shortly.

@davidfstr davidfstr added the type-bug label May 11, 2022
@ronaldoussoren ronaldoussoren added the stdlib label May 11, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stdlib type-bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants