diff --git a/src/duckdb_py/arrow/arrow_array_stream.cpp b/src/duckdb_py/arrow/arrow_array_stream.cpp index f9cfd1bb..f4ac2b58 100644 --- a/src/duckdb_py/arrow/arrow_array_stream.cpp +++ b/src/duckdb_py/arrow/arrow_array_stream.cpp @@ -109,7 +109,7 @@ unique_ptr PythonTableArrowArrayStreamFactory::Produce( break; } default: { - auto py_object_type = string(py::str(arrow_obj_handle.get_type().attr("__name__"))); + auto py_object_type = string(py::str(py::type::of(arrow_obj_handle).attr("__name__"))); throw InvalidInputException("Object of type '%s' is not a recognized Arrow object", py_object_type); } } diff --git a/src/duckdb_py/native/python_conversion.cpp b/src/duckdb_py/native/python_conversion.cpp index 4a01b566..485a7881 100644 --- a/src/duckdb_py/native/python_conversion.cpp +++ b/src/duckdb_py/native/python_conversion.cpp @@ -606,7 +606,7 @@ struct PythonValueConversion { auto type = ele.attr("type"); shared_ptr internal_type; if (!py::try_cast>(type, internal_type)) { - string actual_type = py::str(type.get_type()); + string actual_type = py::str(py::type::of(type)); throw InvalidInputException("The 'type' of a Value should be of type DuckDBPyType, not '%s'", actual_type); } @@ -1062,7 +1062,7 @@ void TransformPythonObjectInternal(py::handle ele, A &result, const B ¶m, bo } case PythonObjectType::Other: throw NotImplementedException("Unable to transform python value of type '%s' to DuckDB LogicalType", - py::str(ele.get_type()).cast()); + py::str(py::type::of(ele)).cast()); default: throw InternalException("Object type recognized but not implemented!"); } diff --git a/src/duckdb_py/pyconnection.cpp b/src/duckdb_py/pyconnection.cpp index 63fc11a0..75d1b612 100644 --- a/src/duckdb_py/pyconnection.cpp +++ b/src/duckdb_py/pyconnection.cpp @@ -755,7 +755,7 @@ static void ParseMultiFileOptions(named_parameter_map_t &options, const Optional if (!py::none().is(hive_partitioning)) { if (!py::isinstance(hive_partitioning)) { - string actual_type = py::str(hive_partitioning.get_type()); + string actual_type = py::str(py::type::of(hive_partitioning)); throw BinderException("read_json only accepts 'hive_partitioning' as a boolean, not '%s'", actual_type); } auto val = TransformPythonValue(hive_partitioning, LogicalTypeId::BOOLEAN); @@ -764,7 +764,7 @@ static void ParseMultiFileOptions(named_parameter_map_t &options, const Optional if (!py::none().is(union_by_name)) { if (!py::isinstance(union_by_name)) { - string actual_type = py::str(union_by_name.get_type()); + string actual_type = py::str(py::type::of(union_by_name)); throw BinderException("read_json only accepts 'union_by_name' as a boolean, not '%s'", actual_type); } auto val = TransformPythonValue(union_by_name, LogicalTypeId::BOOLEAN); @@ -773,7 +773,7 @@ static void ParseMultiFileOptions(named_parameter_map_t &options, const Optional if (!py::none().is(hive_types_autocast)) { if (!py::isinstance(hive_types_autocast)) { - string actual_type = py::str(hive_types_autocast.get_type()); + string actual_type = py::str(py::type::of(hive_types_autocast)); throw BinderException("read_json only accepts 'hive_types_autocast' as a boolean, not '%s'", actual_type); } auto val = TransformPythonValue(hive_types_autocast, LogicalTypeId::BOOLEAN); @@ -812,11 +812,11 @@ unique_ptr DuckDBPyConnection::ReadJSON( auto &column_name = kv.first; auto &type = kv.second; if (!py::isinstance(column_name)) { - string actual_type = py::str(column_name.get_type()); + string actual_type = py::str(py::type::of(column_name)); throw BinderException("The provided column name must be a str, not of type '%s'", actual_type); } if (!py::isinstance(type)) { - string actual_type = py::str(column_name.get_type()); + string actual_type = py::str(py::type::of(column_name)); throw BinderException("The provided column type must be a str, not of type '%s'", actual_type); } struct_fields.emplace_back(py::str(column_name), Value(py::str(type))); @@ -827,7 +827,7 @@ unique_ptr DuckDBPyConnection::ReadJSON( if (!py::none().is(records)) { if (!py::isinstance(records)) { - string actual_type = py::str(records.get_type()); + string actual_type = py::str(py::type::of(records)); throw BinderException("read_json only accepts 'records' as a string, not '%s'", actual_type); } auto records_s = py::reinterpret_borrow(records); @@ -837,7 +837,7 @@ unique_ptr DuckDBPyConnection::ReadJSON( if (!py::none().is(format)) { if (!py::isinstance(format)) { - string actual_type = py::str(format.get_type()); + string actual_type = py::str(py::type::of(format)); throw BinderException("read_json only accepts 'format' as a string, not '%s'", actual_type); } auto format_s = py::reinterpret_borrow(format); @@ -847,7 +847,7 @@ unique_ptr DuckDBPyConnection::ReadJSON( if (!py::none().is(date_format)) { if (!py::isinstance(date_format)) { - string actual_type = py::str(date_format.get_type()); + string actual_type = py::str(py::type::of(date_format)); throw BinderException("read_json only accepts 'date_format' as a string, not '%s'", actual_type); } auto date_format_s = py::reinterpret_borrow(date_format); @@ -857,7 +857,7 @@ unique_ptr DuckDBPyConnection::ReadJSON( if (!py::none().is(timestamp_format)) { if (!py::isinstance(timestamp_format)) { - string actual_type = py::str(timestamp_format.get_type()); + string actual_type = py::str(py::type::of(timestamp_format)); throw BinderException("read_json only accepts 'timestamp_format' as a string, not '%s'", actual_type); } auto timestamp_format_s = py::reinterpret_borrow(timestamp_format); @@ -867,7 +867,7 @@ unique_ptr DuckDBPyConnection::ReadJSON( if (!py::none().is(compression)) { if (!py::isinstance(compression)) { - string actual_type = py::str(compression.get_type()); + string actual_type = py::str(py::type::of(compression)); throw BinderException("read_json only accepts 'compression' as a string, not '%s'", actual_type); } auto compression_s = py::reinterpret_borrow(compression); @@ -877,7 +877,7 @@ unique_ptr DuckDBPyConnection::ReadJSON( if (!py::none().is(sample_size)) { if (!py::isinstance(sample_size)) { - string actual_type = py::str(sample_size.get_type()); + string actual_type = py::str(py::type::of(sample_size)); throw BinderException("read_json only accepts 'sample_size' as an integer, not '%s'", actual_type); } options["sample_size"] = Value::INTEGER(py::int_(sample_size)); @@ -885,7 +885,7 @@ unique_ptr DuckDBPyConnection::ReadJSON( if (!py::none().is(maximum_depth)) { if (!py::isinstance(maximum_depth)) { - string actual_type = py::str(maximum_depth.get_type()); + string actual_type = py::str(py::type::of(maximum_depth)); throw BinderException("read_json only accepts 'maximum_depth' as an integer, not '%s'", actual_type); } options["maximum_depth"] = Value::INTEGER(py::int_(maximum_depth)); @@ -893,7 +893,7 @@ unique_ptr DuckDBPyConnection::ReadJSON( if (!py::none().is(maximum_object_size)) { if (!py::isinstance(maximum_object_size)) { - string actual_type = py::str(maximum_object_size.get_type()); + string actual_type = py::str(py::type::of(maximum_object_size)); throw BinderException("read_json only accepts 'maximum_object_size' as an unsigned integer, not '%s'", actual_type); } @@ -903,7 +903,7 @@ unique_ptr DuckDBPyConnection::ReadJSON( if (!py::none().is(ignore_errors)) { if (!py::isinstance(ignore_errors)) { - string actual_type = py::str(ignore_errors.get_type()); + string actual_type = py::str(py::type::of(ignore_errors)); throw BinderException("read_json only accepts 'ignore_errors' as a boolean, not '%s'", actual_type); } auto val = TransformPythonValue(ignore_errors, LogicalTypeId::BOOLEAN); @@ -912,7 +912,7 @@ unique_ptr DuckDBPyConnection::ReadJSON( if (!py::none().is(convert_strings_to_integers)) { if (!py::isinstance(convert_strings_to_integers)) { - string actual_type = py::str(convert_strings_to_integers.get_type()); + string actual_type = py::str(py::type::of(convert_strings_to_integers)); throw BinderException("read_json only accepts 'convert_strings_to_integers' as a boolean, not '%s'", actual_type); } @@ -922,7 +922,7 @@ unique_ptr DuckDBPyConnection::ReadJSON( if (!py::none().is(field_appearance_threshold)) { if (!py::isinstance(field_appearance_threshold)) { - string actual_type = py::str(field_appearance_threshold.get_type()); + string actual_type = py::str(py::type::of(field_appearance_threshold)); throw BinderException("read_json only accepts 'field_appearance_threshold' as a float, not '%s'", actual_type); } @@ -932,7 +932,7 @@ unique_ptr DuckDBPyConnection::ReadJSON( if (!py::none().is(map_inference_threshold)) { if (!py::isinstance(map_inference_threshold)) { - string actual_type = py::str(map_inference_threshold.get_type()); + string actual_type = py::str(py::type::of(map_inference_threshold)); throw BinderException("read_json only accepts 'map_inference_threshold' as an integer, not '%s'", actual_type); } @@ -942,7 +942,7 @@ unique_ptr DuckDBPyConnection::ReadJSON( if (!py::none().is(maximum_sample_files)) { if (!py::isinstance(maximum_sample_files)) { - string actual_type = py::str(maximum_sample_files.get_type()); + string actual_type = py::str(py::type::of(maximum_sample_files)); throw BinderException("read_json only accepts 'maximum_sample_files' as an integer, not '%s'", actual_type); } auto val = TransformPythonValue(maximum_sample_files, LogicalTypeId::BIGINT); @@ -1395,7 +1395,7 @@ unique_ptr DuckDBPyConnection::ReadCSV(const py::object &name_ if (!py::none().is(lineterminator)) { PythonCSVLineTerminator::Type new_line_type; if (!py::try_cast(lineterminator, new_line_type)) { - string actual_type = py::str(lineterminator.get_type()); + string actual_type = py::str(py::type::of(lineterminator)); throw BinderException("read_csv only accepts 'lineterminator' as a string or CSVLineTerminator, not '%s'", actual_type); } @@ -1404,7 +1404,7 @@ unique_ptr DuckDBPyConnection::ReadCSV(const py::object &name_ if (!py::none().is(max_line_size)) { if (!py::isinstance(max_line_size) && !py::isinstance(max_line_size)) { - string actual_type = py::str(max_line_size.get_type()); + string actual_type = py::str(py::type::of(max_line_size)); throw BinderException("read_csv only accepts 'max_line_size' as a string or an integer, not '%s'", actual_type); } @@ -1414,7 +1414,7 @@ unique_ptr DuckDBPyConnection::ReadCSV(const py::object &name_ if (!py::none().is(auto_type_candidates)) { if (!py::isinstance(auto_type_candidates)) { - string actual_type = py::str(auto_type_candidates.get_type()); + string actual_type = py::str(py::type::of(auto_type_candidates)); throw BinderException("read_csv only accepts 'auto_type_candidates' as a list[str], not '%s'", actual_type); } auto val = TransformPythonValue(auto_type_candidates, LogicalType::LIST(LogicalTypeId::VARCHAR)); @@ -1423,7 +1423,7 @@ unique_ptr DuckDBPyConnection::ReadCSV(const py::object &name_ if (!py::none().is(ignore_errors)) { if (!py::isinstance(ignore_errors)) { - string actual_type = py::str(ignore_errors.get_type()); + string actual_type = py::str(py::type::of(ignore_errors)); throw BinderException("read_csv only accepts 'ignore_errors' as a bool, not '%s'", actual_type); } auto val = TransformPythonValue(ignore_errors, LogicalTypeId::BOOLEAN); @@ -1432,7 +1432,7 @@ unique_ptr DuckDBPyConnection::ReadCSV(const py::object &name_ if (!py::none().is(store_rejects)) { if (!py::isinstance(store_rejects)) { - string actual_type = py::str(store_rejects.get_type()); + string actual_type = py::str(py::type::of(store_rejects)); throw BinderException("read_csv only accepts 'store_rejects' as a bool, not '%s'", actual_type); } auto val = TransformPythonValue(store_rejects, LogicalTypeId::BOOLEAN); @@ -1441,7 +1441,7 @@ unique_ptr DuckDBPyConnection::ReadCSV(const py::object &name_ if (!py::none().is(rejects_table)) { if (!py::isinstance(rejects_table)) { - string actual_type = py::str(rejects_table.get_type()); + string actual_type = py::str(py::type::of(rejects_table)); throw BinderException("read_csv only accepts 'rejects_table' as a string, not '%s'", actual_type); } auto val = TransformPythonValue(rejects_table, LogicalTypeId::VARCHAR); @@ -1450,7 +1450,7 @@ unique_ptr DuckDBPyConnection::ReadCSV(const py::object &name_ if (!py::none().is(rejects_scan)) { if (!py::isinstance(rejects_scan)) { - string actual_type = py::str(rejects_scan.get_type()); + string actual_type = py::str(py::type::of(rejects_scan)); throw BinderException("read_csv only accepts 'rejects_scan' as a string, not '%s'", actual_type); } auto val = TransformPythonValue(rejects_scan, LogicalTypeId::VARCHAR); @@ -1459,7 +1459,7 @@ unique_ptr DuckDBPyConnection::ReadCSV(const py::object &name_ if (!py::none().is(rejects_limit)) { if (!py::isinstance(rejects_limit)) { - string actual_type = py::str(rejects_limit.get_type()); + string actual_type = py::str(py::type::of(rejects_limit)); throw BinderException("read_csv only accepts 'rejects_limit' as an int, not '%s'", actual_type); } auto val = TransformPythonValue(rejects_limit, LogicalTypeId::BIGINT); @@ -1468,7 +1468,7 @@ unique_ptr DuckDBPyConnection::ReadCSV(const py::object &name_ if (!py::none().is(force_not_null)) { if (!py::isinstance(force_not_null)) { - string actual_type = py::str(force_not_null.get_type()); + string actual_type = py::str(py::type::of(force_not_null)); throw BinderException("read_csv only accepts 'force_not_null' as a list[str], not '%s'", actual_type); } auto val = TransformPythonValue(force_not_null, LogicalType::LIST(LogicalTypeId::VARCHAR)); @@ -1477,7 +1477,7 @@ unique_ptr DuckDBPyConnection::ReadCSV(const py::object &name_ if (!py::none().is(buffer_size)) { if (!py::isinstance(buffer_size)) { - string actual_type = py::str(buffer_size.get_type()); + string actual_type = py::str(py::type::of(buffer_size)); throw BinderException("read_csv only accepts 'buffer_size' as a list[str], not '%s'", actual_type); } auto val = TransformPythonValue(buffer_size, LogicalTypeId::UBIGINT); @@ -1486,7 +1486,7 @@ unique_ptr DuckDBPyConnection::ReadCSV(const py::object &name_ if (!py::none().is(decimal)) { if (!py::isinstance(decimal)) { - string actual_type = py::str(decimal.get_type()); + string actual_type = py::str(py::type::of(decimal)); throw BinderException("read_csv only accepts 'decimal' as a string, not '%s'", actual_type); } auto val = TransformPythonValue(decimal, LogicalTypeId::VARCHAR); @@ -1495,7 +1495,7 @@ unique_ptr DuckDBPyConnection::ReadCSV(const py::object &name_ if (!py::none().is(allow_quoted_nulls)) { if (!py::isinstance(allow_quoted_nulls)) { - string actual_type = py::str(allow_quoted_nulls.get_type()); + string actual_type = py::str(py::type::of(allow_quoted_nulls)); throw BinderException("read_csv only accepts 'allow_quoted_nulls' as a bool, not '%s'", actual_type); } auto val = TransformPythonValue(allow_quoted_nulls, LogicalTypeId::BOOLEAN); @@ -1513,11 +1513,11 @@ unique_ptr DuckDBPyConnection::ReadCSV(const py::object &name_ auto &column_name = kv.first; auto &type = kv.second; if (!py::isinstance(column_name)) { - string actual_type = py::str(column_name.get_type()); + string actual_type = py::str(py::type::of(column_name)); throw BinderException("The provided column name must be a str, not of type '%s'", actual_type); } if (!py::isinstance(type)) { - string actual_type = py::str(column_name.get_type()); + string actual_type = py::str(py::type::of(column_name)); throw BinderException("The provided column type must be a str, not of type '%s'", actual_type); } struct_fields.emplace_back(py::str(column_name), Value(py::str(type))); @@ -1671,7 +1671,7 @@ static vector>> ValueListsFromTuples(const p for (idx_t i = 0; i < arg_count; i++) { py::handle arg = tuples[i]; if (!py::isinstance(arg)) { - string actual_type = py::str(arg.get_type()); + string actual_type = py::str(py::type::of(arg)); throw InvalidInputException("Expected objects of type tuple, not %s", actual_type); } auto expressions = py::cast(arg); @@ -1794,7 +1794,7 @@ unique_ptr DuckDBPyConnection::FromArrow(py::object &arrow_obj auto &connection = con.GetConnection(); string name = "arrow_object_" + StringUtil::GenerateRandomName(); if (!IsAcceptedArrowObject(arrow_object)) { - auto py_object_type = string(py::str(arrow_object.get_type().attr("__name__"))); + auto py_object_type = string(py::str(py::type::of(arrow_object).attr("__name__"))); throw InvalidInputException("Python Object Type %s is not an accepted Arrow Object.", py_object_type); } auto tableref = PythonReplacementScan::ReplacementObject(arrow_object, name, *connection.context, true); @@ -2180,7 +2180,7 @@ static string GetPathString(const py::object &path) { if (is_path || py::isinstance(path)) { return std::string(py::str(path)); } - string actual_type = py::str(path.get_type()); + string actual_type = py::str(py::type::of(path)); throw InvalidInputException("Please provide either a str or a pathlib.Path, not %s", actual_type); } diff --git a/src/duckdb_py/pyconnection/type_creation.cpp b/src/duckdb_py/pyconnection/type_creation.cpp index f1839fee..71e6c610 100644 --- a/src/duckdb_py/pyconnection/type_creation.cpp +++ b/src/duckdb_py/pyconnection/type_creation.cpp @@ -26,7 +26,7 @@ static child_list_t GetChildList(const py::object &container) { for (auto &item : fields) { shared_ptr pytype; if (!py::try_cast>(item, pytype)) { - string actual_type = py::str(item.get_type()); + string actual_type = py::str(py::type::of(item)); throw InvalidInputException("object has to be a list of DuckDBPyType's, not '%s'", actual_type); } types.push_back(std::make_pair(StringUtil::Format("v%d", i++), pytype->Type())); @@ -40,14 +40,14 @@ static child_list_t GetChildList(const py::object &container) { string name = py::str(name_p); shared_ptr pytype; if (!py::try_cast>(type_p, pytype)) { - string actual_type = py::str(type_p.get_type()); + string actual_type = py::str(py::type::of(type_p)); throw InvalidInputException("object has to be a list of DuckDBPyType's, not '%s'", actual_type); } types.push_back(std::make_pair(name, pytype->Type())); } return types; } else { - string actual_type = py::str(container.get_type()); + string actual_type = py::str(py::type::of(container)); throw InvalidInputException( "Can not construct a child list from object of type '%s', only dict/list is supported", actual_type); } diff --git a/src/duckdb_py/pyexpression.cpp b/src/duckdb_py/pyexpression.cpp index 5dd551a1..0703389b 100644 --- a/src/duckdb_py/pyexpression.cpp +++ b/src/duckdb_py/pyexpression.cpp @@ -500,7 +500,7 @@ shared_ptr DuckDBPyExpression::FunctionExpression(const stri for (auto arg : args) { shared_ptr py_expr; if (!py::try_cast>(arg, py_expr)) { - string actual_type = py::str(arg.get_type()); + string actual_type = py::str(py::type::of(arg)); throw InvalidInputException("Expected argument of type Expression, received '%s' instead", actual_type); } auto expr = py_expr->GetExpression().Copy(); diff --git a/src/duckdb_py/pyrelation.cpp b/src/duckdb_py/pyrelation.cpp index 62e9cd2d..3cbf09a8 100644 --- a/src/duckdb_py/pyrelation.cpp +++ b/src/duckdb_py/pyrelation.cpp @@ -134,7 +134,7 @@ unique_ptr DuckDBPyRelation::ProjectFromTypes(const py::object auto *type_p = item.cast(); type = type_p->Type(); } else { - string actual_type = py::str(item.get_type()); + string actual_type = py::str(py::type::of(item)); throw InvalidInputException("Can only project on objects of type DuckDBPyType or str, not '%s'", actual_type); } @@ -219,7 +219,7 @@ unique_ptr DuckDBPyRelation::Sort(const py::args &args) { for (auto arg : args) { shared_ptr py_expr; if (!py::try_cast>(arg, py_expr)) { - string actual_type = py::str(arg.get_type()); + string actual_type = py::str(py::type::of(arg)); throw InvalidInputException("Expected argument of type Expression, received '%s' instead", actual_type); } auto expr = py_expr->GetExpression().Copy(); @@ -248,7 +248,7 @@ vector> GetExpressions(ClientContext &context, cons auto aggregate_list = std::string(py::str(expr)); return Parser::ParseExpressionList(aggregate_list, context.GetParserOptions()); } else { - string actual_type = py::str(expr.get_type()); + string actual_type = py::str(py::type::of(expr)); throw InvalidInputException("Please provide either a string or list of Expression objects, not %s", actual_type); } @@ -1183,7 +1183,7 @@ unique_ptr DuckDBPyRelation::Join(DuckDBPyRelation *other, con auto using_list_p = py::list(condition); for (auto &item : using_list_p) { if (!py::isinstance(item)) { - string actual_type = py::str(item.get_type()); + string actual_type = py::str(py::type::of(item)); throw InvalidInputException("Using clause should be a list of strings, not %s", actual_type); } using_list.push_back(std::string(py::str(item))); @@ -1594,7 +1594,7 @@ void DuckDBPyRelation::Update(const py::object &set_p, const py::object &where) } shared_ptr py_expr; if (!py::try_cast>(item_value, py_expr)) { - string actual_type = py::str(item_value.get_type()); + string actual_type = py::str(py::type::of(item_value)); throw InvalidInputException("Please provide an object of type Expression as the value, not %s", actual_type); } diff --git a/src/duckdb_py/python_replacement_scan.cpp b/src/duckdb_py/python_replacement_scan.cpp index 01804f53..ff5c8b5e 100644 --- a/src/duckdb_py/python_replacement_scan.cpp +++ b/src/duckdb_py/python_replacement_scan.cpp @@ -80,7 +80,7 @@ static void CreateArrowScan(const string &name, py::object entry, TableFunctionR static void ThrowScanFailureError(const py::object &entry, const string &name, const string &location = "") { string error; - auto py_object_type = string(py::str(entry.get_type().attr("__name__"))); + auto py_object_type = string(py::str(py::type::of(entry).attr("__name__"))); error += StringUtil::Format("Python Object \"%s\" of type \"%s\"", name, py_object_type); if (!location.empty()) { error += StringUtil::Format(" found on line \"%s\"", location); diff --git a/src/duckdb_py/python_udf.cpp b/src/duckdb_py/python_udf.cpp index c67ae50e..ac2ae74e 100644 --- a/src/duckdb_py/python_udf.cpp +++ b/src/duckdb_py/python_udf.cpp @@ -332,20 +332,23 @@ static scalar_function_t CreateNativeFunction(PyObject *function, PythonExceptio ret = py::reinterpret_steal(PyObject_CallObject(function, nullptr)); } - if (ret == nullptr && PyErr_Occurred()) { - if (exception_handling == PythonExceptionHandling::FORWARD_ERROR) { - auto exception = py::error_already_set(); - throw InvalidInputException("Python exception occurred while executing the UDF: %s", - exception.what()); - } else if (exception_handling == PythonExceptionHandling::RETURN_NULL) { - PyErr_Clear(); - FlatVector::SetNull(result, row, true); - continue; - } else { + if (!ret || ret.is_none()) { + if (PyErr_Occurred()) { + if (exception_handling == PythonExceptionHandling::FORWARD_ERROR) { + auto exception = py::error_already_set(); + throw InvalidInputException("Python exception occurred while executing the UDF: %s", + exception.what()); + } + if (exception_handling == PythonExceptionHandling::RETURN_NULL) { + PyErr_Clear(); + FlatVector::SetNull(result, row, true); + continue; + } throw NotImplementedException("Exception handling type not implemented"); } - } else if ((!ret || ret == Py_None) && default_null_handling) { - throw InvalidInputException(NullHandlingError()); + if (default_null_handling) { + throw InvalidInputException(NullHandlingError()); + } } TransformPythonObject(ret, result, row); } diff --git a/src/duckdb_py/typing/pytype.cpp b/src/duckdb_py/typing/pytype.cpp index 58503cf3..5087de50 100644 --- a/src/duckdb_py/typing/pytype.cpp +++ b/src/duckdb_py/typing/pytype.cpp @@ -215,7 +215,7 @@ static py::tuple FilterNones(const py::tuple &args) { for (const auto &arg : args) { py::object object = py::reinterpret_borrow(arg); - if (object.is(py::none().get_type())) { + if (object.is(py::type::of(py::none()))) { continue; } result.append(object); @@ -313,13 +313,13 @@ static LogicalType FromObject(const py::object &object) { case PythonTypeObject::TYPE: { shared_ptr type_object; if (!py::try_cast>(object, type_object)) { - string actual_type = py::str(object.get_type()); + string actual_type = py::str(py::type::of(object)); throw InvalidInputException("Expected argument of type DuckDBPyType, received '%s' instead", actual_type); } return type_object->Type(); } default: { - string actual_type = py::str(object.get_type()); + string actual_type = py::str(py::type::of(object)); throw NotImplementedException("Could not convert from object of type '%s' to DuckDBPyType", actual_type); } }