Skip to content

Commit a6a31cf

Browse files
committed
Workaround lack of _Py_ID in CPython 3.10.x
1 parent 6ae7665 commit a6a31cf

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

Modules/pyexpat.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,9 +109,11 @@ static struct HandlerInfo handler_info[64];
109109
static int
110110
set_xml_error_attr_code(PyObject *err, enum XML_Error code)
111111
{
112+
PyObject *py_id_code = PyUnicode_InternFromString("code");
112113
PyObject *v = PyLong_FromLong((long)code);
113-
int ok = v != NULL && PyObject_SetAttr(err, &_Py_ID(code), v) != -1;
114+
int ok = v != NULL && PyObject_SetAttr(err, py_id_code, v) != -1;
114115
Py_XDECREF(v);
116+
Py_XDECREF(py_id_code);
115117
return ok;
116118
}
117119

0 commit comments

Comments
 (0)