New submission from Oren Milman: The following code crashes the interpreter:
import decimal import fractions class BadRational(fractions.Fraction): numerator = None denominator = 42 decimal.Decimal() < BadRational() this is because numerator_as_decimal() (in Modules/_decimal/_decimal.c) assumes that 'numerator' is an integer. multiply_by_denominator() (in Modules/_decimal/_decimal.c) also assumes that 'denominator' is an integer, and so the following code crashes the interpreter: import decimal import fractions class BadRational(fractions.Fraction): numerator = 42 denominator = None decimal.Decimal() < BadRational() ---------- components: Extension Modules messages: 301809 nosy: Oren Milman priority: normal severity: normal status: open title: crashes when comparing between a Decimal object and a bad Rational object type: crash versions: Python 3.7 _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue31406> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com