[issue20524] format error messages should provide context information

2021-09-24 Thread Eric V. Smith
Eric V. Smith added the comment: Thanks for the improvement, @sobolevn! -- resolution: -> fixed stage: patch review -> resolved status: open -> closed ___ Python tracker ___

[issue20524] format error messages should provide context information

2021-09-24 Thread Eric V. Smith
Eric V. Smith added the comment: New changeset 8d8729146f21f61af66e70d3ae9501ea6bdccd09 by Nikita Sobolev in branch 'main': bpo-20524: adds better error message for `.format()` (GH-28310) https://github.com/python/cpython/commit/8d8729146f21f61af66e70d3ae9501ea6bdccd09 --

[issue20524] format error messages should provide context information

2021-09-13 Thread Nikita Sobolev
Nikita Sobolev added the comment: > 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

[issue20524] format error messages should provide context information

2021-09-13 Thread Nikita Sobolev
Change by Nikita Sobolev : -- keywords: +patch nosy: +sobolevn nosy_count: 4.0 -> 5.0 pull_requests: +26723 stage: test needed -> patch review pull_request: https://github.com/python/cpython/pull/28310 ___ Python tracker

[issue20524] format error messages should provide context information

2021-09-10 Thread Irit Katriel
Irit Katriel added the comment: Reproduced on 3.11: >>> dd = {'length': 12, 'id': 4, 'title': "t", 'run_time': datetime.time()} >>> '{run_time:%H:%M:%S}, >>> ,COM,DA{id},"{title:.43}",{id},{length:%M:%S}'.format(**dd) Traceback (most recent call last): File "", line 1, in ValueError:

[issue20524] format error messages should provide context information

2014-02-05 Thread R. David Murray
New submission from R. David Murray: Consider the following: '{run_time:%H:%M:%S}, ,COM,DA{id},{title:.43},{id},{length:%M:%S}'.format(**mydict) The error message I got was: Invalid format specifier The problem turned out to be that the value of the 'length' key was an integer

[issue20524] format error messages should provide context information

2014-02-05 Thread Ezio Melotti
Changes by Ezio Melotti ezio.melo...@gmail.com: -- nosy: +ezio.melotti stage: - test needed type: - behavior ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue20524 ___

[issue20524] format error messages should provide context information

2014-02-05 Thread Eric V. Smith
Eric V. Smith added the comment: That would be a great improvement. It's in Python/formatter_unicode.c, line 245, in parse_internal_render_format_spec(). That code knows about the format spec, but not the type being formatted. That would be easy enough to pass in. This fix would only work

[issue20524] format error messages should provide context information

2014-02-05 Thread Eric V. Smith
Eric V. Smith added the comment: int, float, str, and complex are the types formatted by that code. Notice that Decimal already has a better message: format(Decimal(42), 'tx') Traceback (most recent call last): ... ValueError: Invalid format specifier: tx format(42, 'tx') Traceback (most