Issue 31406: crashes when comparing between a Decimal object and a bad Rational object (original) (raw)

This issue has been migrated to GitHub: https://github.com/python/cpython/issues/75587

classification

Title: crashes when comparing between a Decimal object and a bad Rational object
Type: crash Stage: resolved
Components: Extension Modules Versions: Python 3.7, Python 3.6

process

Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: Oren Milman, serhiy.storchaka, skrah
Priority: normal Keywords: patch

Created on 2017-09-10 13:25 by Oren Milman, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 3476 closed Oren Milman,2017-09-10 15:01
PR 3477 merged skrah,2017-09-10 15:18
PR 3479 merged python-dev,2017-09-10 16:22
Messages (4)
msg301809 - (view) Author: Oren Milman (Oren Milman) * Date: 2017-09-10 13:25
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()
msg301813 - (view) Author: Stefan Krah (skrah) * (Python committer) Date: 2017-09-10 16:08
New changeset 3cedf46cdbeefc019f4a672c1104f3d5e94712bd by Stefan Krah in branch 'master': bpo-31406: Fix crash due to lack of type checking in subclassing. (#3477) https://github.com/python/cpython/commit/3cedf46cdbeefc019f4a672c1104f3d5e94712bd
msg301815 - (view) Author: Stefan Krah (skrah) * (Python committer) Date: 2017-09-10 16:46
New changeset f8909d0e4b652256e4da153fa6be664490f60a07 by Stefan Krah (Miss Islington (bot)) in branch '3.6': [3.6] bpo-31406: Fix crash due to lack of type checking in subclassing. (GH-3477) (#3479) https://github.com/python/cpython/commit/f8909d0e4b652256e4da153fa6be664490f60a07
msg301817 - (view) Author: Stefan Krah (skrah) * (Python committer) Date: 2017-09-10 17:07
Thanks for the report and the patch!
History
Date User Action Args
2022-04-11 14:58:52 admin set github: 75587
2017-09-10 17:07:20 skrah set status: open -> closedstage: patch review -> resolved
2017-09-10 17:07:12 skrah set resolution: fixedmessages: + versions: + Python 3.6
2017-09-10 16:46:52 skrah set messages: +
2017-09-10 16:22:07 python-dev set pull_requests: + <pull%5Frequest3469>
2017-09-10 16:08:06 skrah set messages: +
2017-09-10 15🔞08 skrah set pull_requests: + <pull%5Frequest3468>
2017-09-10 15:01:53 Oren Milman set keywords: + patchstage: patch reviewpull_requests: + <pull%5Frequest3467>
2017-09-10 13:47:18 serhiy.storchaka set nosy: + skrah, serhiy.storchaka
2017-09-10 13:25:42 Oren Milman create