[patch #100895 ] PyErr_Format (was: Re: [Python-Dev] Patches)
Greg Stein
gstein@lyra.org
Thu, 20 Jul 2000 15:57:41 -0700
On Wed, Jul 19, 2000 at 07:45:23PM +0200, Fredrik Lundh wrote:
>...
> if I understood GvR correctly, the only remaining issue here
> is whether we need more formatting codes
I would say "no. let's wait and implement when a need is discovered."
> (PyErr_Format is undocumented, so I'm not sure we need to
> be backwards compatible with code outside the interpreter...)
>
> in an earlier post, I suggested adding a couple of PyErr_Format-
> specific formatting codes:
>
> possibly stupid idea: would it make sense to add custom
> formatting codes, like:
>
> %S => char*, string, clip if excessively long
> %T => PyObject*, show name of type, clip if excessively long
>
> where "clip" means:
>
> truncate at 80 characters, and add "..." to indicate
> that the string was truncated.
>
> this covers most of the places where %.\d+s are used (in
> the Python core, at least...)
>
> comments?
Punt. Keep it clean and simple. If a long value goes in, then so be it.
There isn't a need for us to clean up after somebody's horrendous
long-identifier code.
The only reason stuff like %.300s exists is to prevent buffer overflows. It
isn't because we are parents looking after little children :-)
Cheers,
-g
--
Greg Stein, http://www.lyra.org/