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/_pickle.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/_pickle.c')
-rw-r--r-- | Modules/_pickle.c | 25 |
1 files changed, 12 insertions, 13 deletions
diff --git a/Modules/_pickle.c b/Modules/_pickle.c index 6a44b82..ad185a7 100644 --- a/Modules/_pickle.c +++ b/Modules/_pickle.c @@ -1776,7 +1776,6 @@ save_bytes(PicklerObject *self, PyObject *obj) static PyObject * raw_unicode_escape(PyObject *obj) { - static const char *hexdigits = "0123456789abcdef"; PyObject *repr, *result; char *p; Py_ssize_t i, size, expandsize; @@ -1809,23 +1808,23 @@ raw_unicode_escape(PyObject *obj) if (ch >= 0x10000) { *p++ = '\\'; *p++ = 'U'; - *p++ = hexdigits[(ch >> 28) & 0xf]; - *p++ = hexdigits[(ch >> 24) & 0xf]; - *p++ = hexdigits[(ch >> 20) & 0xf]; - *p++ = hexdigits[(ch >> 16) & 0xf]; - *p++ = hexdigits[(ch >> 12) & 0xf]; - *p++ = hexdigits[(ch >> 8) & 0xf]; - *p++ = hexdigits[(ch >> 4) & 0xf]; - *p++ = hexdigits[ch & 15]; + *p++ = Py_hexdigits[(ch >> 28) & 0xf]; + *p++ = Py_hexdigits[(ch >> 24) & 0xf]; + *p++ = Py_hexdigits[(ch >> 20) & 0xf]; + *p++ = Py_hexdigits[(ch >> 16) & 0xf]; + *p++ = Py_hexdigits[(ch >> 12) & 0xf]; + *p++ = Py_hexdigits[(ch >> 8) & 0xf]; + *p++ = Py_hexdigits[(ch >> 4) & 0xf]; + *p++ = Py_hexdigits[ch & 15]; } /* Map 16-bit characters to '\uxxxx' */ else if (ch >= 256 || ch == '\\' || ch == '\n') { *p++ = '\\'; *p++ = 'u'; - *p++ = hexdigits[(ch >> 12) & 0xf]; - *p++ = hexdigits[(ch >> 8) & 0xf]; - *p++ = hexdigits[(ch >> 4) & 0xf]; - *p++ = hexdigits[ch & 15]; + *p++ = Py_hexdigits[(ch >> 12) & 0xf]; + *p++ = Py_hexdigits[(ch >> 8) & 0xf]; + *p++ = Py_hexdigits[(ch >> 4) & 0xf]; + *p++ = Py_hexdigits[ch & 15]; } /* Copy everything else as-is */ else |