From a9e26952e910b225459c320c9b4ef27ddbdb95fb Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Sun, 22 Oct 2017 09:29:19 +0530 Subject: [PATCH] ... --- kitty/screen.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/kitty/screen.c b/kitty/screen.c index 66ae4f352..b6d422be8 100644 --- a/kitty/screen.c +++ b/kitty/screen.c @@ -1251,9 +1251,10 @@ screen_wcswidth(Screen UNUSED *self, PyObject *str) { if (PyUnicode_READY(str) != 0) return NULL; int kind = PyUnicode_KIND(str); void *data = PyUnicode_DATA(str); - Py_ssize_t len = PyUnicode_GET_LENGTH(str), ans = 0, i; - for (i = 0; i < len; i++) ans += wcwidth_impl(PyUnicode_READ(kind, data, i)); - return PyLong_FromSsize_t(ans); + Py_ssize_t len = PyUnicode_GET_LENGTH(str), i; + unsigned long ans = 0; + for (i = 0; i < len; i++) ans += safe_wcwidth(PyUnicode_READ(kind, data, i)); + return PyLong_FromUnsignedLong(ans); } static PyObject*