Message 309306 - Python tracker (original) (raw)

if math.gcd() only accepts integers and not, at least, numbers.Integral, wouldn't that be a bug?

I'd call it an enhancement opportunity rather than a bug. :-) There's no general Python-wide requirement that an instance of numbers.Integral should be acceptable anywhere an int is (though I agree that it's a nice property to have in general).

But as it happens, math.gcd does accept instances of numbers.Integral, since any such instance should implement the index method to convert itself to a plain old int, and math.gcd passes its arguments through PyNumber_Index.