Search Postgresql Archives

Re: Multiline plpython procedure

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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/

---------------------------(end of broadcast)---------------------------
TIP 4: Don't 'kill -9' the postmaster

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux