GNOME Bugzilla – Bug 158417
Crash when printing zero pygflags value
Last modified: 2006-01-09 14:12:35 UTC
1. Get a zero flags value, e.g. by calling gdk.Window.get_state on a normal, visible window. 2. Call repr(value). 3. Crash. Note that this depends on the behaviour of g_strdup_print when formatting a NULL value for %s, which may be platform dependent. It crashes for me on win32, but I haven't tested under anything else. I have a simple patch that fixes the problem.
Created attachment 33828 [details] [review] Patch against pygtk-2.4.0 to fix this bug If the flags value contains no known flags (most common when it's zero) generate_repr now returns the string representation of the number. This is consistent with pygenum behaviour. I also changed generate_repr take a long argument instead of int because that is the exact type of self->parent.ob_ival.
Thanks. Finsed in HEAD and 2.4 * gobject/pygflags.c (pyg_flags_repr): Print long int value if enum string not found. Fixes #158417. (modifed patch from Tim Evans)