8000 gh-109617: fix ncurses incompatibility on macOS with Xcode 15 by sorcio · Pull Request #111258 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

gh-109617: fix ncurses incompatibility on macOS with Xcode 15 #111258

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 11 commits into from
May 4, 2024
Prev Previous commit
Next Next commit
get ncurses_version at runtime from curses_version()
  • Loading branch information
sorcio committed Oct 11, 2023
commit bb2c852c59157b533bd57d192d068d2b0684a5cf
15 changes: 11 additions & 4 deletions Modules/_cursesmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -4570,17 +4570,24 @@ make_ncurses_version(PyTypeObject *type)
if (ncurses_version == NULL) {
return NULL;
}

const char *str = curses_version();
unsigned long major = 0, minor = 0, patch = 0;
if (!str || sscanf(str, "%*[^0-9]%lu.%lu.%lu", &major, &minor, &patch) < 3) {
// Fallback to header version, which cannot be that wrong
major = NCURSES_VERSION_MAJOR;
minor = NCURSES_VERSION_MINOR;
patch = NCURSES_VERSION_PATCH;
}
#define SetIntItem(flag) \
PyStructSequence_SET_ITEM(ncurses_version, pos++, PyLong_FromLong(flag)); \
if (PyErr_Occurred()) { \
Py_CLEAR(ncurses_version); \
return NULL; \
}

SetIntItem(NCURSES_VERSION_MAJOR)
SetIntItem(NCURSES_VERSION_MINOR)
SetIntItem(NCURSES_VERSION_PATCH)
SetIntItem(major)
SetIntItem(minor)
SetIntItem(patch)
#undef SetIntItem

return ncurses_version;
Expand Down
< 383F /div>
0