Message349904
> I'm wary of "%S" used in error messages.
Maybe you're misunderstanding something. The goal is not really to change error messages, only the way how they are produced. For example, we currently have
>>> def f(): pass
>>> f(**1)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: f() argument after ** must be a mapping, not int
This is about how the "f()" in the error message is produced. Currently, this uses PyEval_GetFuncName() and PyEval_GetFuncDesc(). For the reasons explained in this issue, I want to replace that.
I see two ways of doing this:
1. (PR 14890) Write a new function _PyObject_FunctionStr(func) which returns func.__qualname__ + "()" with a suitable fallback if there is no __qualname__ attribute. At some point, we could also introduce a %F format character for this.
2. (PR 15295) Use str(func) in the error message and change various __str__ methods (really tp_str functions) to give a more readable output. |
|
| Date |
User |
Action |
Args |
| 2019-08-17 18:45:22 | jdemeyer | set | recipients:
+ jdemeyer, vstinner, petr.viktorin |
| 2019-08-17 18:45:22 | jdemeyer | set | messageid: <1566067522.1.0.75443885441.issue37645@roundup.psfhosted.org> |
| 2019-08-17 18:45:22 | jdemeyer | link | issue37645 messages |
| 2019-08-17 18:45:21 | jdemeyer | create | |
|