Petri Lehtinen <pe...@digip.org> added the comment:

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.

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue11694>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to