Eryk Sun added the comment:
On second thought, it occurred to me that the problem isn't in Explorer or
shell32, but in the drop handler. It turns out the problem is that the drop
handler calls the ANSI API DragQueryFileA instead of DragQueryFileW. To see
this I attached a debugger to Explorer and set a breakpoint on
shell32!DragQueryFileA:
Breakpoint 0 hit
SHELL32!DragQueryFileA:
00007ffd`bed1a5b0 4883ec38 sub rsp,38h
0:056> k 3
Child-SP RetAddr Call Site
00000000`0ee3e0f8 00007ffd`b2c95b7a SHELL32!DragQueryFileA
00000000`0ee3e100 00007ffd`bedade2e wshext!CWSHExtension::Drop+0x7a
00000000`0ee3e300 00007ffd`bed9d547
SHELL32!CDVDropTarget::_PerformDrop+0x14a
Note that the shell is deferring to the drop handler for the file type, which
in our case is implemented by wshext.dll.
The first DragQueryFileA call is to query the number of files (i.e. iFile ==
0xFFFFFFFF):
0:056> r rdx
rdx=00000000ffffffff
0:056> g
The 2nd call gets the ANSI encoded filename:
Breakpoint 0 hit
SHELL32!DragQueryFileA:
00007ffd`bed1a5b0 4883ec38 sub rsp,38h
0:056> r r8
r8=000000000ee3e1a0
0:056> pt; da ee3e1a0
00000000`0ee3e1a0 "C:\Temp\A.txt"
The drop handler is set in the Python.File ProgId, which is defined in the
installer in Tools/msi/launcher/launcher_reg.wxs, which configures the
following registry entry:
C:\>reg query HKLM\Software\Classes\Python.File\shellex\DropHandler
HKEY_LOCAL_MACHINE\Software\Classes\Python.File\shellex\DropHandler
(Default) REG_SZ {60254CA5-953B-11CF-8C96-00AA00B8708C}
As we previously saw in the stack trace, it's implemented by wshext.dll:
C:\>reg query
HKLM\Software\Classes\CLSID\{60254CA5-953B-11CF-8C96-00AA00B8708C} /s
HKEY_LOCAL_MACHINE\Software\Classes\CLSID\{60254CA5-953B-11CF-8C96-00AA00B8708C}
(Default) REG_SZ Shell Extension For Windows Script Host
HKEY_LOCAL_MACHINE\Software\Classes\CLSID\{60254CA5-953B-11CF-8C96-00AA00B8708C}\InProcServer32
(Default) REG_SZ C:\Windows\System32\wshext.dll
ThreadingModel REG_SZ Apartment
I thought I could fix this easily by switching to the drop handler that batfile
and exefile use:
C:\>reg add HKLM\Software\Classes\Python.File\shellex\DropHandler /ve /d ^
More? {86C86720-42A0-1069-A2E8-08002B30309D}
Value exists, overwrite(Yes/No)? y
The operation completed successfully.
This gets the Unicode filename right, but when I move "Ā.txt" to a directory
under "Program Files", I see that it uses short filenames in the path.
['C:\\PROGRA~1\\Python35\\Ā.txt']
Is that acceptable?
----------
resolution: third party ->
stage: resolved ->
status: closed -> open
_______________________________________
Python tracker <[email protected]>
<http://bugs.python.org/issue27469>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com