Win2k and Python access violation - please help me out here!
Jason Maskell
backov at nospam.csolve.net
Fri Feb 25 11:40:18 EST 2000
Well, I am trying to get my Python embedding project to move forward, and I
am still having problems with it. I recently upgraded to Win2k, and my
project now does something strange.
I changed four lines of PyRun_SimpleString() to One line of
PyRun_SimpleFile() with the same code - here it is:
def main():
# Initialize the forms
ddinterface.setpath(('c:/',))
ddinterface.loadform(('form','tester6.frm'))
ddinterface.showform(('form',))
ddinterface.setelement(('form','textfield0',
{'text':'Blahz','frame':0}))
main()
First off, I'd like to say that the docs for the PyRun_ commands are
woefully inadequate. PyRun_SimpleFile() requires a FILE * and a filename.
Does that mean it wants you to open the file and pass it the pointer, and
the filename is just for reference? Or will it open it itself and put the
pointer in FILE*? Do I have to close it afterwards? This really needs to be
clarified.
Anyway, here's the call stack before I get my access violation:
tok_nextc(tok_state * 0x008e7b50) line 270 + 31 bytes
PyTokenizer_Get(tok_state * 0x008e7b50, char * * 0x0012fb50, char * *
0x0012fb4c) line 469 + 9 bytes
parsetok(tok_state * 0x008e7b50, grammar * 0x1e200028 __PyParser_Grammar,
int 257, perrdetail * 0x0012fc38) line 149 + 17 bytes
PyParser_ParseFile(_iobuf * 0x00482038, char * 0x00478370 `string', grammar
* 0x1e200028 __PyParser_Grammar, int 257, char * 0x00000000, char *
0x00000000, perrdetail * 0x0012fc38) line 120 + 21 bytes
PyParser_SimpleParseFile(_iobuf * 0x00482038, char * 0x00478370 `string',
int 257) line 951 + 30 bytes
PyRun_File(_iobuf * 0x00482038, char * 0x00478370 `string', int 257,
_object * 0x008c28f0, _object * 0x008c28f0) line 861 + 29 bytes
PyRun_SimpleFile(_iobuf * 0x00482038, char * 0x00478370 `string') line 570
+ 26 bytes
WinMain(HINSTANCE__ * 0x00400000, HINSTANCE__ * 0x00000000, char *
0x00132f75, int 1) line 174 + 20 bytes
WinMainCRTStartup() line 198 + 54 bytes
KERNEL32! 77e
The actual message is "Unhandled exception in NTDLL.DLL: Access Violation"
The code that calls PyRun_SimpleString() looks like this:
fileptr=fopen("c://mainscript.py","r+");
PyRun_SimpleFile(fileptr,"c://mainscript.py");
I have tried it without the fopen as well, same error.
Any help would be appreciated.
Cheers,
Jason
More information about the Python-list
mailing list