Hello, I am not sure if this is expected behaviour, or a bug. In a C extension module, if I create and return an empty bytes object like this: val = PyBytes_FromStringAndSize (NULL, 20); Py_SIZE(val) = 0; Then from the Python interpreter's perspective: isinstance(val, bytes) returns True print(val) returns b'' print(repr(val)) returns b'' BUT val == b'' returns False. On the other hand, initializing the underlying memory: val = PyBytes_FromStringAndSize (NULL, 20); PyBytes_AS_STRING (val); c[0] = '\0'; Py_SIZE(val) = 0; Then, from the Python interpreter, val == b'' returns True, as expected. So, my question is: is this the expected behaviour, or a bug? I was slightly surprised to have to initialize the storage. On the other hand, I can perhaps also see it might be expected, since the docs do say that PyBytes_FromStringAndSize will not initialize the underlying storage. Please cc me on any replies - am not subscribed to the list. Many thanks, Jonathan
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4