After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 158417 - Crash when printing zero pygflags value
Crash when printing zero pygflags value
Status: RESOLVED FIXED
Product: pygobject
Classification: Bindings
Component: gobject
2.9.0
Other Windows
: Normal critical
: ---
Assigned To: Nobody's working on this now (help wanted and appreciated)
Python bindings maintainers
Depends on:
Blocks:
 
 
Reported: 2004-11-16 01:25 UTC by Tim Evans
Modified: 2006-01-09 14:12 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Patch against pygtk-2.4.0 to fix this bug (467 bytes, patch)
2004-11-16 01:33 UTC, Tim Evans
none Details | Review

Description Tim Evans 2004-11-16 01:25:23 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.
Comment 1 Tim Evans 2004-11-16 01:33:53 UTC
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.
Comment 2 John Finlay 2004-11-16 05:30:49 UTC
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)