[issue32431] Two bytes objects of zero length don't compare equal

2017-12-27 Thread Jonathan Underwood
Jonathan Underwood added the comment: Actually the commentary at the top of bytesobject.c for PyBytes_FromStringAndSize says: "... If `str' is NULL then PyBytes_FromStringAndSize() will allocate `size+1' bytes (setting the last byte to the null terminating character)... "

[issue32431] Two bytes objects of zero length don't compare equal

2017-12-27 Thread Jonathan Underwood
Jonathan Underwood added the comment: Py_SIZE is actually precisely specified and documented[1] as it stands; I don't think a change there is needed. The usage I outlined is in line with that documentation, and many other uses of that macro in the cpython sources. The documentation i

[issue32431] Two bytes objects of zero length don't compare equal

2017-12-27 Thread Jonathan Underwood
Change by Jonathan Underwood : -- keywords: +patch pull_requests: +4911 stage: -> patch review ___ Python tracker <https://bugs.python.org/issue32431> ___ _

[issue32431] Two bytes objects of zero length don't compare equal

2017-12-27 Thread Jonathan Underwood
Jonathan Underwood added the comment: https://github.com/python/cpython/pull/5021 -- ___ Python tracker <https://bugs.python.org/issue32431> ___ ___ Python-bug

[issue32431] Two bytes objects of zero length don't compare equal

2017-12-27 Thread Jonathan Underwood
New submission from Jonathan Underwood : With the current logic in Objects/bytesobject.c in the function bytes_compare_eq it can be the case that zero length bytes object object created in an extension module like this: val = PyBytes_FromStringAndSize (NULL, 20); Py_SIZE(val) = 0; won&#