Author jdemeyer
Recipients jdemeyer, petr.viktorin, vstinner
Date 2019-08-17.18:45:21
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1566067522.1.0.75443885441.issue37645@roundup.psfhosted.org>
In-reply-to
Content
> 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.
History
Date User Action Args
2019-08-17 18:45:22jdemeyersetrecipients: + jdemeyer, vstinner, petr.viktorin
2019-08-17 18:45:22jdemeyersetmessageid: <1566067522.1.0.75443885441.issue37645@roundup.psfhosted.org>
2019-08-17 18:45:22jdemeyerlinkissue37645 messages
2019-08-17 18:45:21jdemeyercreate