[Python-Dev] Unix line endings required for PyRun* breaking
embedded Python
Stuart Bishop
stuart at stuartbishop.net
Thu Jan 20 00:06:33 CET 2005
There is a discussion going on at the moment in postgresql-general about
plpythonu (which allows you write stored procedures in Python) and line
endings. The discussion starts here:
http://archives.postgresql.org/pgsql-general/2005-01/msg00792.php
The problem appears to be that things are working as documented in PEP-278:
There is no support for universal newlines in strings passed to
eval() or exec. It is envisioned that such strings always have the
standard \n line feed, if the strings come from a file that file can
be read with universal newlines.
So what happens is that if a Windows or Mac user tries to create a
Python stored procedure, it will go through to the server with Windows
line endings and the embedded Python interpreter will raise a syntax
error for everything except single line functions.
I don't think it is possible for plpythonu to fix this by simply
translating the line endings, as this would require significant
knowledge of Python syntax to do correctly (triple quoted strings and
character escaping I think).
The timing of this thread is very unfortunate, as PostgreSQL 8.0 is
being released this weekend and the (hopefully) last release of the 2.3
series next week :-(
--
Stuart Bishop <stuart at stuartbishop.net>
http://www.stuartbishop.net/
More information about the Python-Dev
mailing list