Issue 31406: crashes when comparing between a Decimal object and a bad Rational object
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) * ![]() |
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) * ![]() |
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) * ![]() |
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 -> closed stage: patch review -> resolved |
| 2017-09-10 17:07:12 | skrah | set | resolution: fixed messages: + msg301817 versions: + Python 3.6 |
| 2017-09-10 16:46:52 | skrah | set | messages: + msg301815 |
| 2017-09-10 16:22:07 | python-dev | set | pull_requests: + pull_request3469 |
| 2017-09-10 16:08:06 | skrah | set | messages: + msg301813 |
| 2017-09-10 15:18:08 | skrah | set | pull_requests: + pull_request3468 |
| 2017-09-10 15:01:53 | Oren Milman | set | keywords:
+ patch stage: patch review pull_requests: + pull_request3467 |
| 2017-09-10 13:47:18 | serhiy.storchaka | set | nosy:
+ skrah, serhiy.storchaka |
| 2017-09-10 13:25:42 | Oren Milman | create | |
