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 mark.dickinson
Recipients ajaksu2, mark.dickinson, theller, vdupras
Date 2009-07-04.09:30:45
SpamBayes Score 1.7710833e-12
Marked as misclassified No
Message-id <>
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:49mark.dickinsonsetrecipients: + mark.dickinson, theller, ajaksu2, vdupras
2009-07-04 09:30:48mark.dickinsonsetmessageid: <>
2009-07-04 09:30:47mark.dickinsonlinkissue1741130 messages
2009-07-04 09:30:45mark.dickinsoncreate