Patches item #1720595, was opened at 2007-05-17 09:50
Message generated for change (Comment added) made by gbrandl
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.
----------------------------------------------------------------------
>Comment By: Georg Brandl (gbrandl)
Date: 2007-05-17 15:58
Message:
Logged In: YES
user_id=849994
Originator: NO
I'd rather not allow any object to be assigned to the attribute, but only
a bool. T_INT, for example, doesn't automatically call int() on its values
too.
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=1720595&group_id=5470
_______________________________________________
Patches mailing list
[email protected]
http://mail.python.org/mailman/listinfo/patches