[Python-checkins] r62303 - in python/trunk: Doc/library/warnings.rst Include/Python.h Include/pyerrors.h Include/sysmodule.h Include/traceback.h Include/warnings.h Lib/test/test_support.py Lib/test/test_warnings.py Lib/warnings.py Makefile.pre.in
Alexandre Vassalotti
alexandre at peadrop.com
Sun Apr 27 00:34:16 CEST 2008
On Sat, Apr 12, 2008 at 7:44 PM, brett.cannon
<python-checkins at python.org> wrote:
> Author: brett.cannon
> Date: Sun Apr 13 01:44:07 2008
> New Revision: 62303
>
> Log:
> Re-implement the 'warnings' module in C. This allows for usage of the
> 'warnings' code in places where it was previously not possible (e.g., the
> parser). It could also potentially lead to a speed-up in interpreter start-up
> if the C version of the code (_warnings) is imported over the use of the
> Python version in key places.
>
> Closes issue #1631171.
[Snip]
> Modified: python/trunk/Python/traceback.c
> ==============================================================================
> --- python/trunk/Python/traceback.c (original)
> +++ python/trunk/Python/traceback.c Sun Apr 13 01:44:07 2008
[Snip]
>
> static int
> -tb_printinternal(PyTracebackObject *tb, PyObject *f, int limit)
> +tb_displayline(PyObject *f, const char *filename, int lineno, const char *name)
> +{
> + int err = 0;
> + char linebuf[2000];
> +
> + if (filename == NULL || name == NULL)
> + return -1;
> + /* This is needed by Emacs' compile command */
> +#define FMT " File \"%.500s\", line %d, in %.500s\n"
> + PyOS_snprintf(linebuf, sizeof(linebuf), FMT, filename, lineno, name);
> + err = PyFile_WriteString(linebuf, f);
> + if (err != 0)
> + return err;
> +
> + err = PyFile_WriteString(" ", f);
> + return Py_DisplaySourceLine(f, filename, lineno);
> +}
I think the output extra spaces here are not necessary. This seems to
add an indent before the exception name:
>>> raise KeyError
Traceback (most recent call last):
...
KeyError
-- Alexandre
More information about the Python-checkins
mailing list