Skip to content

Commit 0a806f2

Browse files
GH-90699: Remove _Py_IDENTIFIER usage from _curses module (GH-98957)
1 parent 6d683d8 commit 0a806f2

File tree

1 file changed

+6
-12
lines changed

1 file changed

+6
-12
lines changed

Diff for: Modules/_cursesmodule.c

+6-12
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,6 @@ static const char PyCursesVersion[] = "2.2";
103103
#ifndef Py_BUILD_CORE_BUILTIN
104104
# define Py_BUILD_CORE_MODULE 1
105105
#endif
106-
#define NEEDS_PY_IDENTIFIER
107106

108107
#define PY_SSIZE_T_CLEAN
109108

@@ -2177,12 +2176,11 @@ _curses_window_putwin(PyCursesWindowObject *self, PyObject *file)
21772176
while (1) {
21782177
char buf[BUFSIZ];
21792178
Py_ssize_t n = fread(buf, 1, BUFSIZ, fp);
2180-
_Py_IDENTIFIER(write);
21812179

21822180
if (n <= 0)
21832181
break;
21842182
Py_DECREF(res);
2185-
res = _PyObject_CallMethodId(file, &PyId_write, "y#", buf, n);
2183+
res = PyObject_CallMethod(file, "write", "y#", buf, n);
21862184
if (res == NULL)
21872185
break;
21882186
}
@@ -3051,7 +3049,6 @@ _curses_getwin(PyObject *module, PyObject *file)
30513049
PyObject *data;
30523050
size_t datalen;
30533051
WINDOW *win;
3054-
_Py_IDENTIFIER(read);
30553052
PyObject *res = NULL;
30563053

30573054
PyCursesInitialised;
@@ -3063,7 +3060,7 @@ _curses_getwin(PyObject *module, PyObject *file)
30633060
if (_Py_set_inheritable(fileno(fp), 0, NULL) < 0)
30643061
goto error;
30653062

3066-
data = _PyObject_CallMethodIdNoArgs(file, &PyId_read);
3063+
data = PyObject_CallMethod(file, "read", NULL);
30673064
if (data == NULL)
30683065
goto error;
30693066
if (!PyBytes_Check(data)) {
@@ -3962,8 +3959,6 @@ update_lines_cols(void)
39623959
{
39633960
PyObject *o;
39643961
PyObject *m = PyImport_ImportModule("curses");
3965-
_Py_IDENTIFIER(LINES);
3966-
_Py_IDENTIFIER(COLS);
39673962

39683963
if (!m)
39693964
return 0;
@@ -3973,13 +3968,12 @@ update_lines_cols(void)
39733968
Py_DECREF(m);
39743969
return 0;
39753970
}
3976-
if (_PyObject_SetAttrId(m, &PyId_LINES, o)) {
3971+
if (PyObject_SetAttrString(m, "LINES", o)) {
39773972
Py_DECREF(m);
39783973
Py_DECREF(o);
39793974
return 0;
39803975
}
3981-
/* PyId_LINES.object will be initialized here. */
3982-
if (PyDict_SetItem(ModDict, _PyUnicode_FromId(&PyId_LINES), o)) {
3976+
if (PyDict_SetItemString(ModDict, "LINES", o)) {
39833977
Py_DECREF(m);
39843978
Py_DECREF(o);
39853979
return 0;
@@ -3990,12 +3984,12 @@ update_lines_cols(void)
39903984
Py_DECREF(m);
39913985
return 0;
39923986
}
3993-
if (_PyObject_SetAttrId(m, &PyId_COLS, o)) {
3987+
if (PyObject_SetAttrString(m, "COLS", o)) {
39943988
Py_DECREF(m);
39953989
Py_DECREF(o);
39963990
return 0;
39973991
}
3998-
if (PyDict_SetItem(ModDict, _PyUnicode_FromId(&PyId_COLS), o)) {
3992+
if (PyDict_SetItemString(ModDict, "COLS", o)) {
39993993
Py_DECREF(m);
40003994
Py_DECREF(o);
40013995
return 0;

0 commit comments

Comments
 (0)