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 eryksun, nre3976, paul.moore, steve.dower, tim.golden, zach.ware
Date 2015-09-22.17:56:15
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
This issue doesn't pertain to the 64-bit version.

    C:\Temp>py -3.5
    Python 3.5.0 (v3.5.0:374f501f4567, Sep 13 2015, 02:27:37) 
    [MSC v.1900 64 bit (AMD64)] on win32
    Type "help", "copyright", "credits" or "license" for more information.
    >>> import shutil
    >>> shutil.copy2('test.txt', 'C:\\')
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
      File "C:\Program Files\Python 3.5\lib\", line 251, in copy2
        copyfile(src, dst, follow_symlinks=follow_symlinks)
      File "C:\Program Files\Python 3.5\lib\", line 115, in copyfile
        with open(dst, 'wb') as fdst:
    PermissionError: [Errno 13] Permission denied: 'C:\\test.txt'

In the 32-bit version, creating a file in the system root directory gets virtualized when the user doesn't have write access. It's not specific to shutil.copy2.

    C:\Temp>py -3.5-32
    Python 3.5.0 (v3.5.0:374f501f4567, Sep 13 2015, 02:16:59) 
    [MSC v.1900 32 bit (Intel)] on win32
    Type "help", "copyright", "credits" or "license" for more information.
    >>> open('C:\\test.txt', 'w').close()
    >>> import pathlib
    >>> pathlib.Path('C:\\test.txt').resolve()

You can verify in the task manager's details tab that UAC Virtualization is enabled for 32-bit python.exe and disabled for 64-bit python.exe. The problem is that the manifest is missing the requestedExecutionLevel, which should be present and set to "asInvoker". This is discussed in the MSDN article [New UAC Technologies for Windows Vista][1].

    >>> os.system('sigcheck -q -m "%s"' % sys.executable)
            Verified:       Signed
            Signing date:   2:17 AM 9/13/2015
            Publisher:      Python Software Foundation
            Description:    Python
            Product:        Python
            Prod version:   3.5.0
            File version:   3.5.0
            MachineType:    32-bit
    <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
    <assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
      <compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
          <supportedOS Id="{e2011457-1546-43c5-a5fe-008deee3d3f0}"/>
          <supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}"/>
          <supportedOS Id="{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}"/>
          <supportedOS Id="{1f676c76-80e1-4239-95bb-83d0f6d0da78}"/>
          <supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}"/>

3.4's manifest sets the requestedExecutionLevel:

    C:\Temp>py -3.4-32
    Python 3.4.3 (v3.4.3:9b73f1c3e601, Feb 24 2015, 22:43:06) 
    [MSC v.1600 32 bit (Intel)] on win32
    Type "help", "copyright", "credits" or "license" for more information.
    >>> import os, sys
    >>> os.system('sigcheck -q -m "%s"' % sys.executable)
            Verified:       Unsigned
            Link date:      9:43 PM 2/24/2015
            Publisher:      n/a
            Description:    n/a
            Product:        n/a
            Prod version:   n/a
            File version:   n/a
            MachineType:    32-bit
    <assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
      <trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
            <requestedExecutionLevel level="asInvoker" uiAccess="false"></requestedExecutionLevel>

Date User Action Args
2015-09-22 17:56:16eryksunsetrecipients: + eryksun, paul.moore, tim.golden, zach.ware, steve.dower, nre3976
2015-09-22 17:56:16eryksunsetmessageid: <>
2015-09-22 17:56:16eryksunlinkissue25213 messages
2015-09-22 17:56:15eryksuncreate