Message162367
I see one obvious issue with the patch: The ConversionErrors it creates are passed the struct.error or TypeError instance as a parameter. The first argument of these exceptions would be better, i.e.
try:
...
except struct.error as e:
raise ConversionError(e.args[0])
Furthermore, my ear thinks that raises_conversion_error would be a better name for the decorator than raising_conversion_error.
Anyway, I think the whole ConversionError is a bit problematic, as either TypeError or ValueError would be the most appropriate exception, depending on the situation. For example:
p = Packer()
p.pack_int('foo') # should raise a TypeError
p.pack_int(2**100) # should raise a ValueError
This would be slightly harder to implement, though, as struct.error has exactly the same problem. |
|
Date |
User |
Action |
Args |
2012-06-05 19:24:15 | petri.lehtinen | set | recipients:
+ petri.lehtinen, georg.brandl, gruszczy |
2012-06-05 19:24:15 | petri.lehtinen | set | messageid: <1338924255.89.0.345479552938.issue11694@psf.upfronthosting.co.za> |
2012-06-05 19:24:15 | petri.lehtinen | link | issue11694 messages |
2012-06-05 19:24:14 | petri.lehtinen | create | |
|