Fix the ValueError for whitespace in float()

Ignore whitespace

Fixed: #1391
This commit is contained in:
MinJeong Kim
2019-09-20 17:38:22 +00:00
parent 59d4e4e7c1
commit 6e7e6ecfce

View File

@@ -323,7 +323,7 @@ impl PyFloat {
} else if objtype::isinstance(&arg, &vm.ctx.int_type()) {
objint::get_float_value(&arg, vm)?
} else if objtype::isinstance(&arg, &vm.ctx.str_type()) {
match lexical::try_parse(objstr::get_value(&arg)) {
match lexical::try_parse(objstr::get_value(&arg).trim()) {
Ok(f) => f,
Err(_) => {
let arg_repr = vm.to_pystr(&arg)?;