classification
Title: uu module catches a wrong exception type
Type: behavior Stage:
Components: Library (Lib) Versions: Python 2.5
process
Status: closed Resolution: invalid
Dependencies: Superseder:
Assigned To: Nosy List: giampaolo.rodola, gvanrossum (2)
Priority: Keywords

Created on 2007-11-02 23:13 by giampaolo.rodola, last changed 2007-11-03 15:17 by gvanrossum.

Messages (2)
msg57077 - (view) Author: Giampaolo Rodola' (giampaolo.rodola) Date: 2007-11-02 23:13
uu module on line 53 erroneously tries to catch an AttributeError
exception type.

            try:
                mode = os.stat(in_file).st_mode
            except AttributeError:
                pass

This is not correct since os.stat(), as far as I know, should raise
OSError exceptions only.
This would turn in an error in case we pass a "broken" symlink as
in_file argument.
msg57083 - (view) Author: Guido van Rossum (gvanrossum) Date: 2007-11-03 15:17
You misunderstand. The try/except is there in case os.stat isn't defined 
or its result doesn't have a st_mode attribute. If the stat operation 
fails due to a problem with the file, there's not much point in proceeding 
since the subsequent open() call would fail the same way.
History
Date User Action Args
2007-11-03 15:17:45gvanrossumsetstatus: open -> closed
resolution: invalid
messages: + msg57083
nosy: + gvanrossum
2007-11-02 23:13:53giampaolo.rodolacreate