[python-win32] Py_RunSimpleString() - read the buffer from file.
Moore, Paul
Paul.Moore at atosorigin.com
Thu May 6 06:23:16 EDT 2004
From: Tikva Bonneh
> I am running my python script from a VC++ application.
> I tried to read the script from my .py file to a into
> buffer and execute the buffer with Py_RunSimpleString.
> It didn't work. This is the way I did it:
[...]
// allocate memory to contain the whole file.
buffer = (char*) malloc (lSize);
if (buffer == NULL) exit (2);
// copy the file into the buffer.
fread (buffer,1,lSize,pFile);
[...]
Looking at this, it doesn't look like you null-terminated
the string. Could that be all your problem is? (Don't forget
to add 1 to the length of the buffer you malloc as well!)
Paul
__________________________________________________________________________
This e-mail and the documents attached are confidential and intended
solely for the addressee; it may also be privileged. If you receive this
e-mail in error, please notify the sender immediately and destroy it.
As its integrity cannot be secured on the Internet, the Atos Origin group
liability cannot be triggered for the message content. Although the
sender endeavours to maintain a computer virus-free network, the sender
does not warrant that this transmission is virus-free and will not be
liable for any damages resulting from any virus transmitted.
__________________________________________________________________________
More information about the Python-win32
mailing list