summaryrefslogtreecommitdiffstats
path: root/Python
diff options
context:
space:
mode:
authorBenjamin Peterson <benjamin@python.org>2012-01-22 16:24:29 (GMT)
committerBenjamin Peterson <benjamin@python.org>2012-01-22 16:24:29 (GMT)
commitce798520778e9cb41adfdc4f0a3cb5085a0b11be (patch)
tree915ea477cc6dfaa170d851f0c54f72b07c544874 /Python
parentcd8991255c963858cc74f32d718e1d54987b26a0 (diff)
downloadcpython-ce798520778e9cb41adfdc4f0a3cb5085a0b11be.zip
cpython-ce798520778e9cb41adfdc4f0a3cb5085a0b11be.tar.gz
cpython-ce798520778e9cb41adfdc4f0a3cb5085a0b11be.tar.bz2
use the static identifier api for looking up special methods
I had to move the static identifier code from unicodeobject.h to object.h in order for this to work.
Diffstat (limited to 'Python')
-rw-r--r--Python/ceval.c15
-rw-r--r--Python/sysmodule.c6
2 files changed, 11 insertions, 10 deletions
diff --git a/Python/ceval.c b/Python/ceval.c
index e2d96c5..06bff4c 100644
--- a/Python/ceval.c
+++ b/Python/ceval.c
@@ -138,7 +138,7 @@ static void format_exc_check_arg(PyObject *, const char *, PyObject *);
static void format_exc_unbound(PyCodeObject *co, int oparg);
static PyObject * unicode_concatenate(PyObject *, PyObject *,
PyFrameObject *, unsigned char *);
-static PyObject * special_lookup(PyObject *, char *, PyObject **);
+static PyObject * special_lookup(PyObject *, _Py_Identifier *);
#define NAME_ERROR_MSG \
"name '%.200s' is not defined"
@@ -2540,13 +2540,14 @@ PyEval_EvalFrameEx(PyFrameObject *f, int throwflag)
TARGET(SETUP_WITH)
{
- static PyObject *exit, *enter;
+ _Py_IDENTIFIER(__exit__);
+ _Py_IDENTIFIER(__enter__);
w = TOP();
- x = special_lookup(w, "__exit__", &exit);
+ x = special_lookup(w, &PyId___exit__);
if (!x)
break;
SET_TOP(x);
- u = special_lookup(w, "__enter__", &enter);
+ u = special_lookup(w, &PyId___enter__);
Py_DECREF(w);
if (!u) {
x = NULL;
@@ -3440,12 +3441,12 @@ fail: /* Jump here from prelude on failure */
static PyObject *
-special_lookup(PyObject *o, char *meth, PyObject **cache)
+special_lookup(PyObject *o, _Py_Identifier *id)
{
PyObject *res;
- res = _PyObject_LookupSpecial(o, meth, cache);
+ res = _PyObject_LookupSpecial(o, id);
if (res == NULL && !PyErr_Occurred()) {
- PyErr_SetObject(PyExc_AttributeError, *cache);
+ PyErr_SetObject(PyExc_AttributeError, id->object);
return NULL;
}
return res;
diff --git a/Python/sysmodule.c b/Python/sysmodule.c
index ab0008e..d1517d3 100644
--- a/Python/sysmodule.c
+++ b/Python/sysmodule.c
@@ -814,10 +814,11 @@ static PyObject *
sys_getsizeof(PyObject *self, PyObject *args, PyObject *kwds)
{
PyObject *res = NULL;
- static PyObject *str__sizeof__ = NULL, *gc_head_size = NULL;
+ static PyObject *gc_head_size = NULL;
static char *kwlist[] = {"object", "default", 0};
PyObject *o, *dflt = NULL;
PyObject *method;
+ _Py_IDENTIFIER(__sizeof__);
if (!PyArg_ParseTupleAndKeywords(args, kwds, "O|O:getsizeof",
kwlist, &o, &dflt))
@@ -834,8 +835,7 @@ sys_getsizeof(PyObject *self, PyObject *args, PyObject *kwds)
if (PyType_Ready(Py_TYPE(o)) < 0)
return NULL;
- method = _PyObject_LookupSpecial(o, "__sizeof__",
- &str__sizeof__);
+ method = _PyObject_LookupSpecial(o, &PyId___sizeof__);
if (method == NULL) {
if (!PyErr_Occurred())
PyErr_Format(PyExc_TypeError,