Skip to content

FloatField will crash if the input is a number that is too big #8716

Closed
@beltagymohamed

Description

@beltagymohamed

Discussed in #8715

Originally posted by beltagymohamed October 17, 2022
If you provid an input to the FloatField that is too big for example toolargeinput.txt it will crash with the following error

  File ".../lib/python3.10/site-packages/rest_framework/fields.py", line 994, in to_internal_value
    return float(data)
OverflowError: int too large to convert to float

I propose to fix this by adding the following to the exception list OverflowError so the line change as below
https://github.com/encode/django-rest-framework/blob/master/rest_framework/fields.py#L946

# current implementation 
# except (TypeError, ValueError):  
# proposed change to handle this bug   
except (TypeError, ValueError, OverflowError):  

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions