Re: plpython tracebacks

From: Neil Conway <neilc(at)samurai(dot)com>
To: "P(dot) Scott DeVos" <scott(at)countrysidetechnology(dot)com>
Cc: pgsql-patches(at)postgresql(dot)org
Subject: Re: plpython tracebacks
Date: 2006-02-20 01:09:09
Message-ID: 1140397749.2615.28.camel@localhost.localdomain
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-patches

On Mon, 2006-02-06 at 16:05 -0600, P. Scott DeVos wrote:
> I have been working with plpython for several months and have
> been hampered by the lack of a traceback being logged when a
> plpython function raises an error. I have written a patch causes
> the PLy_traceback function to fully log the traceback. The
> output looks just like the traceback output provided by the
> python interpreter.

Can any PL/Python folks comment on whether they want this patch?

> Feedback appreciated.

Context diffs are preferred. Also, diffs should be against the root of
the source tree, and attached as MIME attachements if possible (it seems
the mailing list software munges the patch somewhat otherwise).

> + hdr = PyString_FromString("Traceback (most recent call last):");
> + tmpl = PyString_FromString(" File \"%s\", line %s, in %s");
> + ftr = PyString_FromString("");
> +
> + tb_list = PyList_New(0); /* create the list of strings */
> + PyList_Append(tb_list, hdr); /* Append the header to the list */

Minor nit: lowercase "Append". Similarly, consistent capitalization for
all the preceding comments in the block (adjacent to the variable
declarations) would be nice.

> estr = eob ? PyString_AsString(eob) : "Unknown Exception";
> - xstr = PLy_printf("%s: %s", estr, vstr);
> + xstr = PLy_printf("%s%s: %s", tbstr, estr, vstr);

tbstr points into storage owned by tb_log, but the reference to tb_log
has already been released.

-Neil

In response to

Responses

Browse pgsql-patches by date

  From Date Subject
Next Message James William Pye 2006-02-20 01:12:41 Re: ScanDirections
Previous Message Neil Conway 2006-02-20 01:02:09 Re: ScanDirections