ctypes error on exit of win32 application



I'm attempting to use ctypes on a DLL with the following
signature:

__declspec(dllimport) void process_record(char *, char *);

An example .cpp file has code like this:

int main(int argc, char **argv)
{
char record[100];
char code[6];
...
process_record(code, record);

When I invoke it under Python everything fine
while the interpreter is running:

>>> from ctypes import *
>>> record = create_string_buffer("My Record")
>>> code = create_string_buffer('\000' * 6)
>>> cdll.grouper.process_recode(code, record)
>>> print code.value
'9999'

But when the interpreter exits, either interactively
or from a script, the following Program Error popup
gets displayed:

"python.exe has generated errors and will be closed
by Windows. You will need to restart the program."

What can I do to prevent this error?
(Environment: Win2000, Python 2.5)
--
Jeff Bauer
Rubicon, Inc.

.



Relevant Pages

  • Re: xor: how come so slow?
    ... never do things like this with python. ... I'm trying to encode a byte data. ... I cycle on the two strings to be xor-red ... in char (chr) ...
    (comp.lang.python)
  • Re: Newbie NameError problem
    ... for char in line: ... Remember that in Python, ... of the Loc class object, and so are shared by all instances. ... This defines two local variables line and char, ...
    (comp.lang.python)
  • Re: QT, ctypes dll and SEG Faults
    ... The crash can occur because you pass a char* to your library. ... char* is not managed by your library but by Python. ... filename with a hard coded value it doesn't crash. ...
    (comp.lang.python)
  • Re: h2py.py bug?
    ... I mean if you define a char literal then in python you would have used a string value: ... Yes, true, but if you intend to use it as an integer, wouldn't you use a numeric value instead of a character literal? ...
    (comp.lang.python)
  • Re: h2py.py bug?
    ... I mean if you define a char literal then in python you would have used a string value: ... Yes, true, but if you intend to use it as an integer, wouldn't you use a numeric value instead of a character literal? ...
    (comp.lang.python)