mirror of
https://github.com/pybind/pybind11.git
synced 2026-05-13 01:36:21 +00:00
don't implicitly convert doubles to ints
This commit is contained in:
@@ -104,4 +104,8 @@ void init_issues(py::module &m) {
|
||||
|
||||
// (no id): should not be able to pass 'None' to a reference argument
|
||||
m2.def("print_element", [](ElementA &el) { std::cout << el.value() << std::endl; });
|
||||
|
||||
// (no id): don't cast doubles to ints
|
||||
m2.def("expect_float", [](float f) { return f; });
|
||||
m2.def("expect_int", [](int i) { return i; });
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ from example.issues import DispatchIssue, dispatch_issue_go
|
||||
from example.issues import Placeholder, return_vec_of_reference_wrapper
|
||||
from example.issues import iterator_passthrough
|
||||
from example.issues import ElementList, ElementA, print_element
|
||||
from example.issues import expect_float, expect_int
|
||||
import gc
|
||||
|
||||
print_cchar("const char *")
|
||||
@@ -47,3 +48,10 @@ try:
|
||||
print_element(None)
|
||||
except Exception as e:
|
||||
print("Failed as expected: " + str(e))
|
||||
|
||||
try:
|
||||
print(expect_int(5.2))
|
||||
except Exception as e:
|
||||
print("Failed as expected: " + str(e))
|
||||
|
||||
print(expect_float(12))
|
||||
|
||||
@@ -8,3 +8,7 @@ Yay..
|
||||
Failed as expected: Incompatible function arguments. The following argument types are supported:
|
||||
1. (example.issues.ElementA) -> NoneType
|
||||
|
||||
Failed as expected: Incompatible function arguments. The following argument types are supported:
|
||||
1. (int) -> int
|
||||
|
||||
12.0
|
||||
|
||||
Reference in New Issue
Block a user