New submission from STINNER Victor <victor.stin...@haypocalc.com>: It would be very practical use have a format, eg. '%y', to accept bytes object in PyBytes_FromFormatV().
Example (extracted from posixmodule.c): k = PyBytes_AsString(key2); v = PyBytes_AsString(val2); len = PyBytes_GET_SIZE(key2) + PyBytes_GET_SIZE(val2) + 2; p = PyMem_NEW(char, len); if (p == NULL) { PyErr_NoMemory(); ... } PyOS_snprintf(p, len, "%s=%s", k, v); With %y, it can be written: p = PyBytes_FromFormat("%y=%y", key2, val2); if (p == NULL) { PyErr_NoMemory(); ... } The '%y' may also accept bytearray and any object with the buffer interface (as the 'y' format of PyArg_Parse*() functions). ---------- components: Interpreter Core messages: 125398 nosy: haypo priority: normal severity: normal status: open title: Add support of bytes objects in PyBytes_FromFormatV() versions: Python 3.3 _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue10832> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com