diff options
author | Brian Curtin <brian.curtin@gmail.com> | 2010-12-02 18:29:18 (GMT) |
---|---|---|
committer | Brian Curtin <brian.curtin@gmail.com> | 2010-12-02 18:29:18 (GMT) |
commit | 52173d4959a1c1e961efab2522e4ba8a22a3c7c6 (patch) | |
tree | a89463de7c0db84aa60ef25bc05caf8837e2cc33 /Lib/test/test_sysconfig.py | |
parent | 02524629f39bb70f4ea00ab8e64d694e08719227 (diff) | |
download | cpython-52173d4959a1c1e961efab2522e4ba8a22a3c7c6.zip cpython-52173d4959a1c1e961efab2522e4ba8a22a3c7c6.tar.gz cpython-52173d4959a1c1e961efab2522e4ba8a22a3c7c6.tar.bz2 |
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`.
Diffstat (limited to 'Lib/test/test_sysconfig.py')
-rw-r--r-- | Lib/test/test_sysconfig.py | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/Lib/test/test_sysconfig.py b/Lib/test/test_sysconfig.py index 193b5f0..d532ddf 100644 --- a/Lib/test/test_sysconfig.py +++ b/Lib/test/test_sysconfig.py @@ -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. |