From 943ce12dfd6ed7b9250a65bd09311d8c7b370767 Mon Sep 17 00:00:00 2001 From: Jon Parise Date: Tue, 4 Oct 2022 14:14:04 -0700 Subject: [PATCH] Add an implementation of _PyType_Name for Python 3.6 This function was introduced in Python 3.7 (https://bugs.python.org/issue31497). --- asyncpg/protocol/record/recordobj.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/asyncpg/protocol/record/recordobj.c b/asyncpg/protocol/record/recordobj.c index 180fc141..e3ba77a3 100644 --- a/asyncpg/protocol/record/recordobj.c +++ b/asyncpg/protocol/record/recordobj.c @@ -14,6 +14,21 @@ # define _ApgObject_GC_IS_TRACKED PyObject_GC_IsTracked #endif +#if PY_VERSION_HEX < 0x03070000 +static const char * _PyType_Name(PyTypeObject *type) +{ + assert(type->tp_name != NULL); + const char *s = strrchr(type->tp_name, '.'); + if (s == NULL) { + s = type->tp_name; + } + else { + s++; + } + return s; +} +#endif + static PyObject * record_iter(PyObject *); static PyObject * record_new_items_iter(PyObject *);