diff options
author | Victor Stinner <victor.stinner@haypocalc.com> | 2011-10-14 00:13:11 (GMT) |
---|---|---|
committer | Victor Stinner <victor.stinner@haypocalc.com> | 2011-10-14 00:13:11 (GMT) |
commit | f5cff56a1be70d2c4e5cde5fa4e5d5d92e620dda (patch) | |
tree | 0eb7ea39ee5a60f384db53d5729b48d73986920d /Modules/binascii.c | |
parent | e506437b52507609772e8141fdbb5ad2e17471bb (diff) | |
download | cpython-f5cff56a1be70d2c4e5cde5fa4e5d5d92e620dda.zip cpython-f5cff56a1be70d2c4e5cde5fa4e5d5d92e620dda.tar.gz cpython-f5cff56a1be70d2c4e5cde5fa4e5d5d92e620dda.tar.bz2 |
Issue #13088: Add shared Py_hexdigits constant to format a number into base 16
Diffstat (limited to 'Modules/binascii.c')
-rw-r--r-- | Modules/binascii.c | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/Modules/binascii.c b/Modules/binascii.c index 19681b4..dc4fef5 100644 --- a/Modules/binascii.c +++ b/Modules/binascii.c @@ -1078,13 +1078,11 @@ binascii_hexlify(PyObject *self, PyObject *args) /* make hex version of string, taken from shamodule.c */ for (i=j=0; i < arglen; i++) { - char c; + unsigned char c; c = (argbuf[i] >> 4) & 0xf; - c = (c>9) ? c+'a'-10 : c + '0'; - retbuf[j++] = c; + retbuf[j++] = Py_hexdigits[c]; c = argbuf[i] & 0xf; - c = (c>9) ? c+'a'-10 : c + '0'; - retbuf[j++] = c; + retbuf[j++] = Py_hexdigits[c]; } PyBuffer_Release(&parg); return retval; |