gh-117709: Add vectorcall support for str() with positional-only arguments (#117746)

Fall back to tp_call() for cases when arguments are passed by name.

Co-authored-by: Donghee Na <donghee.na@python.org>
Co-authored-by: Victor Stinner <vstinner@python.org>
This commit is contained in:
Erlend E. Aasland 2024-04-11 15:55:37 +02:00 committed by GitHub
parent 671cb22094
commit 044dc496e0
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 72 additions and 0 deletions

View file

@ -2651,6 +2651,24 @@ class StrTest(string_tests.StringLikeTest,
proc = assert_python_failure('-X', 'dev', '-c', code)
self.assertEqual(proc.rc, 10, proc)
def test_str_invalid_call(self):
check = lambda *a, **kw: self.assertRaises(TypeError, str, *a, **kw)
# too many args
check(1, "", "", 1)
# no such kw arg
check(test=1)
# 'encoding' must be str
check(1, encoding=1)
check(1, 1)
# 'errors' must be str
check(1, errors=1)
check(1, "", errors=1)
check(1, 1, 1)
class StringModuleTest(unittest.TestCase):
def test_formatter_parser(self):