Message10773

Author pekka.klarck
Recipients pekka.klarck
Date 2016-02-24.09:19:42
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1456305583.0.0.993765126827.issue2474@psf.upfronthosting.co.za>
In-reply-to
Content
To reproduce:

E:\robotframework>jython
Jython 2.7.0 (default:9987c746f838, Apr 29 2015, 02:25:11)
[Java HotSpot(TM) Client VM (Oracle Corporation)] on java1.8.0_73
Type "help", "copyright", "credits" or "license" for more information.
>>> import os, shutil
>>> os.mkdir('foo')
>>> os.mkdir('bar')
>>> shutil.copytree('foo', 'bar/foo')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\jython2.7.0\Lib\shutil.py", line 208, in copytree
    raise Error, errors
shutil.Error: [('foo', 'bar/foo', "[Errno 1] Operation not permitted: 'bar/foo'")]
>>>

The failure seems to be caused by the fact that with Jython WindowsError doesn't exist and shutil has first this code

    try:
        WindowsError
    except NameError:
        WindowsError = None

and later in copytree

    try:
        copystat(src, dst)
    except OSError, why:
        if WindowsError is not None and isinstance(why, WindowsError):
            # Copying file access times may fail on Windows
            pass
        else:
            errors.append((src, dst, str(why)))

I already tested that always ignoring error here makes copytree pass. Even without the change the actual directory is copied fine.

Notice that there is already issue #2314 about related test_shutil failures on Windows. This issue is likely the root cause for those problems.

This problem was initially reported to Robot Framework as https://github.com/robotframework/robotframework/issues/2321. I'm surprised we haven't noticed this problem earlier, because we ought to have tests for the affected functionality that are also run on Windows. It could be that the offending exception doesn't occur always, but I couldn't easily figure out when it occurs and when not.
History
Date User Action Args
2016-02-24 09:19:43pekka.klarcksetrecipients: + pekka.klarck
2016-02-24 09:19:43pekka.klarcksetmessageid: <1456305583.0.0.993765126827.issue2474@psf.upfronthosting.co.za>
2016-02-24 09:19:42pekka.klarcklinkissue2474 messages
2016-02-24 09:19:42pekka.klarckcreate