Re: Multiline plpython procedure

Поиск
Список
Период
Сортировка
От Michael Fuhr
Тема Re: Multiline plpython procedure
Дата
Msg-id 20050118073908.GA17129@winnie.fuhr.org
обсуждение исходный текст
Ответ на Re: Multiline plpython procedure  (Tom Lane <tgl@sss.pgh.pa.us>)
Список 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 по дате отправления:

Предыдущее
От: Michael Fuhr
Дата:
Сообщение: Re: Users and unique identifyers
Следующее
От: Michael Fuhr
Дата:
Сообщение: Re: Multiline plpython procedure