Skip to content

SystemError: invalid maximum character passed to PyUnicode_New #140410

@YuanchengJiang

Description

@YuanchengJiang

Bug report

Bug description:

import unittest
try:
    from _testcapi import PY_SSIZE_T_MIN, PY_SSIZE_T_MAX
except ImportError:
    _testcapi = None
class CAPITest(unittest.TestCase):
    def test_new(self):
        from _testcapi import unicode_new as new
        for maxchar in (0, 97, 4096, 20320, 128512, 1114111):
            self.assertRaises(MemoryError, new, PY_SSIZE_T_MAX, maxchar)
        self.assertEqual(new(-1, 1114112), '')
if __name__ == '__main__':
    unittest.main()

CPython versions tested on:

3.15

Operating systems tested on:

Linux

Metadata

Metadata

Assignees

No one assigned

    Labels

    type-bugAn unexpected behavior, bug, or error

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions