This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author sobolevn
Recipients eric.smith, ezio.melotti, iritkatriel, r.david.murray, sobolevn
Date 2021-09-13.12:04:47
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1631534687.43.0.000320141127271.issue20524@roundup.psfhosted.org>
In-reply-to
Content
> I think that would require some major surgery to the code, but would be worth it.

I've decided to take an easy path: https://github.com/python/cpython/pull/28310

```
PyErr_Format(PyExc_ValueError,
                     "Invalid format specifier: '%s' for object of type '%s'",
                     PyUnicode_AsUTF8AndSize(format_spec, NULL),
                     Py_TYPE(obj)->tp_name);
```

This worked for me as the starting point. It covered: int, float, complex, and str types.

> Note that in your original example, you want the error to contain "{length:%HH:%MM}". By the time the error is detected, the only thing the code knows is the format specifier "%HH:%MM". It doesn't know the "length" part. 

I guess it has changed since the 2014.

I would love to hear any feedback on my proposal and improve it to the level when it can be merged :)
History
Date User Action Args
2021-09-13 12:04:47sobolevnsetrecipients: + sobolevn, eric.smith, ezio.melotti, r.david.murray, iritkatriel
2021-09-13 12:04:47sobolevnsetmessageid: <1631534687.43.0.000320141127271.issue20524@roundup.psfhosted.org>
2021-09-13 12:04:47sobolevnlinkissue20524 messages
2021-09-13 12:04:47sobolevncreate