473,406 Members | 2,336 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

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.

Jan 31 '07 #1
2 1397
En Wed, 31 Jan 2007 19:04:13 -0300, Rubic <ru*****@gmail.comescribió:
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."
Maybe process_record expects some minimum buffer size? The cpp example
uses char record[100], but you are allocating only a few bytes with the
string "My Record"

--
Gabriel Genellina

Feb 1 '07 #2
On Jan 31, 8:49 pm, "Gabriel Genellina" <gagsl...@yahoo.com.arwrote:
Maybe process_record expects some minimum buffer size? The cpp example
uses char record[100], but you are allocating only a few bytes with the
string "My Record"
No, I've already tried padding record out to the full size. But thank
you for the suggestion.
--

Jeff Bauer
Rubicon, Inc.

Feb 1 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: zapazap | last post by:
Dear Snake Charming Gurus, (Was: http://mail.python.org/pipermail/python-list/2004-January/204454.html) First, a thank you to Tim Golden, Thomas Heller, and Mark Hammond for your earlier help...
2
by: Somesh Bartakkay | last post by:
I downloaded and tried a small dialog-dll's application with venster+ctypes+python 2.3 its working very well, but is it reliable to use in big projects ? or part of big projects ? wot are...
9
by: jtravs | last post by:
Hi all, I suspect that I'm doing something stupid, I would like some other opinions though. I'm getting started with ctypes and am trying to use distutils to help build my module. At the moment...
10
by: happyse27 | last post by:
Hi All, I got this apache errors(see section A1 and A2 below) when I used a html(see section b below) to activate acctman.pl(see section c below). Section D below is part of the configuration...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.