Message125398
| Author |
vstinner |
| Recipients |
vstinner |
| Date |
2011年01月05日.02:55:05 |
| SpamBayes Score |
0.017723387 |
| Marked as misclassified |
No |
| Message-id |
<1294196110.74.0.942895284505.issue10832@psf.upfronthosting.co.za> |
| In-reply-to |
| Content |
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). |
|
History
|
|---|
| Date |
User |
Action |
Args |
| 2011年01月05日 02:55:10 | vstinner | set | recipients:
+ vstinner |
| 2011年01月05日 02:55:10 | vstinner | set | messageid: <1294196110.74.0.942895284505.issue10832@psf.upfronthosting.co.za> |
| 2011年01月05日 02:55:05 | vstinner | link | issue10832 messages |
| 2011年01月05日 02:55:05 | vstinner | create |
|