[MERGE] setlocale (#128496)

Aaron Bentley aaron at aaronbentley.com
Tue Jun 17 13:35:32 BST 2008


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

Martin von Gagern wrote:
>>> +    try:
>>> +        return ('%r' % string_or_unicode).encode('string_escape')
>>> +    except Exception:
>>> +        pass
>>> +    try:
>>> +        return "unconvertable %s" % str(string_or_unicode.__class__)
>>> +    except Exception:
>>> +        return "unconvertable thingy"
>>> +
>>
>> Discarding all exceptions like this is not ok; it might be something
>> like KeyboardInterrupt that should stop the whole process.  I'm not
>> totally clear what this is for.
> 
> I had to make the testing framework more robust here, as I repeatedly
> encountered errors while reporting tests, which would crash the whole
> selftest. First I only had the contents of the first try block, but when
> that failed as well with some TypeError or ValueError or some such, I
> got desperate and wanted any kind of output at all instead of the test
> suite breaking.
> 
> Notice that a KeyboardInterrupt is a BaseException but not an instance
> of Exception,

That change was made in python2.5.  But we support 2.4.

$ python2.4 -c 'print isinstance(KeyboardInterrupt(), Exception)'
True

> so there wouldn't be any problem in my code for this. On
> the other hand, I might as well use StandardError,

KeyboardInterrupt is a subclass of StandardError on python 2.4

$ python2.4 -c 'print isinstance(KeyboardInterrupt(), StandardError)'
True

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

iD8DBQFIV6+T0F+nu1YWqI0RAuQdAJ9/CPHBbVT9brgAFfZyb7wtL2yTDgCeO/jM
ng4wsMib/wgUBsdjI2no00g=
=Z33U
-----END PGP SIGNATURE-----



More information about the bazaar mailing list