diff options
author | Martin v. Löwis <martin@v.loewis.de> | 2011-10-14 13:16:45 (GMT) |
---|---|---|
committer | Martin v. Löwis <martin@v.loewis.de> | 2011-10-14 13:16:45 (GMT) |
commit | 1c67dd9b154d57baf58ed081767e199af1e84923 (patch) | |
tree | 0d6c95e99785f9b8381c808a5cb433adf319eda5 /Parser/asdl_c.py | |
parent | bd928fef428e48084ff29ece0e21d07ad86d0793 (diff) | |
download | cpython-1c67dd9b154d57baf58ed081767e199af1e84923.zip cpython-1c67dd9b154d57baf58ed081767e199af1e84923.tar.gz cpython-1c67dd9b154d57baf58ed081767e199af1e84923.tar.bz2 |
Port SetAttrString/HasAttrString to SetAttrId/GetAttrId.
Diffstat (limited to 'Parser/asdl_c.py')
-rwxr-xr-x | Parser/asdl_c.py | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/Parser/asdl_c.py b/Parser/asdl_c.py index 5501ebc..deff06d 100755 --- a/Parser/asdl_c.py +++ b/Parser/asdl_c.py @@ -747,6 +747,7 @@ static PyTypeObject* make_type(char *type, PyTypeObject* base, char**fields, int static int add_attributes(PyTypeObject* type, char**attrs, int num_fields) { int i, result; + _Py_IDENTIFIER(_attributes); PyObject *s, *l = PyTuple_New(num_fields); if (!l) return 0; @@ -758,7 +759,7 @@ static int add_attributes(PyTypeObject* type, char**attrs, int num_fields) } PyTuple_SET_ITEM(l, i, s); } - result = PyObject_SetAttrString((PyObject*)type, "_attributes", l) >= 0; + result = _PyObject_SetAttrId((PyObject*)type, &PyId__attributes, l) >= 0; Py_DECREF(l); return result; } @@ -1024,7 +1025,7 @@ class ObjVisitor(PickleVisitor): for a in sum.attributes: self.emit("value = ast2obj_%s(o->%s);" % (a.type, a.name), 1) self.emit("if (!value) goto failed;", 1) - self.emit('if (PyObject_SetAttrString(result, "%s", value) < 0)' % a.name, 1) + self.emit('if (_PyObject_SetAttrId(result, &PyId_%s, value) < 0)' % a.name, 1) self.emit('goto failed;', 2) self.emit('Py_DECREF(value);', 1) self.func_end() @@ -1070,7 +1071,7 @@ class ObjVisitor(PickleVisitor): value = "o->v.%s.%s" % (name, field.name) self.set(field, value, depth) emit("if (!value) goto failed;", 0) - emit('if (PyObject_SetAttrString(result, "%s", value) == -1)' % field.name, 0) + emit('if (_PyObject_SetAttrId(result, &PyId_%s, value) == -1)' % field.name, 0) emit("goto failed;", 1) emit("Py_DECREF(value);", 0) |