CR+LF problem

Manuel Ruiz mruiz at safa.es
Fri Jun 21 07:22:00 EDT 2002


Hi,

char * txt = "print 123\r\n" is only a sample, I am storing scripts in
a database, I put the script into the database with \n but when I get
it, It has \r\n as end of line, I have assumed this is a database
problem.

The rare thing is that PyRun_Simple() function can't execute this kind
of python code using \r\n as end of line, however I saved that code to
file and ran "python2 myfile.py" (with \r\n as end of line too) and it
ran fine, very fine.

Where is the diferrence between the api of python and the interprete
itself. Because first one can't execute this code and the second one
can do it ?

Regards
Manuel Ruiz

On Thu, 20 Jun 2002 17:38:43 +0300, Christos "TZOTZIOY" Georgiou
<DLNXPEGFQVEB at spammotel.com> wrote:

>On Thu, 20 Jun 2002 11:33:55 GMT, rumours say that mruiz at safa.es (Manuel
>Ruiz) might have written:
>
>>char * txt = "print 123\r\n";
>>result = PyRun_Simple( txt, Py_file_input, PyDict_New(), NULL );
>
>did you try
>	char *txt= "print 123\n";
>by any chance?
>I am not very sure if I do help, but in C, newlines are just "\n".
>"\r\n" is by convention the text line terminator of VMS IIRC, MS-DOS &
>window derivatives etc.
>
>>this code fails to exec txt, I got a SyntaxError exception,
>>however I if save to file the statement "print 123\r\n" and try to run
>>it ussing python interprete (version 2.2.1) It run fine.
>>
>>Can anyone tell me anything about this rare behaviour
>
>-- 
>TZOTZIOY, I speak England very best,
>Real email address: 'dHpvdEBzaWwtdGVjLmdy\n'.decode('base64')




More information about the Python-list mailing list