[issue8992] convertsimple() doesn't need to call converterr() if an exception was already raised

STINNER Victor report at bugs.python.org
Sun Jun 13 23:15:33 CEST 2010


New submission from STINNER Victor <victor.stinner at haypocalc.com>:

If convertitem() result is not NULL, an error occured and seterror() is called (by the function calling convertitem()). seterror() does nothing if an exception was raised (if PyErr_Occurred() is non zero).

convertitem() doesn't need to call converterr() if an exception occurred because the string formatted by converterr() will be ignored. We just need to return a non NULL pointer: msgbuf.

Attached patch creates a RETURN_ERR_OCCURRED macro. convertsimple() should be a little bit faster and the code is more readable. Details:
 - addcleanup() now takes a boolean to indicate if it's a buffer or a pointer to simplify the API and have to raise a special error if the destructor is unknown
 - don't check that the result of PyUnicode_AsEncodedString() is a bytes object: PyUnicode_AsEncodedString() does already check that

----------
components: Interpreter Core
files: getarg_err_occurred.patch
keywords: patch
messages: 107753
nosy: haypo
priority: normal
severity: normal
status: open
title: convertsimple() doesn't need to call converterr() if an exception was already raised
versions: Python 3.2
Added file: http://bugs.python.org/file17662/getarg_err_occurred.patch

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue8992>
_______________________________________


More information about the Python-bugs-list mailing list