WindowsError is not available on linux?

P

Peng Yu

It's not clear to me whether WindowsError is available on linux or
not, after I read the document. But I see WindowsError in shutil.py.
Could you somebody let me know what cause the following error?
.... raise WindowsError('WindowsError')
.... except WindowsError as e:
.... print e
....
Traceback (most recent call last):
File "<stdin>", line 3, in <module>
NameError: name 'WindowsError' is not defined
 
A

Aahz

It's not clear to me whether WindowsError is available on linux or
not, after I read the document.

Here's what I told a co-worker to do yesterday:

if os.name == 'nt':
DiskError = (OSError, WindowsError)
else:
DiskError = WindowsError

try:
disk_operation()
except DiskError:
logit()
--
Aahz ([email protected]) <*> http://www.pythoncraft.com/

"Debugging is twice as hard as writing the code in the first place.
Therefore, if you write the code as cleverly as possible, you are, by
definition, not smart enough to debug it." --Brian W. Kernighan
 
B

Benjamin Kaplan

Here's what I told a co-worker to do yesterday:

if os.name == 'nt':
   DiskError = (OSError, WindowsError)
else:
   DiskError = WindowsError

try:
   disk_operation()
except DiskError:
   logit()
--

Shouldn't that be the other way?
if os.name == 'nt':
DiskError = OSError, WindowsError
else :
DiskError = OSError
 
E

exarkun

Here's what I told a co-worker to do yesterday:

if os.name == 'nt':
DiskError = (OSError, WindowsError)
else:
DiskError = WindowsError

try:
disk_operation()
except DiskError:
logit()

This isn't necessary. WindowsError subclasses OSError.

Jean-Paul
 
D

Dave Angel

Benjamin said:
Shouldn't that be the other way?
if os.name ='nt':
DiskError =SError, WindowsError
else :
DiskError =SError
Doesn't matter. It's not needed anyway, since WindowsError is derived
from OSError. So just use OSError in the except clause.

DaveA
 
A

Aahz

This isn't necessary. WindowsError subclasses OSError.

Thanks! Much appreciated! (I haven't done much Windows programming in
the past -- and would have preferred to keep it that way. ;-)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,994
Messages
2,570,223
Members
46,814
Latest member
SpicetreeDigital

Latest Threads

Top