Skip to content

Commit a571a2f

Browse files
kcatssEclips4
andauthored
gh-114050: Fix crash when more than two arguments are passed to int() (GH-114067)
Co-authored-by: Kirill Podoprigora <[email protected]>
1 parent 311d1e2 commit a571a2f

File tree

3 files changed

+4
-1
lines changed

3 files changed

+4
-1
lines changed

Lib/test/test_int.py

+1
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ def test_basic(self):
9090

9191

9292
self.assertRaises(TypeError, int, 1, 12)
93+
self.assertRaises(TypeError, int, "10", 2, 1)
9394

9495
self.assertEqual(int('0o123', 0), 83)
9596
self.assertEqual(int('0x123', 16), 291)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Fix segmentation fault caused by an incorrect format string
2+
in ``TypeError`` exception when more than two arguments are passed to ``int``.

Objects/longobject.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -6171,7 +6171,7 @@ long_vectorcall(PyObject *type, PyObject * const*args,
61716171
return long_new_impl(_PyType_CAST(type), args[0], args[1]);
61726172
default:
61736173
return PyErr_Format(PyExc_TypeError,
6174-
"int expected at most 2 argument%s, got %zd",
6174+
"int expected at most 2 arguments, got %zd",
61756175
nargs);
61766176
}
61776177
}

0 commit comments

Comments
 (0)