Re: plpython function problem workaround

From: Michael Fuhr <mike(at)fuhr(dot)org>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Martijn van Oosterhout <kleptog(at)svana(dot)org>, Marco Colombo <pgsql(at)esiway(dot)net>, pgsql-general(at)postgresql(dot)org
Subject: Re: plpython function problem workaround
Date: 2005-03-18 02:34:11
Message-ID: 20050318023410.GB13277@winnie.fuhr.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Thu, Mar 17, 2005 at 10:49:24AM -0500, Tom Lane wrote:

> Seems like we have to upgrade that thing to have a complete
> understanding of Python lexical rules --- at least enough to know where
> the line boundaries are. Which is pretty much exactly the same as
> knowing which CRs to strip out. So I guess we have a candidate place
> for a solution.
>
> Anyone want to code it up? I don't know enough Python to do it ...

[Sound of crickets]

More pabulum for pondering:

% cat -v foo.py
print '''line 1^M
line^M2^M
line 3^M
'''^M

% python foo.py | cat -v
line 1
line
2
line 3

% cat -v bar.py
print 'line 1^M'

% python bar.py
File "bar.py", line 1
print 'line 1
^
SyntaxError: EOL while scanning single-quoted string

Line-ending CRs stripped, even inside quotes; mid-line CRs converted
to LF. Tests done with Python 2.4 on FreeBSD 4.11-STABLE; I wonder
what Python on Windows would do. If it behaves the same way, then
a munging algorithm might be CRLF => LF, otherwise CR => LF. Or
we could take Marco's suggestion and do nothing, putting the burden
on the client to send the right thing.

That doesn't address the indentation munging, though. That appears
to be a matter of knowing whether you're inside a quote or not when
a LF appears.

--
Michael Fuhr
http://www.fuhr.org/~mfuhr/

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Woodchuck Bill 2005-03-18 02:46:02 Re: 3rd RFD: comp.databases.postgresql (was: comp.databases.postgresql.*)
Previous Message Grant McLean 2005-03-18 01:32:06 Re: Installing PostgreSQL in Debian