473,406 Members | 2,769 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.

Python 2.2.1 DLL extension causes "abnormal program termination"

Hello,

Apologies if this has already been answered in here and I can't find
it, but can anyone help with this problem?
I hope the example code and comments state clearly enough what is
happening, but if not, please ask me for further information.
Thank in advance for any help.

:-)
Hugh

#!/usr/bin/python

# 1. DLL C++ source code
#
# #include <Python.h>
# static PyObject* dummy(PyObject* self, PyObject* args)
# {
# return Py_None;
# }
# static PyMethodDef py_dll_test_methods[] =
# {
# { "dummy", dummy, METH_VARARGS, "dummy" },
# { 0,0,0,0 }
# };
# extern "C" void _declspec(dllexport) initpy_dll_test(void)
# {
# (void) Py_InitModule("py_dll_test", py_dll_test_methods);
# }
#
# 2. Build release DLL using MSVC++ version 6.0, linking with
"python22.lib"
#
# 3. Copy DLL to "c:\python22\python\dll" directory
#
# 4. Python source

import py_dll_test
import time

while 1:

py_dll_test.dummy()

time.sleep(0.01)

# 5. Run python source
# c:\>c:\Python22\python console_test.py

# 6. Program runs for a while, but then crashes after 24 seconds with
# abnormal program termination
# Note. If I reduce the sleep time, the crash happens earlier.

Sep 1 '05 #1
2 2124
Hugh wrote:
Apologies if this has already been answered in here and I can't find
it, but can anyone help with this problem?
I hope the example code and comments state clearly enough what is
happening, but if not, please ask me for further information.
Thank in advance for any help. # static PyObject* dummy(PyObject* self, PyObject* args)
# {
# return Py_None;
# }


C functions must return an "owned" reference. or in other words, since
Py_None is an existing object, you need to increment the reference count
before returning it:

Py_INCREF(Py_None);
return Py_None;

or, better, but only works in recent Pythons:

Py_RETURN_NONE;

for more on reference counting and object ownership, see:

http://docs.python.org/ext/refcounts.html

</F>

Sep 1 '05 #2
Thank you very much.

Sep 1 '05 #3

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

Similar topics

11
by: tdi | last post by:
Ok, stupid question for the day. I'm reading the interview with Steve Moret and he says: "Once a lot of scripts started going in we knew there was no way we could back out of using Python." I'm...
2
by: Daniel Frickemeier | last post by:
Hi, I have a strange problem. I´m developing a small python-program wiht the mysql-python-module. The program should run on a server without any mysql-installation. Is there any posibility to...
5
by: Matt | last post by:
I will be grateful if someone explians this part colfree = FALSE; upfree = FALSE; downfree = FALSE; of the code below. I don't understand how this marks the downward and upward diagonals....
14
by: RDI | last post by:
I'm in the process of wiritng a custom AutoResponder that will run on a spare PC. If I don't write it as an actual "Service" but just a program that starts via the startup folder, will that use...
55
by: Dev | last post by:
Hello Folks, I had faced this objective in one of my aptitude exams, that "What could be the smallest "C" program? And, as we know, smallest program means, it should execute single statement,...
5
by: Jeroen van den Broek | last post by:
db2 8.1 fp13 on Linux for zSeries (64-bit) Every invocation of db2pd except for the "-version" and "-osinfo" options gives following message: ======================================= Database...
8
by: Edward A. Falk | last post by:
IOW, is there a "linker" for python? I've written a program comprised of about five .py files. I'd like to find a way to combine them into a single executable. Obviously, I could hand-edit them...
1
by: =?ISO-8859-1?Q?Andr=E9?= | last post by:
Hi everyone, I'd be interested in hearing suggestions as to the "best" way to drive a Python program step by step from another application. Details: --------- I have implemented a "Robot"...
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
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
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.