Commit aa06c018 authored by Kevin Modzelewski's avatar Kevin Modzelewski

Fix custom tuple subclasses

parent a0471f34
......@@ -493,6 +493,7 @@ Box* setUnion(BoxedSet* self, BoxedTuple* args) {
static void _setDifferenceUpdate(BoxedSet* self, BoxedTuple* args) {
for (auto container : args->pyElements()) {
AUTO_DECREF(container);
if (PyAnySet_Check(container)) {
for (auto&& elt : ((BoxedSet*)container)->s) {
_setRemove(self, elt);
......
......@@ -382,10 +382,19 @@ extern "C" Box* tupleNew(Box* _cls, BoxedTuple* args, BoxedDict* kwargs) {
}
std::vector<Box*> elts;
try {
for (auto e : elements->pyElements())
elts.push_back(e);
} catch (ExcInfo e) {
for (auto e : elts)
Py_DECREF(e);
throw e;
}
auto rtn = BoxedTuple::create(elts.size(), cls);
memcpy(&rtn->elts[0], &elts[0], elts.size() * sizeof(Box*));
return BoxedTuple::create(elts.size(), &elts[0], cls);
return rtn;
} else {
if (cls == tuple_cls)
return incref(EmptyTuple);
......
# expected: reffail
def func(a, b=1):
print a, b
func(0)
......
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