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 not specific to the re module. If you compile python in debug mode (--with-pydebug) an additional (and expensive) check is done and will print "XXX undetected error". One of the reasons is that accessing the global indicator is an expensive operation, compared to checking the returned value. But there are cases when this cannot be done. For example, PyIter_Next() returns NULL at the end of the loop, and one must call PyErr_Occurred() to check for errors. In the _sre.c case though, it looks more like laziness: intermediate returned values are not checked, and PyErr_Occurred() is called at the end. Bad. ---------- nosy: +amaury.forgeotdarc _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue17544> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com