From: | Stuart Bishop <stuart(at)stuartbishop(dot)net> |
---|---|
To: | Michael Fuhr <mike(at)fuhr(dot)org> |
Cc: | Adrian Klaver <aklaver(at)comcast(dot)net>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Hong Yuan <hongyuan(at)homemaster(dot)cn>, pgsql-general(at)postgresql(dot)org |
Subject: | Re: Multiline plpython procedure |
Date: | 2005-01-19 07:28:25 |
Message-ID: | 41EE0C19.4010802@stuartbishop.net |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Michael Fuhr wrote:
> On Tue, Jan 18, 2005 at 07:34:59PM -0800, Adrian Klaver wrote:
>
>
>>Actually universal newline support seems to be covered by the following PEP
>>and is present in the version of Python(2.3) I am running.
>>http://www.python.org/peps/pep-0278.txt
>
>
> I see the following in the PEP:
>
> There is no support for universal newlines in strings passed to
> eval() or exec. It is envisioned that such strings always have the
> standard \n line feed, if the strings come from a file that file can
> be read with universal newlines.
>
> Does the above mean that the PyRun_*() family doesn't have universal
> newline support? Or at least that some members of the family don't?
> That would explain why the simple C program I tested failed.
>
> http://archives.postgresql.org/pgsql-general/2005-01/msg00876.php
>
>
>>I would tend to agree with Hong Yuan that the problem exists in plpythonu's
>>handling of newlines.
>
>
> If Python's behavior is intentional then the newline burden would
> seem to be on the user or on plpythonu. I think Tom's point is
> that that's just silly....
Changing this behavior in Python would break backwards compatibility. In
particular, the exec() function accepts strings that have already been
unescaped:
>>> exec('print """\n\r\n\r\n"""')
In the above example, the exec function is being passed a string
containing carridge returns and line feeds - not '\n' and '\r' character
sequences.
It is too late for the Python 2.3 series anyway - 2.3.5 is being
released Jan 26th and there won't be a 2.3.6. If it was championed and
it decided that the above example is a bug and not a feature and a patch
produced, it could get into 2.4.1 due April and 2.5+
I suspect this means fixing this problem in plpythonu for 8.1.
--
Stuart Bishop <stuart(at)stuartbishop(dot)net>
http://www.stuartbishop.net/
From | Date | Subject | |
---|---|---|---|
Next Message | Thomas F.O'Connell | 2005-01-19 07:46:33 | Re: PL/PgSQL Index Usage with Trigger Variables |
Previous Message | Ken Tozier | 2005-01-19 06:58:03 | Re: Getting table metadata |