diff -r c568b6ac5e89 Objects/unicodeobject.c --- a/Objects/unicodeobject.c Wed Dec 21 17:30:50 2016 +0100 +++ b/Objects/unicodeobject.c Thu Dec 22 12:57:26 2016 +0800 @@ -14286,11 +14286,13 @@ if (iobj == NULL) { goto onError; } - v = iobj; + /* Integer input truncated to a character */ + x = PyLong_AsLong(iobj); Py_DECREF(iobj); - } - /* Integer input truncated to a character */ - x = PyLong_AsLong(v); + } else { + /* Integer input truncated to a character */ + x = PyLong_AsLong(v); + } if (x == -1 && PyErr_Occurred()) goto onError;