Question

I've observed that shutil fails to import WindowsError on our windows 7 systems:

    from shutil import WindowsError
    File <file>, line <no>, in <module>
        from shutil import WindowsError
    ImportError: cannot import name WindowsError

The same statement works absolutely fine on linux. Has anyone else come across it too? Do you know how I could fix it?

Python version: 2.6.7
Linux OS: Centos 6.3
Windows OS: Windows 7 Professional x64

Était-ce utile?

La solution

Got a solution from the python bug tracker:

http://bugs.python.org/issue18525

This is an implementation artifact and would not be fixed. The import statement such as above are a wrong usage. The correct usage being(if necessary):

try:
    WindowsError
except NameError:
    WindowsError = None
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top