Skip to content

Commit

Permalink
pythongh-114050: Fix crash when more than two arguments are passed to…
Browse files Browse the repository at this point in the history
… int() (pythonGH-114067)

Co-authored-by: Kirill Podoprigora <kirill.bast9@mail.ru>
  • Loading branch information
2 people authored and kulikjak committed Jan 22, 2024
1 parent 0ce3e6e commit 8f8613e
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 1 deletion.
1 change: 1 addition & 0 deletions Lib/test/test_int.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
@@ -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``.
2 changes: 1 addition & 1 deletion Objects/longobject.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Expand Down

0 comments on commit 8f8613e

Please sign in to comment.