Bugs item #1741218, was opened at 2007-06-21 16:33 Message generated for change (Tracker Item Submitted) made by Item Submitter You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1741218&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: Python Interpreter Core Group: Python 2.5 Status: Open Resolution: None Priority: 5 Private: No Submitted By: Kenji Noguchi (kenjinoguchi) Assigned to: Nobody/Anonymous (nobody) Summary: string formatter %x problem with indirectly given long Initial Comment: "%x" % v fails if the v is a instance, and its __int__ returns larger than 0x80000000 on 32bit OS. I've reported the problem at Python ML. http://mail.python.org/pipermail/python-list/2007-June/446103.html "%x" % int(v) "%x" % 0x80000000L above two work fine because string formatter processes a long value exceptionally. It looks inconsistent. So I made this patch. --- stringobject.c.org 2007-06-21 13:57:54.745877000 -0700 +++ stringobject.c 2007-06-21 13:59:19.576646000 -0700 @@ -4684,6 +4684,15 @@ case 'X': if (c == 'i') c = 'd'; + /* try to convert objects to number*/ + PyNumberMethods *nb; + if ((nb = v->ob_type->tp_as_number) && + nb->nb_int) { + v = (*nb->nb_int) (v); + if(v == NULL) + goto error; + } + if (PyLong_Check(v)) { int ilen; temp = _PyString_FormatLong(v, flags, ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1741218&group_id=5470 _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com