bpo-46541: Remove usage of _Py_IDENTIFIER from lzma module (GH-31683)

This commit is contained in:
Dong-hee Na 2022-03-05 01:38:56 +09:00 committed by GitHub
parent 586b24d3be
commit d168c728f7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 10 additions and 10 deletions

View File

@ -6,7 +6,6 @@
*/
#define PY_SSIZE_T_CLEAN
#define NEEDS_PY_IDENTIFIER
#include "Python.h"
#include "structmember.h" // PyMemberDef
@ -431,17 +430,19 @@ parse_filter_chain_spec(_lzma_state *state, lzma_filter filters[], PyObject *fil
Python-level filter specifiers (represented as dicts). */
static int
spec_add_field(PyObject *spec, _Py_Identifier *key, unsigned long long value)
spec_add_field(PyObject *spec, const char *key, unsigned long long value)
{
int status;
PyObject *value_object;
value_object = PyLong_FromUnsignedLongLong(value);
PyObject *value_object = PyLong_FromUnsignedLongLong(value);
if (value_object == NULL) {
return -1;
}
status = _PyDict_SetItemId(spec, key, value_object);
PyObject *key_object = PyUnicode_InternFromString(key);
if (key_object == NULL) {
Py_DECREF(value_object);
return -1;
}
int status = PyDict_SetItem(spec, key_object, value_object);
Py_DECREF(key_object);
Py_DECREF(value_object);
return status;
}
@ -458,8 +459,7 @@ build_filter_spec(const lzma_filter *f)
#define ADD_FIELD(SOURCE, FIELD) \
do { \
_Py_IDENTIFIER(FIELD); \
if (spec_add_field(spec, &PyId_##FIELD, SOURCE->FIELD) == -1) \
if (spec_add_field(spec, #FIELD, SOURCE->FIELD) == -1) \
goto error;\
} while (0)