mirror of
https://github.com/python/cpython.git
synced 2025-08-04 08:59:19 +00:00
Issue #13088: Add shared Py_hexdigits constant to format a number into base 16
This commit is contained in:
parent
e506437b52
commit
f5cff56a1b
16 changed files with 118 additions and 135 deletions
|
@ -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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue