Author mark.dickinson
Recipients benjamin.peterson, bob.ippolito, collinwinter, georg.brandl, giampaolo.rodola, inducer, jafo, mark.dickinson, meador.inge, nnorwitz, piman
Date 2010-03-07.12:22:52
SpamBayes Score 1.74693e-08
Marked as misclassified No
Message-id <1267964576.65.0.754954897344.issue1530559@psf.upfronthosting.co.za>
In-reply-to
Content
Here's a patch to restore the old usage of __int__ to convert non-integer arguments;  it also produces a DeprecationWarning whenever __int__ is used in this way.  For consistency and simplicity, __int__ will be tried for *any* non-integer argument when packing with an integer format;  this goes beyond the conversions that 2.6 allows. (In 2.6, the behaviour is somewhat random: it works only for 'bBhHil' in native mode and 'bhil' in non-native mode.)

It doesn't seem worth deliberately trying __long__ as well, so I've left that out.  So there's still some possibility for breakage relative to 2.6, when (1) packing using 'Q' or 'q', *and* (2) the object to be packed defines __long__ but not __int__, or defines both __long__ and __int__ in inconsistent ways.  The likelihood of (2) seems small enough that this isn't worth worrying about in practice (and the workaround is easy, too).

Andreas, are you in a position to test this patch?

Supporting conversions to integer via __index__ is orthogonal to this;  I'll take a look at Meador's patch shortly.
History
Date User Action Args
2010-03-07 12:22:57mark.dickinsonsetrecipients: + mark.dickinson, nnorwitz, georg.brandl, collinwinter, jafo, bob.ippolito, piman, inducer, giampaolo.rodola, benjamin.peterson, meador.inge
2010-03-07 12:22:56mark.dickinsonsetmessageid: <1267964576.65.0.754954897344.issue1530559@psf.upfronthosting.co.za>
2010-03-07 12:22:54mark.dickinsonlinkissue1530559 messages
2010-03-07 12:22:53mark.dickinsoncreate