gh-114050: Fix crash when more than two arguments are passed to int() (GH-114067)

Co-authored-by: Kirill Podoprigora <kirill.bast9@mail.ru>
This commit is contained in:
kcatss 2024-01-18 20:27:44 +09:00 committed by GitHub
parent 311d1e2701
commit a571a2fd3f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 4 additions and 1 deletions

View file

@ -90,6 +90,7 @@ def test_basic(self):
self.assertRaises(TypeError, int, 1, 12)
self.assertRaises(TypeError, int, "10", 2, 1)
self.assertEqual(int('0o123', 0), 83)
self.assertEqual(int('0x123', 16), 291)

View file

@ -0,0 +1,2 @@
Fix segmentation fault caused by an incorrect format string
in ``TypeError`` exception when more than two arguments are passed to ``int``.

View file

@ -6171,7 +6171,7 @@ long_vectorcall(PyObject *type, PyObject * const*args,
return long_new_impl(_PyType_CAST(type), args[0], args[1]);
default:
return PyErr_Format(PyExc_TypeError,
"int expected at most 2 argument%s, got %zd",
"int expected at most 2 arguments, got %zd",
nargs);
}
}