[Backport maintenance/4.1.x] Fix MemoryError when inferring f-string with large width (#2981)
Fix MemoryError when inferring f-string with large format width
Catch MemoryError in FormattedValue._infer() so that f-strings with
huge format widths (e.g. f'{0:11111111111}') yield Uninferable instead
of crashing.
The test uses an OOMInt subclass whose __format__ raises MemoryError,
avoiding the slow/OOM-inducing actual allocation.
Closes #2762
(cherry picked from commit 2dc42c089f0be62d6f914e93624b66be7a89c5b9)
Co-authored-by: Fridayworks <aifriday700@gmail.com>3 files changed