Skip to content

bpo-46541: Remove usage of _Py_IDENTIFIER from lzma module #31683

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 4, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions Modules/_lzmamodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
*/

#define PY_SSIZE_T_CLEAN
#define NEEDS_PY_IDENTIFIER

#include "Python.h"
#include "structmember.h" // PyMemberDef
Expand Down Expand Up @@ -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;
}
Expand All @@ -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)

Expand Down