mirror of
https://github.com/python/cpython.git
synced 2025-08-04 08:59:19 +00:00
Fix #9333. Expose os.symlink on Windows only when usable.
In order to create symlinks on Windows, SeCreateSymbolicLinkPrivilege is an account privilege that is required to be held by the user. Not only must the privilege be enabled for the account, the activated privileges for the currently running application must be adjusted to enable the requested privilege. Rather than exposing an additional function to be called prior to the user's first os.symlink call, we handle the AdjustTokenPrivileges Windows API call internally and only expose os.symlink when the privilege escalation was successful. Due to the change of only exposing os.symlink when it's available, we can go back to the original test skipping methods of checking via `hasattr`.
This commit is contained in:
parent
02524629f3
commit
52173d4959
12 changed files with 126 additions and 79 deletions
|
@ -12,7 +12,7 @@ import shutil
|
|||
from copy import copy, deepcopy
|
||||
|
||||
from test.support import (run_unittest, TESTFN, unlink, get_attribute,
|
||||
captured_stdout, skip_unless_symlink)
|
||||
captured_stdout)
|
||||
|
||||
import sysconfig
|
||||
from sysconfig import (get_paths, get_platform, get_config_vars,
|
||||
|
@ -245,7 +245,8 @@ class TestSysConfig(unittest.TestCase):
|
|||
'posix_home', 'posix_prefix', 'posix_user')
|
||||
self.assertEqual(get_scheme_names(), wanted)
|
||||
|
||||
@skip_unless_symlink
|
||||
@unittest.skipUnless(hasattr(os, "symlink"),
|
||||
"Missing symlink implementation")
|
||||
def test_symlink(self):
|
||||
# On Windows, the EXE needs to know where pythonXY.dll is at so we have
|
||||
# to add the directory to the path.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue