Torsten Becker <torsten.bec...@gmail.com> added the comment: While working on this, I discovered anther problem. find(), etc. all use the same parsing function (_ParseTupleFinds()). So when an error occurs, the exception message will always start with "find()" even though index() or rfind() might have caused the error:
>>> "asd".index("x", None, None, None) TypeError: find() takes at most 3 arguments (4 given) I attached a patch (issue-8282-error-message-tests.patch) which adds test cases for the wrong error messages. I was thinking about fixing this as well but wanted make sure my approach is correct first: - I would like to add another argument to _ParseTupleFinds(): const char * function_name - in _ParseTupleFinds(): allocate a buffer of 50 chars on the stack to hold "O|OO:" + function name - copy "O|OO:" into buffer - copy max(strlen(function_name), 44) chars from function_name into buffer - use buffer as format argument of PyArg_ParseTuple() - change all calls of _ParseTupleFinds to include the function name as first argument Would that approach work with Python's C style or are there any Python-specific helper functions I could use? ---------- Added file: http://bugs.python.org/file21623/issue-8282-error-message-tests.patch _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue11828> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com