From a52b11d05757ee9c056a7f1118e6f7d3c2da9d44 Mon Sep 17 00:00:00 2001 From: lsq Date: Thu, 11 Dec 2025 19:59:13 +0100 Subject: [PATCH] patch 9.1.1967: if_python: 64bit numbers truncated Problem: if_python: 64bit numbers truncated Solution: cast python result to long long (lsq) fixes: #18899 closes: #18904 Signed-off-by: lsq Signed-off-by: Yegappan Lakshmanan Signed-off-by: Christian Brabandt --- src/if_py_both.h | 2 +- src/testdir/test_python3.vim | 7 ++++++- src/version.c | 2 ++ 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/if_py_both.h b/src/if_py_both.h index 7fc055db53..e0020519b0 100644 --- a/src/if_py_both.h +++ b/src/if_py_both.h @@ -1039,7 +1039,7 @@ VimToPython(typval_T *our_tv, int depth, PyObject *lookup_dict) char buf[NUMBUFLEN]; // For backwards compatibility numbers are stored as strings. - sprintf(buf, "%ld", (long)our_tv->vval.v_number); + sprintf(buf, "%lld", (long long)our_tv->vval.v_number); ret = PyString_FromString((char *)buf); } else if (our_tv->v_type == VAR_FLOAT) diff --git a/src/testdir/test_python3.vim b/src/testdir/test_python3.vim index 3cc5ff2d9f..8fc62d6991 100644 --- a/src/testdir/test_python3.vim +++ b/src/testdir/test_python3.vim @@ -305,7 +305,12 @@ endfunc " Test vim.eval() with various types. func Test_python3_vim_eval() - call assert_equal("\n8", execute('py3 print(vim.eval("3+5"))')) + call assert_equal("\n2061300532912", execute('py3 print(vim.eval("2061300532912"))')) + call assert_equal("\n9223372036854775807", execute('py3 print(vim.eval("9223372036854775807"))')) + call assert_equal("\n-9223372036854775807",execute('py3 print(vim.eval("-9223372036854775807"))')) + call assert_equal("\n2147483648", execute('py3 print(vim.eval("2147483648"))')) + call assert_equal("\n-2147483649", execute('py3 print(vim.eval("-2147483649"))')) + call assert_equal("\n8", execute('py3 print(vim.eval("3+5"))')) call assert_equal("\n3.140000", execute('py3 print(vim.eval("1.01+2.13"))')) call assert_equal("\n0.000000", execute('py3 print(vim.eval("0.0/(1.0/0.0)"))')) call assert_equal("\n0.000000", execute('py3 print(vim.eval("0.0/(1.0/0.0)"))')) diff --git a/src/version.c b/src/version.c index 9e5cfdcd55..e02438312f 100644 --- a/src/version.c +++ b/src/version.c @@ -729,6 +729,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 1967, /**/ 1966, /**/ -- 2.47.3