Bugs item #1630863, was opened at 2007-01-08 21:06 Message generated for change (Comment added) made by loewis You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1630863&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: None Group: None >Status: Closed >Resolution: Invalid Priority: 5 Private: No Submitted By: Roger Upole (rupole) Assigned to: Martin v. Löwis (loewis) Summary: PyLong_AsLong doesn't check tp_as_number Initial Comment: Both PyInt_AsLong and PyLong_AsLongLong check if an object's type has PyNumberMethods defined. However, PyLong_AsLong does not, causing conversion to fail for objects which can legitimately be converted to a long. ---------------------------------------------------------------------- >Comment By: Martin v. Löwis (loewis) Date: 2007-01-12 08:46 Message: Logged In: YES user_id=21627 Originator: NO No, I'm saying that PyLong_AsVoidPtr is guaranteed to convert ints and longs, nothing else. Likewise, PyLong_AsVoidPtr is only supported for int and long objects (read the documentation). It's not deprecated - but it should only be used for the cases which it is documented to support. If, for some reason, you want to convert an object that is not an int or long into a void*, by converting it to an int first, you need to invoke the number methods first yourself. Closing this report as invalid. ---------------------------------------------------------------------- Comment By: Roger Upole (rupole) Date: 2007-01-12 03:11 Message: Logged In: YES user_id=771074 Originator: YES The problem is that the conversion fails when it should succeed. The place I ran into this was in PyLong_AsVoidPtr, which I can't change. Are you saying that PyLong_AsLong is deprecated, and should never be used ? ---------------------------------------------------------------------- Comment By: Martin v. Löwis (loewis) Date: 2007-01-12 00:20 Message: Logged In: YES user_id=21627 Originator: NO I fail to see the problem. If you want to convert arbitrary objects to long, use PyInt_AsLong. ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1630863&group_id=5470 _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com