]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-135379: fix MSVC warning: conversion from 'stwodigits' to 'digit' (GH-135714)
authorChris Eibl <138194463+chris-eibl@users.noreply.github.com>
Fri, 20 Jun 2025 09:05:33 +0000 (11:05 +0200)
committerGitHub <noreply@github.com>
Fri, 20 Jun 2025 09:05:33 +0000 (17:05 +0800)
fix warning C4244: 'initializing': conversion from

'stwodigits' to 'digit', possible loss of data

Objects/longobject.c

index 59b10355ad9df88f1b3a265eaba709181eebdead..557bb6e1dd956cd6f3a7c7cf4acbc36899ca613a 100644 (file)
@@ -337,7 +337,7 @@ medium_from_stwodigits(stwodigits x)
         }
         _PyObject_Init((PyObject*)v, &PyLong_Type);
     }
-    digit abs_x = x < 0 ? -x : x;
+    digit abs_x = x < 0 ? (digit)(-x) : (digit)x;
     _PyLong_SetSignAndDigitCount(v, x<0?-1:1, 1);
     v->long_value.ob_digit[0] = abs_x;
     return PyStackRef_FromPyObjectStealMortal((PyObject *)v);