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

Revert "also disallow altsep beside pathsep inside paths" #1598

Merged
merged 2 commits into from
Feb 13, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/changelog/1582.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Allow the use of ``/`` as pathname component separator on Windows - by ``vphilippon``
11 changes: 5 additions & 6 deletions src/virtualenv/create/creator.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,12 +117,11 @@ def non_write_able(dest, value):
encoding, "".join(refused.keys()), raw_value
)
)
for char in (i for i in (os.pathsep, os.altsep) if i is not None):
if char in raw_value:
raise ArgumentTypeError(
"destination {!r} must not contain the path separator ({}) as this would break "
"the activation scripts".format(raw_value, char)
)
if os.pathsep in raw_value:
raise ArgumentTypeError(
"destination {!r} must not contain the path separator ({}) as this would break "
"the activation scripts".format(raw_value, os.pathsep)
)

value = Path(raw_value)
if value.exists() and value.is_file():
Expand Down
14 changes: 10 additions & 4 deletions tests/unit/create/test_creator.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,12 @@
CURRENT = PythonInfo.current_system()


@pytest.mark.parametrize("sep", [i for i in (os.pathsep, os.altsep) if i is not None])
def test_os_path_sep_not_allowed(tmp_path, capsys, sep):
target = "{}{}".format(str(tmp_path / "a"), "{}b".format(sep))
def test_os_path_sep_not_allowed(tmp_path, capsys):
target = str(tmp_path / "a{}b".format(os.pathsep))
err = _non_success_exit_code(capsys, target)
msg = (
"destination {!r} must not contain the path separator ({}) as this"
" would break the activation scripts".format(target, sep)
" would break the activation scripts".format(target, os.pathsep)
)
assert msg in err, err

Expand Down Expand Up @@ -301,6 +300,13 @@ def test_creator_input_passed_is_abs(tmp_path, monkeypatch):
assert str(result) == str(tmp_path / "venv")


@pytest.mark.skipif(os.altsep is None, reason="OS does not have an altsep")
def test_creator_replaces_altsep_in_dest(tmp_path):
dest = str(tmp_path / "venv{}foobar")
result = Creator.validate_dest(dest.format(os.altsep))
assert str(result) == dest.format(os.sep)


def test_create_long_path(current_fastest, tmp_path):
if sys.platform == "darwin":
max_shebang_length = 512
Expand Down