Re: Multiline plpython procedure

From: Michael Fuhr <mike(at)fuhr(dot)org>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Hong Yuan <hongyuan(at)homemaster(dot)cn>, aklaver(at)comcast(dot)net, pgsql-general(at)postgresql(dot)org
Subject: Re: Multiline plpython procedure
Date: 2005-01-18 07:39:08
Message-ID: 20050118073908.GA17129@winnie.fuhr.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Tue, Jan 18, 2005 at 01:24:31AM -0500, Tom Lane wrote:
>
> Now that you say that, I seem to recall that this has been reported
> before. It seems odd that in today's climate the Python interpreter
> would not cope well with Windows-style newlines. Maybe there is some
> configuration issue with Python itself?

Hmmmm....

#include <Python.h>

int
main(void)
{
Py_Initialize();
PyRun_SimpleString("print 'What hath'\n"
"print 'Guido wrought?'\n");
Py_Finalize();
return 0;
}

As written this program works, at least with Python 2.4 on FreeBSD
4.11 and Solaris 9:

% ./foo
What hath
Guido wrought?

But if you change LF to CRLF like this:

PyRun_SimpleString("print 'What hath'\r\n"
"print 'Guido wrought?'\r\n");

then you get this:

% ./foo
File "<string>", line 1
print 'What hath'
^
SyntaxError: invalid syntax

I don't know if that behavior is configurable or not.

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

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Michael Fuhr 2005-01-18 07:49:11 Re: Multiline plpython procedure
Previous Message Michael Fuhr 2005-01-18 07:21:17 Re: Users and unique identifyers