On Tue, Jul 7, 2015 at 12:07 PM, Stefan Behnel <stefan...@behnel.de> wrote:
> Robert Bradshaw schrieb am 07.07.2015 um 19:05:
>> On Tue, Jul 7, 2015 at 8:11 AM, Josh Ayers wrote:
>>> In the function __Pyx_PyUnicode_Tailmatch, the return type of
>>> PyUnicode_Tailmatch is assumed to be in int.  See line 543 of
>>> Cython/Utility/StringTools.c.
>>>
>>> PyUnicode_Tailmatch actually returns a Py_ssize_t.  See:
>>> https://docs.python.org/3/c-api/unicode.html#c.PyUnicode_Tailmatch.
>>>
>>> For reference, there was previously an error in the Python documentation
>>> of this function.  The documentation mistakenly said it returned an int.
>>>  This was fixed via Python issue 22580:
>>> https://bugs.python.org/issue22580.
>>
>> Fixed (though I'm inclined to agree with the assessment that this
>> choice of return type was a bug in the first place).
>>
>> https://github.com/cython/cython/commit/0a5890216d29d7bce941c9ab5cb0cb818eed643d
>
> That's not a complete fix, though, because it would also be necessary to
> widen the types wherever these functions are called. I therefore prefer an
> explicit and local downcast to "int" over letting this API quirk spread.
>
> https://github.com/cython/cython/commit/9962ade0f048dac953b974ff9dddf087ed2b8fab

I did look at the callsites--they were all conversion to a boolean or
the implementation of an explicit call to PyUnicode_Tailmatch in user
code.

- Robert
_______________________________________________
cython-devel mailing list
cython-devel@python.org
https://mail.python.org/mailman/listinfo/cython-devel

Reply via email to