diff options
author | Dong-hee Na <donghee.na@python.org> | 2022-03-04 16:38:56 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-03-04 16:38:56 (GMT) |
commit | d168c728f7114959e8fc147538ea1d24f2f5af79 (patch) | |
tree | fee5a44fec8c0b867059d2b341d41753832c00b8 | |
parent | 586b24d3be1aec5d2568b070a249b4d75e608782 (diff) | |
download | cpython-d168c728f7114959e8fc147538ea1d24f2f5af79.zip cpython-d168c728f7114959e8fc147538ea1d24f2f5af79.tar.gz cpython-d168c728f7114959e8fc147538ea1d24f2f5af79.tar.bz2 |
bpo-46541: Remove usage of _Py_IDENTIFIER from lzma module (GH-31683)
-rw-r--r-- | Modules/_lzmamodule.c | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/Modules/_lzmamodule.c b/Modules/_lzmamodule.c index e3fc90e..b572d8c 100644 --- a/Modules/_lzmamodule.c +++ b/Modules/_lzmamodule.c @@ -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) |