diff Lib/test/test_httpservers.py @ 66606:9a2058309c1a

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`.
author Brian Curtin <brian.curtin@gmail.com>
date Thu, 02 Dec 2010 18:29:18 +0000
parents 9717153d558d
children 436bbc7f0aa6
line wrap: on
line diff
--- a/Lib/test/test_httpservers.py	Thu Dec 02 18:06:51 2010 +0000
+++ b/Lib/test/test_httpservers.py	Thu Dec 02 18:29:18 2010 +0000
@@ -304,7 +304,7 @@
 
         # The shebang line should be pure ASCII: use symlink if possible.
         # See issue #7668.
-        if support.can_symlink():
+        if hasattr(os, "symlink"):
             self.pythonexe = os.path.join(self.parent_dir, 'python')
             os.symlink(sys.executable, self.pythonexe)
         else: