8000 gh-103092: Prep curses module for multi-phase init by koubaa · Pull Request #23091 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

gh-103092: Prep curses module for multi-phase init #23091

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

Closed
wants to merge 3 commits into from
Closed
Changes from 1 commit
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
Prev Previous commit
remove PyImport_ImportModuleNoBlock
  • Loading branch information
koubaa committed Feb 28, 2021
commit 0dc705bf04d8c83d9d585c981655d6cf9c00bc8c
18 changes: 3 additions & 15 deletions Modules/_cursesmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -3965,8 +3965,6 @@ _curses_qiflush_impl(PyObject *module, int flag)
static int
update_lines_cols(PyObject *module)
{
PyObject *o;
PyObject *m = PyImport_ImportModuleNoBlock("curses");
_Py_IDENTIFIER(LINES);
_Py_IDENTIFIER(COLS);

Expand All @@ -3975,43 +3973,33 @@ update_lines_cols(PyObject *module)
return 0;
}

if (!m)
return 0;

o = PyLong_FromLong(LINES);
PyObject *o = PyLong_FromLong(LINES);
if (!o) {
Py_DECREF(m);
return 0;
}
if (_PyObject_SetAttrId(m, &PyId_LINES, o)) {
Py_DECREF(m);
if (_PyObject_SetAttrId(module, &PyId_LINES, o)) {
Py_DECREF(o);
return 0;
}
/* PyId_LINES.object will be initialized here. */
if (PyDict_SetItem(d, _PyUnicode_FromId(&PyId_LINES), o)) {
Py_DECREF(m);
Py_DECREF(o);
return 0;
}
Py_DECREF(o);
o = PyLong_FromLong(COLS);
if (!o) {
Py_DECREF(m);
return 0;
}
if (_PyObject_SetAttrId(m, &PyId_COLS, o)) {
Py_DECREF(m);
if (_PyObject_SetAttrId(module, &PyId_COLS, o)) {
Py_DECREF(o);
return 0;
}
if (PyDict_SetItem(d, _PyUnicode_FromId(&PyId_COLS), o)) {
Py_DECREF(m);
Py_DECREF(o);
return 0;
}
Py_DECREF(o);
Py_DECREF(m);
return 1;
}

Expand Down
0