[patch #100895 ] PyErr_Format (was: Re: [Python-Dev] Patches)

Fredrik Lundh Fredrik Lundh" <effbot@telia.com
Wed, 19 Jul 2000 19:45:23 +0200


greg wrote:

> > Yes, but it would by possible to use snprintf in PyErr_Format.
>=20
> still not quite the same. /F's PyErr_Format returns an arbitrary =
length
> string. snprintf() would be cut at some pre-specified limit.

if I understood GvR correctly, the only remaining issue here
is whether we need more formatting codes

(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 =3D> char*, string, clip if excessively long
        %T =3D> 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?

</F>