[Python-Dev] threading.Semaphore()'s counter can become negative for non-ints

Benjamin Peterson benjamin at python.org
Mon Jan 30 23:23:42 CET 2012


2012/1/30 Nick Coghlan <ncoghlan at gmail.com>:
> On Tue, Jan 31, 2012 at 8:11 AM, Matt Joiner <anacrolix at gmail.com> wrote:
>> It's also potentially lossy if you incremented and decremented until integer
>> precision is lost. My vote is for an int type check. No casting.
>
> operator.index() is built for that purpose (it's what we use these
> days to restrict slicing to integers).
>
> +1 for the type restriction from me.

We don't need a type check. Just pass integers (obviously the only
right type) to it.


-- 
Regards,
Benjamin


More information about the Python-Dev mailing list