Mercurial > cpython-lru_cache-weakref
comparison Python/errors.c @ 65690:c6d86439aa91 3.1
Merged revisions 85896 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/branches/py3k
........
r85896 | antoine.pitrou | 2010-10-29 00:56:58 +0200 (ven., 29 oct. 2010) | 4 lines
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 23:06:57 +0000 |
| parents | f197407bdba2 |
| children | 3c9232a684ae |
comparison
equal
deleted
inserted
replaced
| 65672:e4425d68dadf | 65690:c6d86439aa91 |
|---|---|
| 326 } | 326 } |
| 327 | 327 |
| 328 PyObject * | 328 PyObject * |
| 329 PyErr_NoMemory(void) | 329 PyErr_NoMemory(void) |
| 330 { | 330 { |
| 331 if (PyErr_ExceptionMatches(PyExc_MemoryError)) | 331 PyErr_SetNone(PyExc_MemoryError); |
| 332 /* already current */ | |
| 333 return NULL; | |
| 334 | |
| 335 /* raise the pre-allocated instance if it still exists */ | |
| 336 if (PyExc_MemoryErrorInst) | |
| 337 { | |
| 338 /* Clear the previous traceback, otherwise it will be appended | |
| 339 * to the current one. | |
| 340 * | |
| 341 * The following statement is not likely to raise any error; | |
| 342 * if it does, we simply discard it. | |
| 343 */ | |
| 344 PyException_SetTraceback(PyExc_MemoryErrorInst, Py_None); | |
| 345 | |
| 346 PyErr_SetObject(PyExc_MemoryError, PyExc_MemoryErrorInst); | |
| 347 } | |
| 348 else | |
| 349 /* this will probably fail since there's no memory and hee, | |
| 350 hee, we have to instantiate this class | |
| 351 */ | |
| 352 PyErr_SetNone(PyExc_MemoryError); | |
| 353 | |
| 354 return NULL; | 332 return NULL; |
| 355 } | 333 } |
| 356 | 334 |
| 357 PyObject * | 335 PyObject * |
| 358 PyErr_SetFromErrnoWithFilenameObject(PyObject *exc, PyObject *filenameObject) | 336 PyErr_SetFromErrnoWithFilenameObject(PyObject *exc, PyObject *filenameObject) |
