WindowsError is not available on linux?

Chris Rebert clp2 at
Wed Nov 18 05:18:33 CET 2009

On Tue, Nov 17, 2009 at 7:37 PM, Peng Yu <pengyu.ut at> wrote:
> On Tue, Nov 17, 2009 at 9:18 PM, alex23 <wuwei23 at> wrote:
>> Peng Yu <pengyu... at> wrote:
>>> But the document doesn't say shutil need to be imported in order to
>>> use WindowsError. Shall the document or the code be corrected?
>> Neither, it's your understanding that needs correction.
>> Benjamin wasn't trying to say that WindowsError is defined within
>> shutil, he was showing that it _isn't_ defined within shutil on a non-
>> Windows machine.
>> As you're looking in, you should have noticed this at the
>> very top, just beneath the declaration of the Error exception:
>>    try:
>>        WindowsError
>>    except NameError:
>>        WindowsError = None
>> This looks for the existence of the WindowsError exception - present
>> only under Windows - and if it's not there it binds the name to None.
>> You'll notice that the only place it's used in is prefixed
>> by the test WindowsError is not None...
>> I think the mention of the exception being raised when a "Windows-
>> specific error occurs" should make it pretty clear that this is a
>> Windows-only exception.
> I don't know about others. The wording "Windows-specific error occurs"
> was ambiguous to me. It could refers to some errors resulted from
> copying (on a linux machine) some files from linux file systems to
> windows files systems (via samba, maybe). I recommend to revise the
> document a little bit to avoid confusion.

But your example isn't even Windows-specific because Samba server
exists; any error would network-related or specific to the SMB
protocol rather than Windows-related.


More information about the Python-list mailing list