Skip to content

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

@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

      pFad - Phonifier reborn

      Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

      Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy