From c83e0622635490ea38db539074782fdab7f0733d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20Mi=C4=85sko?= Date: Sun, 27 Dec 2015 09:05:25 +0100 Subject: [PATCH] Create an empty python tuple in pybind::tuple default constructor. Follow the same semantics as constructors of dict, list, and set by creating valid Python object in default constructor of a tuple class. --- include/pybind11/pytypes.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/pybind11/pytypes.h b/include/pybind11/pytypes.h index 01776d7e..bdad374e 100644 --- a/include/pybind11/pytypes.h +++ b/include/pybind11/pytypes.h @@ -372,8 +372,8 @@ public: class tuple : public object { public: - PYBIND11_OBJECT_DEFAULT(tuple, object, PyTuple_Check) - tuple(size_t size) : object(PyTuple_New((Py_ssize_t) size), false) { } + PYBIND11_OBJECT(tuple, object, PyTuple_Check) + tuple(size_t size = 0) : object(PyTuple_New((Py_ssize_t) size), false) { } size_t size() const { return (size_t) PyTuple_Size(m_ptr); } detail::tuple_accessor operator[](size_t index) { return detail::tuple_accessor(ptr(), index); } };