[issue17544] regex code re-raises exceptions on success

2020-05-31 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: When function sets an exception, it should return NULL. Otherwise the behavior of the interpreter is undefined, it can crash in debug build or developing mode. See for example https://docs.python.org/3/extending/extending.html#intermezzo-errors-and-excepti

[issue17544] regex code re-raises exceptions on success

2013-03-26 Thread Zdeněk Pavlas
Zdeněk Pavlas added the comment: Yes, found that *certain* IO operations re-raise the error, too. However, if the Python runtime expects extension writers to keep tstate->curexc_type clear, it should be documented in http://docs.python.org/2/c-api/exceptions.html There's not a single use cas

[issue17544] regex code re-raises exceptions on success

2013-03-25 Thread Amaury Forgeot d'Arc
Amaury Forgeot d'Arc added the comment: The returned value and the global indicator are not independent. C functions should not set an error while returning a valid value. The same behavior will occur in random places -- for example, "for x in range(2): pass" also triggers the issue, this is

[issue17544] regex code re-raises exceptions on success

2013-03-25 Thread Zdeněk Pavlas
Zdeněk Pavlas added the comment: static PyObject* foo(PyObject *, PyObject *arg) { void *buf; Py_ssize_t size; if (PyObject_AsReadBuffer(arg, &buf, &size)) size = -1; return PyInt_FromLong(size); } >>> import tst, re >>> re.search("a", "a") <_sre.SRE_Match object at 0xb76

[issue17544] regex code re-raises exceptions on success

2013-03-25 Thread Ezio Melotti
Ezio Melotti added the comment: Can you provide an actual example to reproduce the error? -- ___ Python tracker ___ ___ Python-bugs-li

[issue17544] regex code re-raises exceptions on success

2013-03-25 Thread Zdeněk Pavlas
New submission from Zdeněk Pavlas: There is a global indicator (per thread) of the last error that occurred. Most functions do not clear this on success, but will set it to indicate the cause of the error on failure. Most functions also return an error indicator, usually NULL if they are supp