Message90109
Thanks for the patch, Daniel! It certainly fixes the problem. I was
planning something a little more drastic, though---I think the struct
module could do with a bit of a cleanup in this area.
At the moment it's not clear exactly what types should be accepted by
struct.pack with an integer format. Just ints and longs (and their
subclases)? Anything implementing an __index__ method? Anything
implementing an __int__ method (e.g., Decimal instances)?
I propose doing a little bit of rewriting so that
(1) all attempted conversions of a PyObject to a C integer
go through PyNumber_Index; thus anything with an __index__
method can be packed.
(2) If PY_STRUCT_FLOAT_COERCE is defined, instances of float or
subclasses of float (i.e., everything that passes PyFloat_Check)
are also accepted, for backwards compatibility.
Does this seem reasonable? |
|
Date |
User |
Action |
Args |
2009-07-04 09:30:49 | mark.dickinson | set | recipients:
+ mark.dickinson, theller, ajaksu2, vdupras |
2009-07-04 09:30:48 | mark.dickinson | set | messageid: <1246699848.74.0.0103628785671.issue1741130@psf.upfronthosting.co.za> |
2009-07-04 09:30:47 | mark.dickinson | link | issue1741130 messages |
2009-07-04 09:30:45 | mark.dickinson | create | |
|