Skip to content

Bugs: numeric parsing and validation (0.28.1) #34

Closed

Description

@otsobide

Defects in the numeric value objects of 0.28.1 (each one reproduced). Fixed by the new numeric.py family; every item gets a regression test and is ticked when the fix lands.

  • C09 Int.from_str parses through float and silently changes integers above 2**53 ('9007199254740993' → 9007199254740992). (750b31a)
  • C10 Int.from_str accepts non-integer strings that round to an integer ('0.99999999999999999' → 1). (750b31a)
  • C11 Int.from_str rejects valid large integer strings that the Int constructor accepts ('1' * 400). (750b31a)
  • C12 Int.from_str has no input type check: it accepts bool, bytes, int, float, Decimal and IntEnum. (750b31a)
  • C13 Int.from_str / Int.from_float swallow subclass validation errors and replace them with misleading messages. (750b31a)
  • C16 Bounded int constructors and Int.from_float(inf/nan) report misleading error messages. (cd2c88e)
  • X02 Int.from_str / Float.from_str accept whitespace-padded, underscore-grouped, exponent and non-ASCII-digit strings ('1_000', '١٢', '5', '1e3'). (750b31a, 1031aaa)
  • X03 Float.from_int silently rounds integers that are not exactly representable (2**53 + 1). (8953619)
  • X04 Int accepts integers whose str_value() then crashes with a plain ValueError (int max-str-digits limit). (7a8a34a)
  • C14/C46/C54 ~20 tests named *from_str*_with_decimals call from_float with a string, and the zero tests pass an int to from_str: Int.from_str decimal handling is untested. (750b31a)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions