Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

gh-134208: remove dead AC directives for_curses.window.{chgat,getstr,instr}#134325

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
picnixz wants to merge4 commits intopython:main
base:main
Choose a base branch
Loading
frompicnixz:fix/curses/better-clinic-134208
Open
Changes from1 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
PrevPrevious commit
NextNext commit
remove dead Argument Clinic for_curses.window.getstr
  • Loading branch information
@picnixz
picnixz committedMay 20, 2025
commita670d5417a110e09c2bef19eddb345c5e44dfc06
93 changes: 35 additions & 58 deletionsModules/_cursesmodule.c
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -1843,77 +1843,51 @@ curses_clinic_parse_optional_xy_n(PyObject *args,
}
}

[
y: int
Y-coordinate.
x: int
X-coordinate.
]
n: int = 1023
Maximal number of characters.
/

Read a string from the user, with primitive line editing capacity.
[-clinic start generated code]*/
PyDoc_STRVAR(_curses_window_getstr__doc__,
"getstr([[y, x,] n=1023])\n"
"Read a string from the user, with primitive line editing capacity.\n"
"\n"
" y\n"
" Y-coordinate.\n"
" x\n"
" X-coordinate.\n"
" n\n"
" Maximal number of characters.");

static PyObject *
PyCursesWindow_GetStr(PyObject *op, PyObject *args)
PyCursesWindow_getstr(PyObject *op, PyObject *args)
{
PyCursesWindowObject *self = _PyCursesWindowObject_CAST(op);

intx, y, n;
int use_xy = 0, y = 0, x = 0;
unsignedintn = 1023;
char rtn[1024]; /* This should be big enough.. I hope */
int rtn2;

switch (PyTuple_Size(args)) {
case 0:
Py_BEGIN_ALLOW_THREADS
rtn2 = wgetnstr(self->win,rtn, 1023);
Py_END_ALLOW_THREADS
break;
case 1:
if (!PyArg_ParseTuple(args,"i;n", &n))
return NULL;
if (n < 0) {
PyErr_SetString(PyExc_ValueError, "'n' must be nonnegative");
return NULL;
}
Py_BEGIN_ALLOW_THREADS
rtn2 = wgetnstr(self->win, rtn, Py_MIN(n, 1023));
Py_END_ALLOW_THREADS
break;
case 2:
if (!PyArg_ParseTuple(args,"ii;y,x",&y,&x))
return NULL;
if (!curses_clinic_parse_optional_xy_n(args, &y, &x, &n, &use_xy,
"_curses.window.getstr"))
{
return NULL;
}

n = Py_MIN(n, 1023);
if (use_xy) {
Py_BEGIN_ALLOW_THREADS
#ifdef STRICT_SYSV_CURSES
rtn2 = wmove(self->win,y,x)==ERR ? ERR : wgetnstr(self->win, rtn, 1023);
if (wmove(self->win, y, x) == ERR) {
rtn2 = ERR;
}
else {
rtn2 = wgetnstr(self->win, rtn, n);
}
#else
rtn2 = mvwgetnstr(self->win,y,x,rtn,1023);
rtn2 = mvwgetnstr(self->win, y, x,rtn,n);
#endif
Py_END_ALLOW_THREADS
break;
case 3:
if (!PyArg_ParseTuple(args,"iii;y,x,n", &y, &x, &n))
return NULL;
if (n < 0) {
PyErr_SetString(PyExc_ValueError, "'n' must be nonnegative");
return NULL;
}
#ifdef STRICT_SYSV_CURSES
Py_BEGIN_ALLOW_THREADS
rtn2 = wmove(self->win,y,x)==ERR ? ERR :
wgetnstr(self->win, rtn, Py_MIN(n, 1023));
Py_END_ALLOW_THREADS
#else
}
else {
Py_BEGIN_ALLOW_THREADS
rtn2 =mvwgetnstr(self->win,y, x,rtn,Py_MIN(n, 1023));
rtn2 =wgetnstr(self->win, rtn,n);
Py_END_ALLOW_THREADS
#endif
break;
default:
PyErr_SetString(PyExc_TypeError, "getstr requires 0 to 3 arguments");
return NULL;
}
if (rtn2 == ERR)
rtn[0] = 0;
Expand DownExpand Up@@ -2877,7 +2851,10 @@ static PyMethodDef PyCursesWindow_methods[] = {
_CURSES_WINDOW_GET_WCH_METHODDEF
{"getmaxyx", PyCursesWindow_getmaxyx, METH_NOARGS},
{"getparyx", PyCursesWindow_getparyx, METH_NOARGS},
{"getstr", PyCursesWindow_GetStr, METH_VARARGS},
{
"getstr", PyCursesWindow_getstr, METH_VARARGS,
_curses_window_getstr__doc__
},
{"getyx", PyCursesWindow_getyx, METH_NOARGS},
_CURSES_WINDOW_HLINE_METHODDEF
{"idcok", PyCursesWindow_idcok, METH_VARARGS},
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp