2014/1/11 Ethan Furman <ethan at stoneleaf.us>: >>> b'x=%s' % 10 is well defined, it's pure bytes. >> >> It is well-defined? Then please explain me what the general case of >> b'%s' % x >> is supposed to call: > > This is the key question, isn't it? Python 2 and Python 3 are very different here. In Python 2, the "s" format of PyArg_Parse may call the __str__() method of an object. In Python 3, the "y*" format of PyArg_Parse uses the Py_buffer API which has no slot (there is no protocol like a __getbuffer__() method). The Py_buffer can only be implemented in C. For example, bytes, bytearray and memoryview implement it. PyArg_Parse requires also the buffer to be C-contiguous and has a single segment (use PyBUF_SIMPLE flag). Said differently, bytes%args and bytes.format() would *not* call any method. Victor
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