Message133551
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? |
|
Date |
User |
Action |
Args |
2011-04-11 22:48:04 | torsten.becker | set | recipients:
+ torsten.becker, rhettinger, jcea, r.david.murray, santoso.wijaya, hkBst |
2011-04-11 22:48:04 | torsten.becker | set | messageid: <1302562084.68.0.815813277112.issue11828@psf.upfronthosting.co.za> |
2011-04-11 22:48:04 | torsten.becker | link | issue11828 messages |
2011-04-11 22:48:04 | torsten.becker | create | |
|