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

Fixed a case when template variable is WindowsPath #2707

Merged
merged 1 commit into from
Apr 23, 2024

Conversation

NtWriteCode
Copy link
Contributor

Thanks for contributing, make sure you address all the checklists (for details on how see development documentation)

I think the fix is trivial enough not to create new tests on them.
Also I'm unsure if it's going to be a new release, hence I didn't change the changelog.

@gaborbernat gaborbernat merged commit 4a13deb into pypa:main Apr 23, 2024
46 of 47 checks passed
@maresb
Copy link

maresb commented Apr 23, 2024

I'm hitting this the corresponding issue also on Linux when running pre-commit:

[INFO] Installing environment for https://github.com/astral-sh/ruff-pre-commit.
[INFO] Once installed this environment will be reused.
[INFO] This may take a few minutes...
An unexpected error has occurred: CalledProcessError: command: ('/opt/conda/bin/python3.11', '-mvirtualenv', '/home/mambauser/.cache/pre-commit/repopp_kosvk/py_env-python3')
return code: 1
stdout:
    AttributeError: 'PosixPath' object has no attribute 'endswith'
stderr: (none)
$ python -mvirtualenv --with-traceback /tmp/x
Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "/opt/conda/lib/python3.11/site-packages/virtualenv/__main__.py", line 70, in <module>
    run_with_catch()  # pragma: no cov
    ^^^^^^^^^^^^^^^^
  File "/opt/conda/lib/python3.11/site-packages/virtualenv/__main__.py", line 56, in run_with_catch
    run(args, options, env)
  File "/opt/conda/lib/python3.11/site-packages/virtualenv/__main__.py", line 18, in run
    session = cli_run(args, options, env)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/conda/lib/python3.11/site-packages/virtualenv/run/__init__.py", line 33, in cli_run
    of_session.run()
  File "/opt/conda/lib/python3.11/site-packages/virtualenv/run/session.py", line 46, in run
    self._activate()
  File "/opt/conda/lib/python3.11/site-packages/virtualenv/run/session.py", line 65, in _activate
    activator.generate(self.creator)
  File "/opt/conda/lib/python3.11/site-packages/virtualenv/activation/via_template.py", line 27, in generate
    generated = self._generate(replacements, self.templates(), dest_folder, creator)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/conda/lib/python3.11/site-packages/virtualenv/activation/via_template.py", line 51, in _generate
    encoding = "utf-8-sig" if template.endswith(".ps1") else "utf-8"
                              ^^^^^^^^^^^^^^^^^
AttributeError: 'PosixPath' object has no attribute 'endswith'

Glad to see this merged, it'd be great to get this released soon.

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 this pull request may close these issues.

3 participants