Skip to content

float() does not behave the same as CPython #908

Description

@JennaSys

Right now the transcrypted float() uses JS parseFloat, but parseFoat allows for non-numeric values in the string it is partsing. It jsut stops parsing when it hits a non-numeric value instead of throwing NaN. CPython will instead raise a ValueError.

parseFloat("123.pdf")
123
float("123.pdf")
Traceback (most recent call last):
  File "/opt/pycharm/plugins/python-ce/helpers/pydev/pydevconsole.py", line 364, in runcode
    coro = func()
  File "<input>", line 1, in <module>
ValueError: could not convert string to float: '123.pdf'

Maybe use Number instead of parseFloat?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions