Skip to content

Commit 7ebfc6e

Browse files
authored
[3.13] pythongh-132909: handle overflow for 'K' format in do_mkvalue (pythonGH-132911) (python#132932)
(cherry picked from commit 3fa024d)
1 parent 3776ade commit 7ebfc6e

File tree

3 files changed

+6
-1
lines changed

3 files changed

+6
-1
lines changed

Doc/c-api/arg.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -639,6 +639,8 @@ Building values
639639
``L`` (:class:`int`) [long long]
640640
Convert a C :c:expr:`long long` to a Python integer object.
641641
642+
.. _capi-py-buildvalue-format-K:
643+
642644
``K`` (:class:`int`) [unsigned long long]
643645
Convert a C :c:expr:`unsigned long long` to a Python integer object.
644646
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Fix an overflow when handling the :ref:`K <capi-py-buildvalue-format-K>` format
2+
in :c:func:`Py_BuildValue`. Patch by Bénédikt Tran.

Python/modsupport.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,8 @@ do_mkvalue(const char **p_format, va_list *p_va)
320320
return PyLong_FromLongLong((long long)va_arg(*p_va, long long));
321321

322322
case 'K':
323-
return PyLong_FromUnsignedLongLong((long long)va_arg(*p_va, unsigned long long));
323+
return PyLong_FromUnsignedLongLong(
324+
va_arg(*p_va, unsigned long long));
324325

325326
case 'u':
326327
{

0 commit comments

Comments
 (0)