Re: Multiline plpython procedure - Mailing list pgsql-general

From Michael Fuhr
Subject Re: Multiline plpython procedure
Date
Msg-id 20050118073908.GA17129@winnie.fuhr.org
Whole thread Raw
In response to Re: Multiline plpython procedure  (Tom Lane <tgl@sss.pgh.pa.us>)
List 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/

pgsql-general by date:

Previous
From: Michael Fuhr
Date:
Subject: Re: Users and unique identifyers
Next
From: Michael Fuhr
Date:
Subject: Re: Multiline plpython procedure