This issue tracker has been migrated to GitHub ,
and is currently read-only.
For more information,
see the GitHub FAQs in the Python's Developer Guide.
Created on 2011年01月05日 02:55 by vstinner, last changed 2022年04月11日 14:57 by admin. This issue is now closed.
| Files | ||||
|---|---|---|---|---|
| File name | Uploaded | Description | Edit | |
| pybytes_fromformat_y.patch | vstinner, 2011年01月05日 03:34 | |||
| Messages (3) | |||
|---|---|---|---|
| msg125398 - (view) | Author: STINNER Victor (vstinner) * (Python committer) | Date: 2011年01月05日 02:55 | |
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).
|
|||
| msg125401 - (view) | Author: STINNER Victor (vstinner) * (Python committer) | Date: 2011年01月05日 03:34 | |
Patch implementing this feature. It only supports bytes. |
|||
| msg136811 - (view) | Author: STINNER Victor (vstinner) * (Python committer) | Date: 2011年05月24日 23:43 | |
The "%y" format is useless for the posixmodule.c example (it doesn't simplify the code), and I cannot find another usage of this feature. So let's forget it :-) |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022年04月11日 14:57:10 | admin | set | github: 55041 |
| 2011年05月24日 23:43:47 | vstinner | set | status: open -> closed resolution: not a bug messages: + msg136811 |
| 2011年01月05日 03:34:11 | vstinner | set | files:
+ pybytes_fromformat_y.patch messages: + msg125401 keywords: + patch |
| 2011年01月05日 02:55:05 | vstinner | create | |