[ python-Bugs-982008 ] PyObject_Str() and PyObject_Repr() corrupt
object type
SourceForge.net
noreply at sourceforge.net
Tue Jun 29 11:54:30 EDT 2004
Bugs item #982008, was opened at 2004-06-29 08:23
Message generated for change (Comment added) made by janusfury
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=982008&group_id=5470
Category: None
Group: None
>Status: Closed
Resolution: None
Priority: 5
Submitted By: Kevin Gadd (janusfury)
Assigned to: Nobody/Anonymous (nobody)
Summary: PyObject_Str() and PyObject_Repr() corrupt object type
Initial Comment:
For background: I am working on a modification to a
game engine that uses Python for automation. I am
trying to expose a few new objects to python scripts.
The engine already exposes a dozen or so different
objects to scripts, and I am exposing these new objects
the exact same way.
I am unable to override str() or repr() for my objects.
If I set the appropriate member in the type structure
(tp_str or tp_repr), PyObject_Str()/PyObject_Repr()
mangle the object when trying to convert it. If I leave
the structure member empty, everything works (except
for the str()/repr() override not working, naturally.)
I've gone over all my code multiple times, and can't
find anything that could possibly cause this. When I
step through the code in the VC++ debugger, I can see
the ob_type member of my object become corrupted at a
certain point in PyObject_Str()'s execution.
This block of code:
if (v->ob_type->tp_str == NULL)
return PyObject_Repr(v);
res = (*v->ob_type->tp_str)(v);
Is apparently the culprit. If tp_str is NULL, the line
following the if is never reached. If it is set,
however, that line is executed, and for some reason
(one which I cannot determine, since tp_str isn't
documented at all), that line calls a method of
std::string, and once that function pointer call
returns, my object's ob_type member has been changed to
an invalid pointer (usually something like 0x00000032.)
----------------------------------------------------------------------
>Comment By: Kevin Gadd (janusfury)
Date: 2004-06-29 08:54
Message:
Logged In: YES
user_id=313047
Sorry, this issue turned out to be a global scope problem.
My tp_str method had the same name and signature as a method
defined globally by a library I'm currently using, and for
some reason the debugger couldn't jump into it.
Sorry for the trouble.
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=982008&group_id=5470
More information about the Python-bugs-list
mailing list