bare excepts

Aaron Bentley aaron.bentley at utoronto.ca
Tue Jan 3 16:39:45 GMT 2006


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Robert Collins wrote:
> On Tue, 2006-01-03 at 01:28 -0500, Aaron Bentley wrote:
> 
>>-----BEGIN PGP SIGNED MESSAGE-----
>>Hash: SHA1
>>
>>Robert Collins wrote:
>>| I'd be happy to extend my code-practices tests to check for:
>>| except:
>>| except Exception[ ,].*
>>| What do you think? (They are persistent little buggers, keep coming
>>| back.)
>>
>>I think we'd need a way to flag some of the second type as legit.  And
>>there's a risk of improper flagging, then.  But on the whole, sure.
> 
> 
> I'll put in a counter - which we can change as needed - to accomodate
> the aggregate legit ones. That said, I *still* have never seen one.

What about the exception logging?

    except Exception, e:
        # used to handle AssertionError and KeyboardInterrupt
        # specially here, but hopefully they're handled ok by the logger now
        import errno
        if (isinstance(e, IOError)
            and hasattr(e, 'errno')
            and e.errno == errno.EPIPE):
            bzrlib.trace.note('broken pipe')
            return 3
        else:
            bzrlib.trace.log_exception()
            if os.environ.get('BZR_PDB'):
                print '**** entering debugger'
                import pdb
                pdb.post_mortem(sys.exc_traceback)
            return 3

Aaron
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org

iD8DBQFDuqjR0F+nu1YWqI0RAq7rAJ9FIv+1Lkhegin1D5hzhKUlGJnAAACgiG3k
e9tiecvdO4qWJJN/z+ZpxVY=
=2w0P
-----END PGP SIGNATURE-----




More information about the bazaar mailing list