summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenjamin Peterson <benjamin@python.org>2009-05-05 22:31:58 +0000
committerBenjamin Peterson <benjamin@python.org>2009-05-05 22:31:58 +0000
commitb173f7853e4e3a4215a661d98174291e379cf6fb (patch)
tree02735987f20fc27277a82c14c5da5e043cc134aa /Include/py_curses.h
parentMerged revisions 72361 via svnmerge from (diff)
downloadcpython-b173f7853e4e3a4215a661d98174291e379cf6fb.tar.gz
cpython-b173f7853e4e3a4215a661d98174291e379cf6fb.tar.bz2
cpython-b173f7853e4e3a4215a661d98174291e379cf6fb.zip
add a replacement API for PyCObject, PyCapsule #5630
All stdlib modules with C-APIs now use this. Patch by Larry Hastings
Diffstat (limited to 'Include/py_curses.h')
-rw-r--r--Include/py_curses.h15
1 files changed, 5 insertions, 10 deletions
diff --git a/Include/py_curses.h b/Include/py_curses.h
index b4ad8f7f14a..ae7b12b685c 100644
--- a/Include/py_curses.h
+++ b/Include/py_curses.h
@@ -75,6 +75,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 */
@@ -89,16 +92,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 */