Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
de24338
Update __init__.py
Shrey-N Mar 3, 2026
ec2958b
Implement test for script installation mtime
Shrey-N Mar 3, 2026
1428e75
Relint test_venv.py and fix trailing whitespace
Shrey-N Mar 3, 2026
8778209
Refine venv test to use Activate.ps1 and check mode (gh-145417)
Shrey-N Mar 3, 2026
52ee5ef
Add news entry
Shrey-N Mar 3, 2026
eec4e46
Rename News
Shrey-N Mar 3, 2026
c4d32d5
Delete Misc/NEWS.d/next/Library/gh-issue-145417.shrey.rst
Shrey-N Mar 3, 2026
88fae45
Apply maintainer's suggestion for docstring clarity
Shrey-N Mar 3, 2026
7dc69f0
Move template protection check before content assertion
Shrey-N Mar 3, 2026
878d3b8
Merge branch 'python:main' into main
Shrey-N Mar 3, 2026
75bd937
Clean up blank lines in test_venv.py
Shrey-N Mar 3, 2026
a76da3e
Enhance test for Activate.ps1 file integrity
Shrey-N Mar 3, 2026
89c0c92
📜🤖 Added by blurb_it.
blurb-it[bot] Mar 3, 2026
431c4ac
Applying maintainer's suggestion for news wording
Shrey-N Mar 3, 2026
9bcf6db
Change Location of time module
Shrey-N Mar 3, 2026
ead93d7
Merge branch 'main' into main
Shrey-N Mar 3, 2026
97652be
Reorder imports alphabetically
Shrey-N Mar 3, 2026
4e127d8
Refactor test for SELinux acc to suggestion
Shrey-N Mar 5, 2026
0e506f1
Fix SELinux context test and update patch usage
Shrey-N Mar 5, 2026
ace163b
Fix mock path for listxattr in SELinux test
Shrey-N Mar 5, 2026
d15ad82
Update test_venv.py
Shrey-N Mar 5, 2026
7abaefc
Fix indentation for test_install_scripts_selinux
Shrey-N Mar 5, 2026
2c23790
Update Misc/NEWS.d/next/Library/2026-03-03-11-49-44.gh-issue-145417.m…
Shrey-N Mar 5, 2026
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 @@ def create_contents(self, paths, filename):
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):
"""
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
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,4 @@
:mod:`venv`: Prevent incorrect preservation of SELinux context
when copying the ``Activate.ps1`` script. The script inherited
the SELinux security context of the system template directory,
rather than the destination project directory.
Loading