Movatterモバイル変換


[0]ホーム

URL:


homepage

Issue31293

This issue trackerhas been migrated toGitHub, and is currentlyread-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title:crashes in multiply_float_timedelta() and in truedivide_timedelta_float()
Type:crashStage:resolved
Components:Extension ModulesVersions:Python 3.7, Python 3.6
process
Status:closedResolution:fixed
Dependencies:Superseder:
Assigned To:Nosy List: Oren Milman, belopolsky, serhiy.storchaka
Priority:normalKeywords:patch

Created on2017-08-28 14:36 byOren Milman, last changed2022-04-11 14:58 byadmin. This issue is nowclosed.

Pull Requests
URLStatusLinkedEdit
PR 3227mergedOren Milman,2017-08-28 15:35
PR 3654mergedpython-dev,2017-09-19 12:58
Messages (7)
msg300954 -(view)Author: Oren Milman (Oren Milman)*Date: 2017-08-28 14:36
both of the following true division and multiplication operations crash theinterpreter:import datetimeclass BadFloat(float):    def as_integer_ratio(self):        return (1 << 1000) - 1datetime.timedelta() / BadFloat()datetime.timedelta() * BadFloat()this is because both multiply_float_timedelta() and truedivide_timedelta_float()(inModules/_datetimemodule.c) assume as_integer_ratio() returns tuple.
msg300955 -(view)Author: Oren Milman (Oren Milman)*Date: 2017-08-28 14:43
i am working on a patch.BTW, is there anywhere a list of what counts as an extensionmodule, and what counts as the interpreter core?
msg300956 -(view)Author: Serhiy Storchaka (serhiy.storchaka)*(Python committer)Date: 2017-08-28 15:24
I don't know if there is a list, but definitely the parser, the compiler, the evaluation loop, builtin types and few builtin modules (like builtins and sys) are interpreter core. The _datetime module is an accelerator of the datetime module. It is optional and definitely is not in the core.
msg300957 -(view)Author: Serhiy Storchaka (serhiy.storchaka)*(Python committer)Date: 2017-08-28 17:57
Please check if there is similar issue with Decimal.
msg300958 -(view)Author: Oren Milman (Oren Milman)*Date: 2017-08-28 18:23
I guess you meant for me to check whether the following has any problem:import decimalclass BadFloat(float):    def as_integer_ratio(self):        return 1 << 1000decimal.Decimal.from_float(BadFloat())so it doesn't crash.if IIUC, this is because the C implementation of Decimal.from_float()is PyDecType_FromFloat(), while the relevant part of it is a call toPyDecType_FromFloatExact().But PyDecType_FromFloatExact() uses float.as_integer_ratio(), and thusISTM that the issue doesn't exist there.(also, the following doesn't raise an exception, as expected:import decimalclass BadFloat(float):    def as_integer_ratio(self):        raise RuntimeErrordecimal.Decimal.from_float(BadFloat()))
msg302520 -(view)Author: Serhiy Storchaka (serhiy.storchaka)*(Python committer)Date: 2017-09-19 12:58
New changeset865e4b4f630e2ae91e61239258abb58b488f1d65 by Serhiy Storchaka (Oren Milman) in branch 'master':bpo-31293: Fix crashes in truediv and mul of a timedelta by a float with a bad as_integer_ratio() method. (#3227)https://github.com/python/cpython/commit/865e4b4f630e2ae91e61239258abb58b488f1d65
msg302528 -(view)Author: Serhiy Storchaka (serhiy.storchaka)*(Python committer)Date: 2017-09-19 14:00
New changesetf37dd11f0d4832c15d49c2ddc83d533ddaa36e74 by Serhiy Storchaka (Miss Islington (bot)) in branch '3.6':[3.6]bpo-31293: Fix crashes in truediv and mul of a timedelta by a float with a bad as_integer_ratio() method. (GH-3227) (#3654)https://github.com/python/cpython/commit/f37dd11f0d4832c15d49c2ddc83d533ddaa36e74
History
DateUserActionArgs
2022-04-11 14:58:51adminsetgithub: 75474
2017-09-19 14:01:15serhiy.storchakasetstatus: open -> closed
stage: patch review -> resolved
resolution: fixed
versions: + Python 3.6
2017-09-19 14:00:46serhiy.storchakasetmessages: +msg302528
2017-09-19 12:58:25python-devsetkeywords: +patch
stage: needs patch -> patch review
pull_requests: +pull_request3647
2017-09-19 12:58:13serhiy.storchakasetmessages: +msg302520
2017-08-28 18:23:30Oren Milmansetmessages: +msg300958
2017-08-28 17:57:52serhiy.storchakasetmessages: +msg300957
2017-08-28 15:35:57Oren Milmansetpull_requests: +pull_request3270
2017-08-28 15:24:47serhiy.storchakasetmessages: +msg300956
2017-08-28 14:43:56Oren Milmansetmessages: +msg300955
2017-08-28 14:42:04serhiy.storchakasetcomponents: + Extension Modules, - Interpreter Core
2017-08-28 14:41:55serhiy.storchakasetnosy: +belopolsky,serhiy.storchaka

stage: needs patch
2017-08-28 14:36:40Oren Milmancreate
Supported byThe Python Software Foundation,
Powered byRoundup
Copyright © 1990-2022,Python Software Foundation
Legal Statements

[8]ページ先頭

©2009-2026 Movatter.jp