Closed
Description
Bug report
Bug description:
The below code results in a 'MemoryError' being raised in the format_field
function.
import string
obj = string.Formatter()
ret = obj.format_field("test", "5555555555550555")
Traceback
Traceback (most recent call last):
File "rep.py", line 4, in <module>
ret = obj.format_field("test", "5555555555550555")
File "/usr/lib/python3.10/string.py", line 235, in format_field
return format(value, format_spec)
MemoryError
CPython versions tested on:
3.10
Operating systems tested on:
Linux
Activity
StanFromIreland commentedon May 14, 2025
format_field
is a wrapper aroundformat
Is the core problem. Though IMO it is fine, it is a massive width, and would realistically fail, is there even a point to making it more graceful?
sergey-miryanov commentedon May 14, 2025
What do you expect? Your format string interpreted as a '5555555555550555s' and tried to allocate string with length of 5555555555550555.
gabe-sherman commentedon May 14, 2025
Thank you for the responses. This was found while fuzzing the Python interpreter libraries, and I wasn't sure if it represented a true issue. I will close this issue now, as this represents expected behavior.