diff options
author | Thomas Heller <theller@ctypes.org> | 2008-06-10 15:26:58 (GMT) |
---|---|---|
committer | Thomas Heller <theller@ctypes.org> | 2008-06-10 15:26:58 (GMT) |
commit | b795f528b2487a5dea5d4fb055dfe18c1f2f43fd (patch) | |
tree | aa4557c4e1d56405e3c86732c85dcfbc6397ac68 /Modules | |
parent | c5d012694b7a357f7e6a7b5ce445f8147efbd3c2 (diff) | |
download | cpython-b795f528b2487a5dea5d4fb055dfe18c1f2f43fd.zip cpython-b795f528b2487a5dea5d4fb055dfe18c1f2f43fd.tar.gz cpython-b795f528b2487a5dea5d4fb055dfe18c1f2f43fd.tar.bz2 |
Merged revisions 63988,63991 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r63988 | thomas.heller | 2008-06-06 20:37:55 +0200 (Fr, 06 Jun 2008) | 3 lines
Performance improvement: Use PyDict_Get/SetItem instead of
PyDict_Get/SetItemString.
........
r63991 | thomas.heller | 2008-06-06 22:05:15 +0200 (Fr, 06 Jun 2008) | 5 lines
Document the new ctypes features.
It would be great if someone could review both sematics, markup, and
spelling, and correct the versionadded and versionchanges markers.
........
Diffstat (limited to 'Modules')
-rw-r--r-- | Modules/_ctypes/callproc.c | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/Modules/_ctypes/callproc.c b/Modules/_ctypes/callproc.c index 5fa6336..47cc567 100644 --- a/Modules/_ctypes/callproc.c +++ b/Modules/_ctypes/callproc.c @@ -117,12 +117,18 @@ get_error_object(int **pspace) { PyObject *dict = PyThreadState_GetDict(); PyObject *errobj; + static PyObject *error_object_name; if (dict == 0) { PyErr_SetString(PyExc_RuntimeError, "cannot get thread state"); return NULL; } - errobj = PyDict_GetItemString(dict, "ctypes.error_object"); + if (error_object_name == NULL) { + error_object_name = PyString_InternFromString("ctypes.error_object"); + if (error_object_name == NULL) + return NULL; + } + errobj = PyDict_GetItem(dict, error_object_name); if (errobj) Py_INCREF(errobj); else { @@ -133,8 +139,8 @@ get_error_object(int **pspace) errobj = PyCObject_FromVoidPtr(space, PyMem_Free); if (errobj == NULL) return NULL; - if (-1 == PyDict_SetItemString(dict, "ctypes.error_object", - errobj)) { + if (-1 == PyDict_SetItem(dict, error_object_name, + errobj)) { Py_DECREF(errobj); return NULL; } |