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.

classification
Title: Add new format of fixed length string for PyErr_Format
Type: enhancement Stage:
Components: Interpreter Core Versions: Python 3.10
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: barry, pitrou, serhiy.storchaka, vajrasky
Priority: normal Keywords: patch

Created on 2013-12-15 05:23 by vajrasky, last changed 2022-04-11 14:57 by admin.

Files
File name Uploaded Description Edit
add_T_format_for_PyErr_Format.patch vajrasky, 2013-12-15 05:27 review
Messages (2)
msg206216 - (view) Author: Vajrasky Kok (vajrasky) * Date: 2013-12-15 05:23
This ticket sprung from this discussion:
https://mail.python.org/pipermail/python-dev/2013-December/130756.html

Basically I am always confused when writing error message in C-API.

Is it:

PyErr_Format(PyExc_TypeError,"can't intern %.400s", s->ob_type->tp_name);

or

PyErr_Format(PyExc_TypeError,"can't intern %.80s", s->ob_type->tp_name);

or

PyErr_Format(PyExc_TypeError,"can't intern %s", s->ob_type->tp_name);

In conclusion, is it %s or %.80s or %.400s?

This patch will add one true way of writing fixed length string of the wrong type. This is just preliminary patch. I'll write the documentation later (and maybe test?).
msg206232 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2013-12-15 13:36
Originally Antoine had proposed [1] `"%T", obj` as replacement for `"%.400s", Py_TYPE(obj)->tp_name`.

[1] http://permalink.gmane.org/gmane.comp.python.devel/143925
History
Date User Action Args
2022-04-11 14:57:55adminsetgithub: 64183
2021-02-15 20:05:44iritkatrielsetversions: + Python 3.10, - Python 3.5
2013-12-15 13:36:22serhiy.storchakasetnosy: + serhiy.storchaka, pitrou
messages: + msg206232
2013-12-15 13:29:32barrysetnosy: + barry
2013-12-15 09:08:28vajraskysettitle: Add new format of fix length string for PyErr_Format -> Add new format of fixed length string for PyErr_Format
2013-12-15 05:27:35vajraskysetfiles: + add_T_format_for_PyErr_Format.patch
2013-12-15 05:27:28vajraskysetfiles: - add_T_format_for_PyErr_Format.patch
2013-12-15 05:23:22vajraskycreate