#983

Differences from CPython 3.14 found by differential testing

Openwisper-devopened 23d ago

hi there,

found by a program generator comparing Monty (main 5915273) and CPython 3.14.8. Each example is minimized and checked by hand. None is described in limitations/, and as far as I could find, none is filed yet.

  1. await outside an async function is accepted: with async def g(): return 1, the function def f(): return await g() compiles and runs. CPython: SyntaxError: 'await' outside async function.
  2. print() and str() of a self-referencing container go one level deeper: cy = [1]; cy.append(cy); print(cy) gives [1, [1, [...]]], CPython [1, [...]]. repr() is correct. The same for dict.
  3. round(float, n) diverges: round(1e20, 3) gives 9.999999999999998e+19 (CPython 1e+20), round(710.8655, 3) gives 710.866 (CPython 710.865). About 5% of random calls. #807 fixed rounding to an integer; this path is different.
  4. format() accepts a spec where CPython refuses: format([1], '5') and format(None, '>5') pad with spaces. CPython: TypeError: unsupported format string passed to list.__format__. With a huge width, a huge string is allocated.
  5. float('1_000') and float(b'1.5') fail; CPython gives 1000.0 and 1.5.
  6. Comparisons: bytes(2) < b'abc' and {1, 2} >= {1} (and <=, <, > for sets) give TypeError; CPython gives True. Comparing two bytes literals works.
  7. chr(2**63) gives TypeError instead of ValueError: chr() arg not in range(0x110000).
  8. repr() of a list nested 1500 deep is silently truncated to [...] after 1000 levels; CPython returns the full string.

related: the order of attribute lookup and argument evaluation, #976 (for builtin types, as noted there, it remains).

Activity

0

No activity yet.