Commit e47bcc85 authored by Marius Wachtler's avatar Marius Wachtler

Merge commit 'ca7c5b86' into refcounting

Conflicts:
	src/runtime/types.cpp

Had todo some bigger changes to AttrWrapper and Box::setDictBacked
parents 9404c04a ca7c5b86
......@@ -690,7 +690,7 @@ public:
void setDictBacked(STOLEN(Box*) d);
// For instances with dict attrs:
BoxedDict* getDict();
void setDict(BoxedDict* d);
void setDict(STOLEN(BoxedDict*) d);
// Note, setattr does *not* steal a reference, but it probably should
......
......@@ -965,7 +965,7 @@ BoxedDict** Box::getDictPtr() {
return d_ptr;
}
void Box::setDict(BoxedDict* d) {
void Box::setDict(STOLEN(BoxedDict*) d) {
assert(0 && "check refcounting");
assert(cls->instancesHaveDictAttrs());
......@@ -6547,7 +6547,6 @@ Box* _typeNew(BoxedClass* metatype, BoxedString* name, BoxedTuple* bases, BoxedD
Py_DECREF(s);
}
} else {
assert(0 && "check refcounting");
Box* copy = PyDict_Copy(attr_dict);
RELEASE_ASSERT(copy, "");
made->setDictBacked(copy);
......
This diff is collapsed.
......@@ -51,6 +51,19 @@ print hasattr(c, "attr")
print hasattr(c, "foo")
print c.__dict__ is d1
c = C()
a = c.__dict__
c.__dict__ = c.__dict__
c.__dict__[u"uni"] = "u"
c.__dict__[u"\u20ac"] = "u"
c.__dict__[(1, 2, 3)] = "t"
print sorted(c.__dict__.keys()), sorted(a.keys())
print "all non str attributes:", sorted([item for item in dir(c) if not isinstance(item, str)])
print "can we retrieve unicode attributes by there ascii value?", c.uni, c.__dict__["uni"]
print "attrwrapper:", a["uni"], a[(1, 2, 3)]
setattr(c, "uni", 1)
print "test setattr()", c.uni, c.__dict__["uni"], a["uni"], len(c.__dict__), len(a)
dictproxy = C.__dict__
print type(dictproxy)
print "foo" in dictproxy
......
# expected: fail
# - haven't bothered to implement this yet
# Funny case: if we get the attrwrapper of an object, then change it to be dict-backed,
# the original attrwrapper should remain valid but no longer connected to that object.
......@@ -13,3 +10,10 @@ c1.a = 1
print aw.items()
c1.__dict__ = d = {}
print aw.items()
c2 = C()
olddict = c2.__dict__
c2.__dict__ = { "should not be there" : 1 }
print olddict.has_key("should not be there")
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