-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make int_::operator T() (for integer types) behave the same as the caster for integers #2802
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -270,6 +270,7 @@ TEST_SUBMODULE(pytypes, m) { | |
throw std::runtime_error("Invalid type"); | ||
}); | ||
|
||
// test_implicit_casting | ||
m.def("get_implicit_casting", []() { | ||
py::dict d; | ||
d["char*_i1"] = "abc"; | ||
|
@@ -307,6 +308,12 @@ TEST_SUBMODULE(pytypes, m) { | |
); | ||
}); | ||
|
||
// (see also test_builtin_casters) | ||
m.def("implicitly_cast_to_int32", [](py::int_ value) { return int32_t{value}; }); | ||
m.def("implicitly_cast_to_uint32", [](py::int_ value) { return uint32_t{value}; }); | ||
m.def("implicitly_cast_to_int64", [](py::int_ value) { return int64_t{value}; }); | ||
m.def("implicitly_cast_to_uint64", [](py::int_ value) { return uint64_t{value}; }); | ||
Comment on lines
+312
to
+315
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These are all explicit casts. If you want implicit, use trailing return types and just There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think I per se want implicit casts. They invoke the same code anyway, right? |
||
|
||
// test_print | ||
m.def("print_function", []() { | ||
py::print("Hello, World!"); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't this now throwing
OverflowError
instead ofRuntimeError
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, this is what's currently making tests fail.