[Patches] [ python-Patches-1720595 ] Allow T_BOOL in PyMemberDef definitions

SourceForge.net noreply at sourceforge.net
Thu May 17 11:50:16 CEST 2007


Patches item #1720595, was opened at 2007-05-17 11:50
Message generated for change (Tracker Item Submitted) made by Item Submitter
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=1720595&group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Core (C code)
Group: Python 2.5
Status: Open
Resolution: None
Priority: 5
Private: No
Submitted By: Angelo Mottola (lillo)
Assigned to: Nobody/Anonymous (nobody)
Summary: Allow T_BOOL in PyMemberDef definitions

Initial Comment:
Hello

The attached patch allows to use T_BOOL alongside other common types in the PyMemberDef definitions of your custom types.
The boolean value is assumed to be held in a straight C char variable, and PyMember_SetOne() sets it to 1 or 0 depending on the result of calling PyObject_IsTrue() on the passed value object.


Usage example:


typedef struct ButtonObject
{
	PyObject_HEAD
	char		fToggled;
} ButtonObject;


static PyMemberDef eb_ButtonEventMembers[] = {

	{ "toggled", T_BOOL, offsetof(ButtonObject, fToggled), RO, "True if the button is currently toggled" },
	{ NULL, 0, 0, 0, NULL }
};



The patch has been built against a plain Python 2.5 installation.


----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=1720595&group_id=5470


More information about the Patches mailing list