mirror of
https://github.com/python/cpython.git
synced 2025-09-26 18:29:57 +00:00
Issue #14936: curses_panel was converted to PEP 3121 API.
Patch by Robin Schreiber.
This commit is contained in:
parent
474eb23b7f
commit
c838ec1f82
2 changed files with 45 additions and 12 deletions
|
@ -21,6 +21,9 @@ Core and Builtins
|
||||||
Library
|
Library
|
||||||
-------
|
-------
|
||||||
|
|
||||||
|
- Issue #14936: curses_panel was converted to PEP 3121 API.
|
||||||
|
Patch by Robin Schreiber.
|
||||||
|
|
||||||
- Issue #1667546: On platforms supporting tm_zone and tm_gmtoff fields
|
- Issue #1667546: On platforms supporting tm_zone and tm_gmtoff fields
|
||||||
in struct tm, time.struct_time objects returned by time.gmtime(),
|
in struct tm, time.struct_time objects returned by time.gmtime(),
|
||||||
time.localtime() and time.strptime() functions now have tm_zone and
|
time.localtime() and time.strptime() functions now have tm_zone and
|
||||||
|
|
|
@ -16,8 +16,38 @@ static char *PyCursesVersion = "2.1";
|
||||||
|
|
||||||
#include <panel.h>
|
#include <panel.h>
|
||||||
|
|
||||||
static PyObject *PyCursesError;
|
typedef struct {
|
||||||
|
PyObject *PyCursesError;
|
||||||
|
} _curses_panelstate;
|
||||||
|
|
||||||
|
#define _curses_panelstate(o) ((_curses_panelstate *)PyModule_GetState(o))
|
||||||
|
|
||||||
|
/*static PyObject *PyCursesError;*/
|
||||||
|
|
||||||
|
static int
|
||||||
|
_curses_panel_clear(PyObject *m)
|
||||||
|
{
|
||||||
|
Py_CLEAR(_curses_panelstate(m)->PyCursesError);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
_curses_panel_traverse(PyObject *m, visitproc visit, void *arg)
|
||||||
|
{
|
||||||
|
Py_VISIT(_curses_panelstate(m)->PyCursesError);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_curses_panel_free(void *m)
|
||||||
|
{
|
||||||
|
_curses_panel_clear((PyObject *) m);
|
||||||
|
}
|
||||||
|
|
||||||
|
static struct PyModuleDef _curses_panelmodule;
|
||||||
|
|
||||||
|
#define _curses_panelstate_global \
|
||||||
|
((_curses_panelstate *) PyModule_GetState(PyState_FindModule(&_curses_panelmodule)))
|
||||||
|
|
||||||
/* Utility Functions */
|
/* Utility Functions */
|
||||||
|
|
||||||
|
@ -34,9 +64,9 @@ PyCursesCheckERR(int code, char *fname)
|
||||||
return Py_None;
|
return Py_None;
|
||||||
} else {
|
} else {
|
||||||
if (fname == NULL) {
|
if (fname == NULL) {
|
||||||
PyErr_SetString(PyCursesError, catchall_ERR);
|
PyErr_SetString(_curses_panelstate_global->PyCursesError, catchall_ERR);
|
||||||
} else {
|
} else {
|
||||||
PyErr_Format(PyCursesError, "%s() returned ERR", fname);
|
PyErr_Format(_curses_panelstate_global->PyCursesError, "%s() returned ERR", fname);
|
||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -280,7 +310,7 @@ PyCursesPanel_replace_panel(PyCursesPanelObject *self, PyObject *args)
|
||||||
|
|
||||||
rtn = replace_panel(self->pan, temp->win);
|
rtn = replace_panel(self->pan, temp->win);
|
||||||
if (rtn == ERR) {
|
if (rtn == ERR) {
|
||||||
PyErr_SetString(PyCursesError, "replace_panel() returned ERR");
|
PyErr_SetString(_curses_panelstate_global->PyCursesError, "replace_panel() returned ERR");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
Py_DECREF(po->wo);
|
Py_DECREF(po->wo);
|
||||||
|
@ -305,7 +335,7 @@ PyCursesPanel_userptr(PyCursesPanelObject *self)
|
||||||
PyCursesInitialised;
|
PyCursesInitialised;
|
||||||
obj = (PyObject *) panel_userptr(self->pan);
|
obj = (PyObject *) panel_userptr(self->pan);
|
||||||
if (obj == NULL) {
|
if (obj == NULL) {
|
||||||
PyErr_SetString(PyCursesError, "no userptr set");
|
PyErr_SetString(_curses_panelstate_global->PyCursesError, "no userptr set");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -405,7 +435,7 @@ PyCurses_new_panel(PyObject *self, PyObject *args)
|
||||||
return NULL;
|
return NULL;
|
||||||
pan = new_panel(win->win);
|
pan = new_panel(win->win);
|
||||||
if (pan == NULL) {
|
if (pan == NULL) {
|
||||||
PyErr_SetString(PyCursesError, catchall_NULL);
|
PyErr_SetString(_curses_panelstate_global->PyCursesError, catchall_NULL);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
return (PyObject *)PyCursesPanel_New(pan, win);
|
return (PyObject *)PyCursesPanel_New(pan, win);
|
||||||
|
@ -467,12 +497,12 @@ static struct PyModuleDef _curses_panelmodule = {
|
||||||
PyModuleDef_HEAD_INIT,
|
PyModuleDef_HEAD_INIT,
|
||||||
"_curses_panel",
|
"_curses_panel",
|
||||||
NULL,
|
NULL,
|
||||||
-1,
|
sizeof(_curses_panelstate),
|
||||||
PyCurses_methods,
|
PyCurses_methods,
|
||||||
NULL,
|
NULL,
|
||||||
NULL,
|
_curses_panel_traverse,
|
||||||
NULL,
|
_curses_panel_clear,
|
||||||
NULL
|
_curses_panel_free
|
||||||
};
|
};
|
||||||
|
|
||||||
PyMODINIT_FUNC
|
PyMODINIT_FUNC
|
||||||
|
@ -493,8 +523,8 @@ PyInit__curses_panel(void)
|
||||||
d = PyModule_GetDict(m);
|
d = PyModule_GetDict(m);
|
||||||
|
|
||||||
/* For exception _curses_panel.error */
|
/* For exception _curses_panel.error */
|
||||||
PyCursesError = PyErr_NewException("_curses_panel.error", NULL, NULL);
|
_curses_panelstate(m)->PyCursesError = PyErr_NewException("_curses_panel.error", NULL, NULL);
|
||||||
PyDict_SetItemString(d, "error", PyCursesError);
|
PyDict_SetItemString(d, "error", _curses_panelstate(m)->PyCursesError);
|
||||||
|
|
||||||
/* Make the version available */
|
/* Make the version available */
|
||||||
v = PyUnicode_FromString(PyCursesVersion);
|
v = PyUnicode_FromString(PyCursesVersion);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue