@@ -1140,39 +1140,39 @@ struct from_object<py::table_view<columns...>> {
11401140 using type = py::table_view<columns...>;
11411141
11421142 template <typename Column>
1143- static auto pop_column (PyObject* t) {
1143+ static auto pop_column (py::borrowed_ref<> t) {
11441144 auto text = py::cs::to_array (typename Column::key{});
11451145 auto column_name = py::to_object (
11461146 *reinterpret_cast <std::array<char , text.size () - 1 >*>(text.data ()));
11471147 if (!column_name) {
11481148 throw py::exception ();
11491149 }
1150- PyObject* column_ob = PyDict_GetItem (t, column_name.get ());
1150+ PyObject* column_ob = PyDict_GetItem (t. get () , column_name.get ());
11511151 if (!column_ob) {
11521152 throw py::exception (PyExc_ValueError, " missing column: " , column_name);
11531153 }
1154- if (PyDict_DelItem (t, column_name.get ())) {
1154+ if (PyDict_DelItem (t. get () , column_name.get ())) {
11551155 // pop the item to track which columns we used
11561156 throw py::exception ();
11571157 }
11581158 return py::from_object<py::array_view<typename Column::value>>(column_ob);
11591159 }
11601160
11611161public:
1162- static type f (PyObject* t) {
1163- if (!PyDict_Check (t)) {
1162+ static type f (py::borrowed_ref<> t) {
1163+ if (!PyDict_Check (t. get () )) {
11641164 throw py::exception (
11651165 PyExc_TypeError,
11661166 " from_object<table_view<...>> input must be a Python dictionary, got: " ,
1167- Py_TYPE (t)->tp_name );
1167+ Py_TYPE (t. get () )->tp_name );
11681168 }
11691169
1170- py::owned_ref copy (PyDict_Copy (t));
1170+ py::owned_ref copy (PyDict_Copy (t. get () ));
11711171 if (!copy) {
11721172 throw py::exception ();
11731173 }
11741174
1175- type out (pop_column<py::detail::unwrap_column<columns>>(copy. get () )...);
1175+ type out (pop_column<py::detail::unwrap_column<columns>>(copy)...);
11761176 if (PyDict_Size (copy.get ())) {
11771177 py::owned_ref keys (PyDict_Keys (copy.get ()));
11781178 if (!keys) {
@@ -1190,39 +1190,39 @@ struct from_object<py::row<columns...>> {
11901190 using type = py::row<columns...>;
11911191
11921192 template <typename Column>
1193- static auto pop_column (PyObject* t) {
1193+ static auto pop_column (py::borrowed_ref<> t) {
11941194 auto text = py::cs::to_array (typename Column::key{});
11951195 auto column_name = py::to_object (
11961196 *reinterpret_cast <std::array<char , text.size () - 1 >*>(text.data ()));
11971197 if (!column_name) {
11981198 throw py::exception ();
11991199 }
1200- PyObject* column_ob = PyDict_GetItem (t, column_name.get ());
1200+ PyObject* column_ob = PyDict_GetItem (t. get () , column_name.get ());
12011201 if (!column_ob) {
12021202 throw py::exception (PyExc_ValueError, " missing column: " , column_name);
12031203 }
1204- if (PyDict_DelItem (t, column_name.get ())) {
1204+ if (PyDict_DelItem (t. get () , column_name.get ())) {
12051205 // pop the item to track which columns we used
12061206 throw py::exception ();
12071207 }
12081208 return py::from_object<typename Column::value>(column_ob);
12091209 }
12101210
12111211public:
1212- static type f (PyObject* t) {
1213- if (!PyDict_Check (t)) {
1212+ static type f (py::borrowed_ref<> t) {
1213+ if (!PyDict_Check (t. get () )) {
12141214 throw py::exception (
12151215 PyExc_TypeError,
1216- " from_object<table_view <...>> input must be a Python dictionary, got: " ,
1217- Py_TYPE (t)->tp_name );
1216+ " from_object<row <...>> input must be a Python dictionary, got: " ,
1217+ Py_TYPE (t. get () )->tp_name );
12181218 }
12191219
1220- py::owned_ref copy (PyDict_Copy (t));
1220+ py::owned_ref copy (PyDict_Copy (t. get () ));
12211221 if (!copy) {
12221222 throw py::exception ();
12231223 }
12241224
1225- type out (pop_column<py::detail::unwrap_column<columns>>(copy. get () )...);
1225+ type out (pop_column<py::detail::unwrap_column<columns>>(copy)...);
12261226 if (PyDict_Size (copy.get ())) {
12271227 py::owned_ref keys (PyDict_Keys (copy.get ()));
12281228 if (!keys) {
0 commit comments