diff options
author | Larry Hastings <larry@hastings.org> | 2010-03-25 00:54:54 (GMT) |
---|---|---|
committer | Larry Hastings <larry@hastings.org> | 2010-03-25 00:54:54 (GMT) |
commit | 402b73fb8d54ec2b24b52fdd77d389d903fa6c44 (patch) | |
tree | ced928b7f7dce754142742e485ed8e836fbc9486 /Include/py_curses.h | |
parent | 53ff86ea5f0ed27f5eb5b966faf59dac298d6672 (diff) | |
download | cpython-402b73fb8d54ec2b24b52fdd77d389d903fa6c44.zip cpython-402b73fb8d54ec2b24b52fdd77d389d903fa6c44.tar.gz cpython-402b73fb8d54ec2b24b52fdd77d389d903fa6c44.tar.bz2 |
Backported PyCapsule from 3.1, and converted most uses of
CObject to PyCapsule.
Diffstat (limited to 'Include/py_curses.h')
-rw-r--r-- | Include/py_curses.h | 15 |
1 files changed, 5 insertions, 10 deletions
diff --git a/Include/py_curses.h b/Include/py_curses.h index e4c0a6e..657816c 100644 --- a/Include/py_curses.h +++ b/Include/py_curses.h @@ -80,6 +80,9 @@ typedef struct { #define PyCursesWindow_Check(v) (Py_TYPE(v) == &PyCursesWindow_Type) +#define PyCurses_CAPSULE_NAME "_curses._C_API" + + #ifdef CURSES_MODULE /* This section is used when compiling _cursesmodule.c */ @@ -94,16 +97,8 @@ static void **PyCurses_API; #define PyCursesInitialisedColor {if (! ((int (*)(void))PyCurses_API[3]) () ) return NULL;} #define import_curses() \ -{ \ - PyObject *module = PyImport_ImportModuleNoBlock("_curses"); \ - if (module != NULL) { \ - PyObject *module_dict = PyModule_GetDict(module); \ - PyObject *c_api_object = PyDict_GetItemString(module_dict, "_C_API"); \ - if (PyCObject_Check(c_api_object)) { \ - PyCurses_API = (void **)PyCObject_AsVoidPtr(c_api_object); \ - } \ - } \ -} + PyCurses_API = (void **)PyCapsule_Import(PyCurses_CAPSULE_NAME, 1); + #endif /* general error messages */ |