473,569 Members | 2,772 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Python source sensitive to PyObject_HEAD layout?

For academic reasons, I'm hacking on the Python source trying to add
some new capabilities. At present, I'm making minor changes mostly to
familiarise myself with the code and gain awareness of what issues I
may encounter, with the result that I encountered a fairly strange one
(to me, anyway).

As I wanted to add new fields to all Python objects, it seemed to make
the most sense to add them to PyObject_HEAD. When I added an int field
to the end of PyObject_HEAD, however, the make process failed (see
below). This was on a Pentium-M running GCC 3.4.6 under Gentoo Linux. I
switched to my other computer, and Athlon 64 running GCC 4.1.0 under
Gentoo Linux, and it compiled; I dismissed the earlier failure as an
irritating but fixed GCC bug, and went on---until I added another int
field and ran into a failure at exactly the same place.

The error looks fairly uninformative, as such:

/bin/sh: line 1: 6926 Segmentation fault CC='gcc -pthread'
LDSHARED='gcc -pthread -shared' OPT='-DNDEBUG -g -O3 -Wall
-Wstrict-prototypes' ./python -E ./setup.py build
make: *** [sharedmods] Error 139

I can supply more information if desired (I ran a GDB backtrace), but
it really didn't tell me very much. None of the functions on the stack
were ones I had modified, so the only factor is the presence of that
second additional field in PyObject_HEAD (I can make it build by simply
commenting out that field and its initialiser in PyObject_HEAD_I NIT).

My question is therefore a vague, nebulous, open, and at least mildly
desperate one: What is the problem? The only notion that occurs to me
is that some part of the Python source is somehow upset by alignment
issues (or padding of some sort); if so then I have no clue where that
might be. If not, then I have no idea what's causing the errors at all.

Any help, thoughts, or advice would be vastly appreciated.

--
Petter Haggholm

May 21 '06 #1
2 2088
Petter Haggholm wrote:
Any help, thoughts, or advice would be vastly appreciated.


After changing PyObject_HEAD, I would run "make distclean".
Most likely, some object files were not recompiled and still
using the old layout.

Regards,
Martin
May 22 '06 #2
Boy, do I feel foolish! I hang my head in shame and thank you for your
assistance---that solved it.

May 22 '06 #3

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

Similar topics

0
1358
by: Nikola Milutinovic | last post by:
Hi all. I'm not subscribed to the list, so all replies to me mail directly. I ran into a small problem, for which we have found a workaround. I was compiling PostgreSQL v7.4.1 and it's PL/Python module. Compilation failed on lines which had this: typedef struct PLyPlanObject { PyObject_HEAD; ... } PLyPlanObject;
0
1170
by: Nikola Milutinovic | last post by:
Hi all. OS: Tru64 UNIX 4.0d PG: PostgreSQL v7.4.1 PY: Python v2.3.3 I just ran into a minor bug while compiling PL/Python module. It bombed outon lines 153 and 160 of ./src/pl/plpython/plpython.c complaining on incomplete type "PyObject_HEAD". The source of the problem were these two typedefs:
2
4433
by: ajikoe | last post by:
Hi, I tried to follow the example in swig homepage. I found error which I don't understand. I use bcc32, I already include directory where my python.h exist in bcc32.cfg. /* File : example.c */ #include <time.h>
29
16475
by: 63q2o4i02 | last post by:
Hi, I'm interested in using python to start writing a CAD program for electrical design. I just got done reading Steven Rubin's book, I've used "real" EDA tools, and I have an MSEE, so I know what I *want* at the end of this; I just have never taken on a programming task of this magnitude. I've seen that some are using python as a utility...
32
2810
by: siggi | last post by:
@Ben Sizer Hi Ben, in January I received your message re Pygame and Python 2.5: As a Python (and programming ) newbie allow me a - certainly naive - question:
1
2321
by: AngelBlaZe | last post by:
Can you access the c object of a python object directly? Can this be done in ctypes or directly throught python functions without reverting to forking the python module? scanario: I have pyctx object that i get in python like this: pyctx = cairo.Context(surface) defined in the python extension this:
2
1823
by: sndive | last post by:
q#1: in C I want to check if a given PyObject is a xml.dom.minidom.Node (or a derivative). how do i extract a PyTypeObject for such a class? issue #2 I'm in a situation when i don't really need to extend python with any classes of my own but i do have extra luggage for the python data structures such as tuples, lists, dictionaries, etc
15
1456
by: Pie Squared | last post by:
I've been looking at the Python source code recently, more specifically trying to figure out how it's garbage collector works. I've gathered that it uses refcounting as well as some cycle-detection algorithms, but I haven't been able to figure out some other things. Does Python actually have a single 'heap' where all the data is stored?...
0
1044
by: mathieu | last post by:
Hi there, I am currently involved in managing a large python/c++ project (using swig to automagically wrap c++ code to python). So far my current experience was that python was a second class citizen and extremely little python code was written and everything seemed to work. Now this is the contrary, large portion of code are written...
0
7694
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7609
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7921
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8118
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7666
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7964
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
5217
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
1
2107
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1208
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.