This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author petri.lehtinen
Recipients georg.brandl, gruszczy, petri.lehtinen
Date 2012-06-05.19:24:14
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1338924255.89.0.345479552938.issue11694@psf.upfronthosting.co.za>
In-reply-to
Content
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.
History
Date User Action Args
2012-06-05 19:24:15petri.lehtinensetrecipients: + petri.lehtinen, georg.brandl, gruszczy
2012-06-05 19:24:15petri.lehtinensetmessageid: <1338924255.89.0.345479552938.issue11694@psf.upfronthosting.co.za>
2012-06-05 19:24:15petri.lehtinenlinkissue11694 messages
2012-06-05 19:24:14petri.lehtinencreate