]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-114050: Fix crash when more than two arguments are passed to int() (GH-114067)
authorkcatss <kcats9731@gmail.com>
Thu, 18 Jan 2024 11:27:44 +0000 (20:27 +0900)
committerGitHub <noreply@github.com>
Thu, 18 Jan 2024 11:27:44 +0000 (13:27 +0200)
Co-authored-by: Kirill Podoprigora <kirill.bast9@mail.ru>
Lib/test/test_int.py
Misc/NEWS.d/next/Core and Builtins/2024-01-17-23-39-20.gh-issue-114050.Lnv1oq.rst [new file with mode: 0644]
Objects/longobject.c

index 5545ee39d8e942952bddfae2cb2f771f80ea5afb..0bf55facad9fedbf741ea68c6f2514ef7d19d7d2 100644 (file)
@@ -90,6 +90,7 @@ class IntTestCases(unittest.TestCase):
 
 
         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)
diff --git a/Misc/NEWS.d/next/Core and Builtins/2024-01-17-23-39-20.gh-issue-114050.Lnv1oq.rst b/Misc/NEWS.d/next/Core and Builtins/2024-01-17-23-39-20.gh-issue-114050.Lnv1oq.rst
new file mode 100644 (file)
index 0000000..c35d250
--- /dev/null
@@ -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``.
index fae70dd13bb18af6fd102314642f9e32050bca58..e655ba19e8f1c12d7831a5c138374fcb7a48e991 100644 (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);
     }
 }