"Martin v. Loewis" wrote: > > > How about this: we add a wchar_t codec to Python and the "eu#" parser > > marker. Then you could write: > > > > wchar_t value = NULL; > > int len = 0; > > if (PyArg_ParseTuple(tuple, "eu#", "wchar_t", &value, &len) < 0) > > return NULL; > > Wouldn't that code be incorrect if there are further format argument > whose conversion could fail also? Yes; you'd currently have to write: wchar_t value = NULL; int len = 0; if (PyArg_ParseTuple(tuple, "eu#", "wchar_t", &value, &len) < 0) goto onError; ... onError: if (value) PyMem_Free(value); return NULL; > I think format specifiers that require explicit memory management are > so difficult to use that they must be avoided. I'd be in favour of > extending the argtuple type to include additional slots for objects > that go away when the tuple goes away. I don't understand that last comment. Anyway, you've got a point there: allocated buffers should be freed in case the PyArg_ParserTuple() API fails (and then reset the *buffer pointer to NULL). -- Marc-Andre Lemburg CEO eGenix.com Software GmbH ______________________________________________________________________ Company & Consulting: http://www.egenix.com/ Python Software: http://www.egenix.com/files/python/
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