There are a lot of places where Python or modules do something like: self->buf = (char *)malloc(size); if (!self->buf) { PyErr_SetString(PyExc_MemoryError, "out of memory"); At job, we're having some MemoryErrors, and one thing that we would love to know, if how much memory it was asking when that happened. So, I thought about doing something like: char message[50]; ... self->buf = (char *)malloc(size); if (!self->buf) { snprintf(message, 50, "out of memory (asked: %lld)", size); PyErr_SetString(PyExc_MemoryError, &message); Is any inherent problem in doing this? May it be a good idea to make it generic, like providing a PyErr_MemoryError that could accept a message and a number, and stores that number in the exception objects internals? Thanks! -- . Facundo Blog: http://www.taniquetil.com.ar/plog/ PyAr: http://www.python.org/ar/
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