473,395 Members | 1,393 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,395 software developers and data experts.

return (PyObject*)myPyType; ...segmentation fault!

I called a own python type 'PyType' with a c function and returned it
into my python programm - there it fault.
It is said that the object has a NULL-Pointer when I try to debug it?

Here are the importent snips from my code:
// == test.py ================================================== =======
..
:
myNewPyType = PyMyExtention.GetValue ("xxx")
# printings for testing
print "...back to python... test.py"
print "pp\t ...PyMyType.PyMyObject:", type(tySdlXml)
//================================================== =================/
// == PyMyExtention.c =================================================
..
:
static PyObject* wrap_GetValue (PyObject* self, PyObject* args)
{
char* pchXXX;
if (!PyArg_ParseTuple(args, "s", &pchXXX))
{
return 0;
}

long llong = CFunktion::CallMe(pchXXX);

// returning Python-Objekt
PyObject *pyType = PyMyObject_NewC (llong);
cout << "cc ..." << ((PyMyType*)pyType)->lAttribute << endl;
cout << "\t ...proof object-valid pointer?" << (void*)pyType << endl;
return (PyObject*)pyType;
}
..
:
//================================================== =================/
// == PyMyExtention.c =================================================
..
:
typedef struct {
PyObject_HEAD
long lAttribute;
} PyMyObject;

static PyObject* PyMyObject_NewC (long lAttribute)
{
PySDLXMLNode *self;
PySDLXMLNode *type;

self = new PySDLXMLNode;
self->lAttribute = lAttribute;

return (PyObject*)self;
}

static PyMethodDef PyMyObject_methods[] = {
{"PyMyObject_NewC", (PyCFunction)PyMyObject_NewC, METH_NOARGS,
"Create PyMyObject_NewC from C-Code"},
{NULL} /* Sentinel */
};

:

static PyTypeObject PySDLXMLNodeType = {
PyObject_HEAD_INIT(NULL)
:
};
//================================================== =================/
// ::: output :::::::::::::::::::::::::::::::::::::::::::::::::: ::

cc ...135603272
t ...proof object-valid pointer?: 0x8165940
....back to python... test.py
Segmentation fault

//================================================== =================/
....you see: It returns to python but over there the object is something
bad. So what is wrong?
Sep 30 '05 #1
0 1242

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

Similar topics

2
by: jeko | last post by:
Hi, I'm using a class method which read and write on private variable of own class. During the first alghoritm cycle, method read and write correclty on num_elts variable, but during the second...
2
by: Rolf Wester | last post by:
Hi, I' trying to make an extension module that passes Numeric arrays. The wrapper function is (swig generated and modified by myself): static PyObject *_wrap_my_func(PyObject *self, PyObject...
5
by: Fra-it | last post by:
Hi everybody, I'm trying to make the following code running properly, but I can't get rid of the "SEGMENTATION FAULT" error message when executing. Reading some messages posted earlier, I...
1
by: Kirill Simonov | last post by:
Hi, Could someone tell me why my extension module works under Python 2.4, but fails with Segmentation Fault under Python 2.3? Here is the stripped version: ...
27
by: Paminu | last post by:
I have a wierd problem. In my main function I print "test" as the first thing. But if I run the call to node_alloc AFTER the printf call I get a segmentation fault and test is not printed! ...
4
by: Luke Miller | last post by:
Hello, I am working on my first python module based on a c program. The module builds and installs OK using dist-utils, and imports fine into python. However, when I try and use the one wrapper...
6
by: DanielJohnson | last post by:
int main() { printf("\n Hello World"); main; return 0; } This program terminate just after one loop while the second program goes on infinitely untill segmentation fault (core dumped) on...
8
by: Andrea | last post by:
I wrote this code: void * xmalloc (size_t size){ register void *value = OPENSSL_malloc(size); if (value == 0) printf("virtual memory exhausted"); return value; } int _chooseTSK(char*...
0
by: Gal Aviel | last post by:
Hello All, I Need some tips/help/ideas debugging segmentation fault ... I'm trying to debug Python running embedded inside a Verilog Simulator (as a SystemVerilog DPI application). (on SUSE...
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: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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...

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.