classification
Title: Incorrect error message on float('')
Type: behavior Stage: resolved
Components: Interpreter Core Versions: Python 3.7
process
Status: closed Resolution: fixed
Dependencies: 2651 Superseder:
Assigned To: Nosy List: Drekin, Nofar Schnider, Pedro Lacerda, cheryl.sabella, cryvate, eryksun, mark.dickinson, rhettinger, wolma
Priority: normal Keywords: patch

Created on 2016-06-08 14:34 by Drekin, last changed 2019-05-17 22:35 by cheryl.sabella. This issue is now closed.

Files
File name Uploaded Description Edit
float.patch Pedro Lacerda, 2016-06-16 06:17
Pull Requests
URL Status Linked Edit
PR 2745 merged Pedro Lacerda, 2017-07-18 01:12
PR 3722 closed Cryvate, 2017-09-24 17:18
Messages (10)
msg267858 - (view) Author: Adam BartoŇ° (Drekin) * Date: 2016-06-08 14:34
>>> float('foo')
ValueError: could not convert string to float: 'foo'
>>> float('')
ValueError: could not convert string to float: 

should be
ValueError: could not convert string to float: ''

The message comes from Objects/floatobject.c:183 but I don't understand how the empty string gets discarded.
msg267864 - (view) Author: Eryk Sun (eryksun) * (Python triager) Date: 2016-06-08 15:26
> The message comes from Objects/floatobject.c:183

No, in this case the error is set in PyOS_string_to_double in Python/pystrtod.c, because `fail_pos == s`, and it doesn't get replaced in PyFloat_FromString because `end == last`. The format string in PyOS_string_to_double should probably be "'%.200s'".
msg268644 - (view) Author: Pedro Lacerda (Pedro Lacerda) * Date: 2016-06-16 06:17
Following the bug pointed by Adam and Eryk.
msg274150 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2016-09-01 16:26
Setting this aside for Nofar to review.
msg275425 - (view) Author: Nofar Schnider (Nofar Schnider) * (Python triager) Date: 2016-09-09 20:29
Tested and reviewed the patch on the relevant versions. Works well!
msg275428 - (view) Author: Nofar Schnider (Nofar Schnider) * (Python triager) Date: 2016-09-09 20:35
Assigning to Raymond for final approval.
msg297812 - (view) Author: Wolfgang Maier (wolma) * Date: 2017-07-06 07:45
Could somebody turn this into a PR to move things forward?

I guess Nofar mistakenly set resolution to "works for me", but meant "patch works for me"?
msg302871 - (view) Author: Henk-Jaap Wagenaar (cryvate) * Date: 2017-09-24 17:20
@Wolfgang

I just created a PR, only to realise that Pedro already made one a while back: PR 2745
msg342771 - (view) Author: Cheryl Sabella (cheryl.sabella) * (Python committer) Date: 2019-05-17 22:32
New changeset 4fa7504ee3184cff064e23fe6799e717ed0f9357 by Cheryl Sabella (Pedro Lacerda) in branch 'master':
bpo-27268: Fix incorrect error message on float('') (GH-2745)
https://github.com/python/cpython/commit/4fa7504ee3184cff064e23fe6799e717ed0f9357
msg342772 - (view) Author: Cheryl Sabella (cheryl.sabella) * (Python committer) Date: 2019-05-17 22:35
@Drekin, thank you for the report, @Pedro Lacerda, thank you for the pull request, and @Nofar Schnider, thank you for the review.
History
Date User Action Args
2019-05-17 22:35:40cheryl.sabellasetstatus: open -> closed
nosy: rhettinger, mark.dickinson, eryksun, Drekin, wolma, Nofar Schnider, Pedro Lacerda, cheryl.sabella, cryvate
messages: + msg342772

resolution: works for me -> fixed
stage: patch review -> resolved
2019-05-17 22:32:50cheryl.sabellasetnosy: + cheryl.sabella
messages: + msg342771
2017-09-24 17:20:05cryvatesetnosy: + cryvate
messages: + msg302871
2017-09-24 17:18:33Cryvatesetpull_requests: + pull_request3708
2017-09-24 16:50:17rhettingersetassignee: rhettinger ->
versions: - Python 2.7, Python 3.5, Python 3.6
2017-07-18 01:12:00Pedro Lacerdasetpull_requests: + pull_request2805
2017-07-06 07:45:10wolmasetnosy: + wolma
messages: + msg297812
2016-10-25 12:42:34serhiy.storchakasetnosy: - serhiy.storchaka

versions: + Python 3.7
2016-09-10 00:14:27lukasz.langasetdependencies: + Strings passed to KeyError do not round trip
2016-09-09 20:35:45Nofar Schnidersetassignee: Nofar Schnider -> rhettinger
resolution: works for me
messages: + msg275428
2016-09-09 20:29:26Nofar Schnidersetmessages: + msg275425
stage: patch review
2016-09-06 22:58:11rhettingersetassignee: rhettinger -> Nofar Schnider

nosy: + Nofar Schnider
2016-09-01 16:26:19rhettingersetassignee: rhettinger

messages: + msg274150
nosy: + rhettinger
2016-06-16 06:17:21Pedro Lacerdasetfiles: + float.patch

nosy: + Pedro Lacerda
messages: + msg268644

keywords: + patch
2016-06-08 17:41:45serhiy.storchakasetnosy: + mark.dickinson, serhiy.storchaka
2016-06-08 15:26:24eryksunsetnosy: + eryksun

messages: + msg267864
versions: + Python 2.7, Python 3.6
2016-06-08 14:34:24Drekincreate