Skip to content

Commit ce35192

Browse files
committed
gh-139122: Use shared hex conversion helper for UUID.hex
1 parent 95b8544 commit ce35192

1 file changed

Lines changed: 2 additions & 5 deletions

File tree

‎Modules/_uuidmodule.c‎

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#include "pycore_long.h" // _PyLong_AsByteArray(), _PyLong_GetOne()
2020
#include "pycore_pylifecycle.h" // _PyOS_URandom()
2121
#include "pycore_runtime_init.h" // _Py_ID()
22+
#include "pycore_strhex.h" // _Py_strhex()
2223

2324
#if defined(HAVE_UUID_H)
2425
// AIX, FreeBSD, libuuid with pkgconf
@@ -1120,11 +1121,7 @@ static PyObject *
11201121
Uuid_get_hex(PyObject *op, void *Py_UNUSED(closure))
11211122
{
11221123
uuidobject *self = uuidobject_CAST(op);
1123-
char hex[UUID_SIZE * 2];
1124-
for (int i = 0; i < UUID_SIZE; i++) {
1125-
byte_to_hex(self->bytes[i], &hex[i * 2]);
1126-
}
1127-
return PyUnicode_FromStringAndSize(hex, sizeof(hex));
1124+
return _Py_strhex((const char *)self->bytes, sizeof(self->bytes));
11281125
}
11291126

11301127
static PyObject *

0 commit comments

Comments
 (0)