Skip to content

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

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

Closed
davidfstr opened this issue May 11, 2022 · 0 comments · Fixed by #92676
Closed

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

davidfstr opened this issue May 11, 2022 · 0 comments · Fixed by #92676
Labels
stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error

Comments

@davidfstr
Copy link
Contributor

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 An unexpected behavior, bug, or error label May 11, 2022
@ronaldoussoren ronaldoussoren added the stdlib Python modules in the Lib dir label May 11, 2022
miss-islington pushed a commit to miss-islington/cpython that referenced this issue May 19, 2022
… for env_dir (pythonGH-92676)

Co-authored-by: Jelle Zijlstra <[email protected]>
Co-authored-by: Alex Waygood <[email protected]>
(cherry picked from commit 30deeac)

Co-authored-by: David Foster <[email protected]>
JelleZijlstra added a commit that referenced this issue May 19, 2022
…nv_dir (#92676)

Co-authored-by: Jelle Zijlstra <[email protected]>
Co-authored-by: Alex Waygood <[email protected]>
miss-islington added a commit that referenced this issue May 19, 2022
…nv_dir (GH-92676)

Co-authored-by: Jelle Zijlstra <[email protected]>
Co-authored-by: Alex Waygood <[email protected]>
(cherry picked from commit 30deeac)

Co-authored-by: David Foster <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants