This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author eryksun
Recipients Drekin, abarry, eryksun, ezio.melotti, paul.moore, steve.dower, tim.golden, vstinner, zach.ware
Date 2016-07-09.03:13:09
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
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
    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
    0:056> g

The 2nd call gets the ANSI encoded filename:

    Breakpoint 0 hit
    00007ffd`bed1a5b0 4883ec38        sub     rsp,38h
    0:056> r r8
    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

        (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

        (Default)    REG_SZ    Shell Extension For Windows Script Host

        (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. 


Is that acceptable?
Date User Action Args
2016-07-09 03:13:12eryksunsetrecipients: + eryksun, paul.moore, vstinner, tim.golden, ezio.melotti, zach.ware, Drekin, steve.dower, abarry
2016-07-09 03:13:11eryksunsetmessageid: <>
2016-07-09 03:13:11eryksunlinkissue27469 messages
2016-07-09 03:13:09eryksuncreate