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 Voo, akira, amaury.forgeotdarc, jcea, mark.dickinson, pitrou, rhettinger, tim.peters
Date 2012-01-31.17:50:56
SpamBayes Score 6.5075747e-06
Marked as misclassified No
Message-id <1328032257.57.0.46607816978.issue13496@psf.upfronthosting.co.za>
In-reply-to
Content
> I think the patch is *NOT* correct.

Can you elaborate?  It works fine for that example on a 64-bit build;  not sure why 32-bit would be any different.

The idea is just that the single cast forces the addition to be done as an addition of integers of type size_t.  Since the integers being added are (a) nonnegative and (b) both fit into a Py_ssize_t, the sum fits into a size_t without overflow, and the result of dividing the sum by 2 fits into a size_t.

(This is all assuming that 2*Py_SSIZE_T_MAX fits into a size_t, but that's a fairly safe assumption in practice.)
History
Date User Action Args
2012-01-31 17:50:57mark.dickinsonsetrecipients: + mark.dickinson, tim.peters, rhettinger, jcea, amaury.forgeotdarc, pitrou, akira, Voo
2012-01-31 17:50:57mark.dickinsonsetmessageid: <1328032257.57.0.46607816978.issue13496@psf.upfronthosting.co.za>
2012-01-31 17:50:57mark.dickinsonlinkissue13496 messages
2012-01-31 17:50:56mark.dickinsoncreate