Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit acbf461

Browse files
committed
Merged revisions 68893 via svnmerge from
svn+ssh://[email protected]/python/trunk ........ r68893 | martin.v.loewis | 2009-01-24 16:47:27 +0100 (Sa, 24 Jan 2009) | 3 lines Issue #3881: Help Tcl to load even when started through the unreadable local symlink to "Program Files" on Vista. ........
1 parent 17e5587 commit acbf461

2 files changed

Lines changed: 38 additions & 0 deletions

File tree

Lib/tkinter/_fix.py

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,48 @@
1010
# <TCL_LIBRARY>\..\tcl<TCL_VERSION>, so anything close to
1111
# the real Tcl library will do.
1212

13+
# Expand symbolic links on Vista
14+
try:
15+
import ctypes
16+
ctypes.windll.kernel32.GetFinalPathNameByHandleW
17+
except (ImportError, AttributeError):
18+
def convert_path(s):
19+
return s
20+
else:
21+
def convert_path(s):
22+
if isinstance(s, bytes):
23+
s = s.decode("mbcs")
24+
hdir = ctypes.windll.kernel32.\
25+
CreateFileW(s, 0x80, # FILE_READ_ATTRIBUTES
26+
1, # FILE_SHARE_READ
27+
None, 3, # OPEN_EXISTING
28+
0x02000000, # FILE_FLAG_BACKUP_SEMANTICS
29+
None)
30+
if hdir == -1:
31+
# Cannot open directory, give up
32+
return s
33+
buf = ctypes.create_unicode_buffer("", 32768)
34+
res = ctypes.windll.kernel32.\
35+
GetFinalPathNameByHandleW(hdir, buf, len(buf),
36+
0) # VOLUME_NAME_DOS
37+
ctypes.windll.kernel32.CloseHandle(hdir)
38+
if res == 0:
39+
# Conversion failed (e.g. network location)
40+
return s
41+
s = buf[:res]
42+
# Ignore leading \\?\
43+
if s.startswith("\\\\?\\"):
44+
s = s[4:]
45+
return s
46+
1347
prefix = os.path.join(sys.prefix,"tcl")
1448
if not os.path.exists(prefix):
1549
# devdir/../tcltk/lib
1650
prefix = os.path.join(sys.prefix, os.path.pardir, "tcltk", "lib")
1751
prefix = os.path.abspath(prefix)
1852
# if this does not exist, no further search is needed
1953
if os.path.exists(prefix):
54+
prefix = convert_path(prefix)
2055
if "TCL_LIBRARY" not in os.environ:
2156
for name in os.listdir(prefix):
2257
if name.startswith("tcl"):

Misc/NEWS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,9 @@ Core and Builtins
139139
Library
140140
-------
141141

142+
- Issue #3881: Help Tcl to load even when started through the
143+
unreadable local symlink to "Program Files" on Vista.
144+
142145
- Issue #4710: Extract directories properly in the zipfile module;
143146
allow adding directories to a zipfile.
144147

0 commit comments

Comments
 (0)