Skip to content
Open
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
12 changes: 11 additions & 1 deletion Lib/test/test_venv.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@
import os.path
import pathlib
import re
import shlex
import shutil
import subprocess
import sys
import sysconfig
import tempfile
import shlex
from test.support import (captured_stdout, captured_stderr,
skip_if_broken_multiprocessing_synchronize, verbose,
requires_subprocess, is_android, is_apple_mobile,
Expand Down Expand Up @@ -373,6 +373,16 @@
with open(fn, 'wb') as f:
f.write(b'Still here?')

@unittest.skipUnless(hasattr(os, 'listxattr'), 'test requires os.listxattr')
def test_install_scripts_selinux(self):

Check failure on line 377 in Lib/test/test_venv.py

View workflow job for this annotation

GitHub Actions / lint

Ruff (invalid-syntax)

Lib/test/test_venv.py:377:1: invalid-syntax: Expected class, function definition or async function definition after decorator
"""
gh-145417: Test that install_scripts does not copy SELinux context
when copying scripts.
"""
with patch('os.listxattr') as listxattr_mock:
venv.create(self.env_dir)
listxattr_mock.assert_not_called()

def test_overwrite_existing(self):
"""
Test creating environment in an existing directory.
Expand Down Expand Up @@ -892,7 +902,7 @@
self.fail("venvwlauncher.exe did not run %s" % exename)


@requireVenvCreate

Check failure on line 905 in Lib/test/test_venv.py

View workflow job for this annotation

GitHub Actions / lint

Ruff (invalid-syntax)

Lib/test/test_venv.py:905:1: invalid-syntax: Expected a statement
class EnsurePipTest(BaseTest):
"""Test venv module installation of pip."""
def assert_pip_not_installed(self):
Expand Down
2 changes: 1 addition & 1 deletion Lib/venv/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -581,7 +581,7 @@ def skip_file(f):
'may be binary: %s', srcfile, e)
continue
if new_data == data:
shutil.copy2(srcfile, dstfile)
shutil.copy(srcfile, dstfile)
else:
with open(dstfile, 'wb') as f:
f.write(new_data)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Prevent incorrect preservation of SELinux context when copying scripts in :mod:`venv`.
Loading