-#define NEEDS_PY_IDENTIFIER
-
#include "Python.h"
#include <ctype.h>
typedef struct {
PyTypeObject *xml_parse_type;
PyObject *error;
+ PyObject *str_read;
} pyexpat_state;
static inline pyexpat_state*
{
int rv = 1;
PyObject *readmethod = NULL;
- _Py_IDENTIFIER(read);
pyexpat_state *state = PyType_GetModuleState(cls);
- if (_PyObject_LookupAttrId(file, &PyId_read, &readmethod) < 0) {
+ if (_PyObject_LookupAttr(file, state->str_read, &readmethod) < 0) {
return NULL;
}
if (readmethod == NULL) {
pyexpat_exec(PyObject *mod)
{
pyexpat_state *state = pyexpat_get_state(mod);
+ state->str_read = PyUnicode_InternFromString("read");
+ if (state->str_read == NULL) {
+ return -1;
+ }
state->xml_parse_type = (PyTypeObject *)PyType_FromModuleAndSpec(
mod, &_xml_parse_type_spec, NULL);
pyexpat_state *state = pyexpat_get_state(module);
Py_VISIT(state->xml_parse_type);
Py_VISIT(state->error);
+ Py_VISIT(state->str_read);
return 0;
}
pyexpat_state *state = pyexpat_get_state(module);
Py_CLEAR(state->xml_parse_type);
Py_CLEAR(state->error);
+ Py_CLEAR(state->str_read);
return 0;
}