Mercurial > cpython-lru_cache-weakref
comparison Python/errors.c @ 65688:1b7a0385c65f
Issue #5437: A preallocated MemoryError instance should not hold traceback
data (including local variables caught in the stack trace) alive infinitely.
| author | Antoine Pitrou <solipsis@pitrou.net> |
|---|---|
| date | Thu, 28 Oct 2010 22:56:58 +0000 |
| parents | 39b9e9de372b |
| children | 5605f6920b63 |
comparison
equal
deleted
inserted
replaced
| 65687:613c7b596fe7 | 65688:1b7a0385c65f |
|---|---|
| 331 } | 331 } |
| 332 | 332 |
| 333 PyObject * | 333 PyObject * |
| 334 PyErr_NoMemory(void) | 334 PyErr_NoMemory(void) |
| 335 { | 335 { |
| 336 if (PyErr_ExceptionMatches(PyExc_MemoryError)) | 336 PyErr_SetNone(PyExc_MemoryError); |
| 337 /* already current */ | |
| 338 return NULL; | |
| 339 | |
| 340 /* raise the pre-allocated instance if it still exists */ | |
| 341 if (PyExc_MemoryErrorInst) | |
| 342 { | |
| 343 /* Clear the previous traceback, otherwise it will be appended | |
| 344 * to the current one. | |
| 345 * | |
| 346 * The following statement is not likely to raise any error; | |
| 347 * if it does, we simply discard it. | |
| 348 */ | |
| 349 PyException_SetTraceback(PyExc_MemoryErrorInst, Py_None); | |
| 350 | |
| 351 PyErr_SetObject(PyExc_MemoryError, PyExc_MemoryErrorInst); | |
| 352 } | |
| 353 else | |
| 354 /* this will probably fail since there's no memory and hee, | |
| 355 hee, we have to instantiate this class | |
| 356 */ | |
| 357 PyErr_SetNone(PyExc_MemoryError); | |
| 358 | |
| 359 return NULL; | 337 return NULL; |
| 360 } | 338 } |
| 361 | 339 |
| 362 PyObject * | 340 PyObject * |
| 363 PyErr_SetFromErrnoWithFilenameObject(PyObject *exc, PyObject *filenameObject) | 341 PyErr_SetFromErrnoWithFilenameObject(PyObject *exc, PyObject *filenameObject) |
