Skip to content

Commit d168c72

Browse files
authored
bpo-46541: Remove usage of _Py_IDENTIFIER from lzma module (GH-31683)
1 parent 586b24d commit d168c72

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

Modules/_lzmamodule.c

+10-10
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
*/
77

88
#define PY_SSIZE_T_CLEAN
9-
#define NEEDS_PY_IDENTIFIER
109

1110
#include "Python.h"
1211
#include "structmember.h" // PyMemberDef
@@ -431,17 +430,19 @@ parse_filter_chain_spec(_lzma_state *state, lzma_filter filters[], PyObject *fil
431430
Python-level filter specifiers (represented as dicts). */
432431

433432
static int
434-
spec_add_field(PyObject *spec, _Py_Identifier *key, unsigned long long value)
433+
spec_add_field(PyObject *spec, const char *key, unsigned long long value)
435434
{
436-
int status;
437-
PyObject *value_object;
438-
439-
value_object = PyLong_FromUnsignedLongLong(value);
435+
PyObject *value_object = PyLong_FromUnsignedLongLong(value);
440436
if (value_object == NULL) {
441437
return -1;
442438
}
443-
444-
status = _PyDict_SetItemId(spec, key, value_object);
439+
PyObject *key_object = PyUnicode_InternFromString(key);
440+
if (key_object == NULL) {
441+
Py_DECREF(value_object);
442+
return -1;
443+
}
444+
int status = PyDict_SetItem(spec, key_object, value_object);
445+
Py_DECREF(key_object);
445446
Py_DECREF(value_object);
446447
return status;
447448
}
@@ -458,8 +459,7 @@ build_filter_spec(const lzma_filter *f)
458459

459460
#define ADD_FIELD(SOURCE, FIELD) \
460461
do { \
461-
_Py_IDENTIFIER(FIELD); \
462-
if (spec_add_field(spec, &PyId_##FIELD, SOURCE->FIELD) == -1) \
462+
if (spec_add_field(spec, #FIELD, SOURCE->FIELD) == -1) \
463463
goto error;\
464464
} while (0)
465465

0 commit comments

Comments
 (0)