Description
Crash report
Putting a null byte into a Python string causes a SystemError in Python 3.10, due to a call to strlen in the string parsing library. In Python 3.9, the following example runs without errors:
# -*- coding: latin-1 -*-
"""
<NULL>
"""
In Python 3.10, it raises SystemError: ../Parser/string_parser.c:219: bad argument to internal function
.
Internally, the new string_parser library introduced in v3.10.0a1 uses a call to strlen to determine the string size, which is getting thrown off by the null byte. This call is actually unnecessary, as the length has already been calculated by the calling parser and can be retrieved with PyBytes_AsStringAndSize
.
Error messages
For single line strings, the error is SystemError: Negative size passed to PyUnicode_New
For multiline strings, the error is SystemError: ../Parser/string_parser.c:219: bad argument to internal function