Commit: patch 9.1.1967: if_python: 64bit numbers truncated

2 views
Skip to first unread message

Christian Brabandt

unread,
Dec 11, 2025, 2:31:00 PM (13 hours ago) Dec 11
to vim...@googlegroups.com
patch 9.1.1967: if_python: 64bit numbers truncated

Commit: https://github.com/vim/vim/commit/a52b11d05757ee9c056a7f1118e6f7d3c2da9d44
Author: lsq <lsq...@gmail.com>
Date: Thu Dec 11 19:59:13 2025 +0100

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 <lsq...@gmail.com>
Signed-off-by: Yegappan Lakshmanan <yega...@yahoo.com>
Signed-off-by: Christian Brabandt <c...@256bit.org>

diff --git a/src/if_py_both.h b/src/if_py_both.h
index 7fc055db5..e0020519b 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 3cc5ff2d9..8fc62d699 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("
8", execute('py3 print(vim.eval("3+5"))'))
+ call assert_equal("
2061300532912", execute('py3 print(vim.eval("2061300532912"))'))
+ call assert_equal("
9223372036854775807", execute('py3 print(vim.eval("9223372036854775807"))'))
+ call assert_equal("
-9223372036854775807",execute('py3 print(vim.eval("-9223372036854775807"))'))
+ call assert_equal("
2147483648", execute('py3 print(vim.eval("2147483648"))'))
+ call assert_equal("
-2147483649", execute('py3 print(vim.eval("-2147483649"))'))
+ call assert_equal("
8", execute('py3 print(vim.eval("3+5"))'))
call assert_equal("
3.140000", execute('py3 print(vim.eval("1.01+2.13"))'))
call assert_equal("
0.000000", execute('py3 print(vim.eval("0.0/(1.0/0.0)"))'))
call assert_equal("
0.000000", execute('py3 print(vim.eval("0.0/(1.0/0.0)"))'))
diff --git a/src/version.c b/src/version.c
index 9e5cfdcd5..e02438312 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,
/**/
Reply all
Reply to author
Forward
0 new messages