Mark Dickinson <dicki...@gmail.com> added the comment: > Right. In practice, returning a long instead of an int can produce bugs, > mainly because some C functions will only accept ints and refuse longs.
I'd say 'in theory' rather than 'in practice' here. In this particular case, I don't see much danger: any C code explicitly calling PyNumber_Long (rather than PyNumber_Int) surely has to be prepared to deal with a long, since that's what's going to be returned in the vast majority of cases. Similarly for Python code calling 'long' rather than 'int'. I'd also note that the docs state clearly that PyNumber_Long returns a long (while PyNumber_Int, in contrast, is permitted to return either an int or a long); similarly for the builtin 'long' function. And finally, looking at the history of the test_class test (see issue 1671298), it doesn't look as if anyone was thinking too hard about return types at that point---it looks like the test was just fit to the existing semi-broken behaviour. So I'm still proposing to apply this patch, in spite of Antoine's -1. ;-) ---------- _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue9869> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com