Commit b7ffa456 authored by Kevin Modzelewski's avatar Kevin Modzelewski

Get delattr() working

parent 0604fb4f
......@@ -493,14 +493,16 @@ extern "C" int PyObject_GenericSetAttr(PyObject* obj, PyObject* name, PyObject*
}
BoxedString* str = static_cast<BoxedString*>(name);
incref(str);
internStringMortalInplace(str);
AUTO_DECREF(str);
assert(PyString_Check(name));
try {
if (value == NULL)
delattrGeneric(obj, str, NULL);
else
setattrGeneric<NOT_REWRITABLE>(obj, str, value, NULL);
setattrGeneric<NOT_REWRITABLE>(obj, str, incref(value), NULL);
} catch (ExcInfo e) {
setCAPIException(e);
return -1;
......@@ -1139,8 +1141,8 @@ extern "C" void _Py_NegativeRefcount(const char* fname, int lineno, PyObject* op
char buf[300];
PyOS_snprintf(buf, sizeof(buf), "%s:%i object at %p has negative ref count "
"%" PY_FORMAT_SIZE_T "d",
fname, lineno, op, op->ob_refcnt);
"%" PY_FORMAT_SIZE_T "d. \033[40mwatch -l *(long*)%p\033[0m",
fname, lineno, op, op->ob_refcnt, &op->ob_refcnt);
Py_FatalError(buf);
}
......
......@@ -511,13 +511,15 @@ Box* bltinImport(Box* name, Box* globals, Box* locals, Box** args) {
}
Box* delattrFunc(Box* obj, Box* _str) {
assert(0 && "check refcounting");
_str = coerceUnicodeToStr<CXX>(_str);
if (_str->cls != str_cls)
if (_str->cls != str_cls) {
Py_DECREF(_str);
raiseExcHelper(TypeError, "attribute name must be string, not '%s'", getTypeName(_str));
}
BoxedString* str = static_cast<BoxedString*>(_str);
internStringMortalInplace(str);
AUTO_DECREF(str);
delattr(obj, str);
return incref(None);
......
# expected: reffail
class C(object):
pass
......
# expected: reffail
#delete attribute of built-in types
def del_builtin_attr(o):
try:
......
# expected: reffail
class C(object):
def __delattr__(self, attr):
print "delattr", attr
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment