Author nre3976
Recipients nre3976
Date 2015-09-22.13:48:39
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1442929720.2.0.722583571486.issue25213@psf.upfronthosting.co.za>
In-reply-to
Content
Python 3.5.0 shutil.copy2 doesn't raise PermissionError when it does not have permission to copy a file (tested on Windows 7):

C:\Users\X\Desktop>C:\Users\X\AppData\Local\Programs\Python\Python35-32\python.exe
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.
>>> import shutil
>>> shutil.copy2("test.txt", "/")
'/test.txt'
>>> shutil.copy2("test.txt", "C:\\")
'C:\\test.txt'

NB: The file is not copied.

Python 3.4.3 does raise PermissionError:

C:\Users\X\Desktop>C:\Python34\python.exe
Python 3.4.3 (v3.4.3:9b73f1c3e601, Feb 24 2015, 22:44:40) [MSC v.1600 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import shutil
>>> shutil.copy2("test.txt", "/")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Python34\lib\shutil.py", line 245, in copy2
    copyfile(src, dst, follow_symlinks=follow_symlinks)
  File "C:\Python34\lib\shutil.py", line 109, in copyfile
    with open(dst, 'wb') as fdst:
PermissionError: [Errno 13] Permission denied: '/test.txt'
>>> shutil.copy2("test.txt", "C:\\")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Python34\lib\shutil.py", line 245, in copy2
    copyfile(src, dst, follow_symlinks=follow_symlinks)
  File "C:\Python34\lib\shutil.py", line 109, in copyfile
    with open(dst, 'wb') as fdst:
PermissionError: [Errno 13] Permission denied: 'C:\\test.txt'
History
Date User Action Args
2015-09-22 13:48:40nre3976setrecipients: + nre3976
2015-09-22 13:48:40nre3976setmessageid: <1442929720.2.0.722583571486.issue25213@psf.upfronthosting.co.za>
2015-09-22 13:48:40nre3976linkissue25213 messages
2015-09-22 13:48:39nre3976create