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 mark.dickinson
Recipients facundobatista, mark.dickinson, rhettinger, skrah, terry.reedy
Date 2018-03-15.20:38:32
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
Observed by Terry Reedy in the issue #25735 discussion (msg255479):

>>> factorial(decimal.Decimal(5.2))

This should be either raising an exception (either ValueError or TypeError, depending on whether we want to accept only integral Decimal values, or prohibit Decimal values altogether), or possibly returning an approximation to Gamma(6.2) (=169.406099461722999629...)

I'd prefer that we prohibit a Decimal input altogether, but accepting integral Decimal instances would parallel the current behaviour with floats:

>>> factorial(5.2)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ValueError: factorial() only accepts integral values
>>> factorial(5.0)

Terry also observed:

>>> factorial(Fraction(5))
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: an integer is required (got type Fraction)
Date User Action Args
2018-03-15 20:38:33mark.dickinsonsetrecipients: + mark.dickinson, rhettinger, terry.reedy, facundobatista, skrah
2018-03-15 20:38:33mark.dickinsonsetmessageid: <>
2018-03-15 20:38:33mark.dickinsonlinkissue33083 messages
2018-03-15 20:38:32mark.dickinsoncreate