This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author serhiy.storchaka
Recipients John.Yeung, facundobatista, mark.dickinson, rhettinger, serhiy.storchaka, skrah, terry.reedy
Date 2018-03-15.23:00:55
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1521154855.8.0.467229070634.issue33083@psf.upfronthosting.co.za>
In-reply-to
Content
Many functions implemented in C accept Decimal instances.

>>> chr(decimal.Decimal(65.2))
'A'

This is because PyLong_AsLong() and similar functions call __int__().

Floats are specially prohibited when convert arguments with PyArg_Parse() with the "i" format unit.

>>> chr(65.2)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: integer argument expected, got float

The specific of factorial() is that it accepts integral floats and raises ValueError instead of TypeError for non-integral floats. Maybe it was planned to extend factorial() to non-integral floats by using a gamma function. All other functions in the math module worked with floats at the time of adding factorial() in issue2138. math.gamma() was added 1.5 years later in issue3366.
History
Date User Action Args
2018-03-15 23:00:55serhiy.storchakasetrecipients: + serhiy.storchaka, rhettinger, terry.reedy, facundobatista, mark.dickinson, skrah, John.Yeung
2018-03-15 23:00:55serhiy.storchakasetmessageid: <1521154855.8.0.467229070634.issue33083@psf.upfronthosting.co.za>
2018-03-15 23:00:55serhiy.storchakalinkissue33083 messages
2018-03-15 23:00:55serhiy.storchakacreate