@@ -602,53 +602,22 @@ inline handle create_pybind_function_overload_set(handle existing_function) {
602602 return create_pybind_function<function_overload_set>(existing_function);
603603}
604604
605- inline handle
606- combine_functions (handle existing_function, handle new_function, bool prepend, bool is_method) {
607- // TODO: InstanceMethod here is very inefficient
605+ inline handle combine_functions (handle existing_function, handle new_function, bool prepend) {
608606 pybind_function *new_wrapper = (pybind_function *) new_function.ptr ();
609607
610- bool pulled_from_instance_method = false ;
611- if (PyInstanceMethod_Check (existing_function.ptr ())) {
612- pulled_from_instance_method = true ;
613- existing_function = PyInstanceMethod_GET_FUNCTION (existing_function.ptr ());
614- }
615-
616608 if (!PyObject_TypeCheck (existing_function.ptr (), pybind_function_type ())) {
617609 if (!existing_function.is_none () && new_wrapper->name [0 ] != ' _' ) {
618610 pybind11_fail (std::string (" Found an existing object when trying to defined function " )
619611 + new_wrapper->name );
620612 }
621613
622- if (is_method) {
623- return PyInstanceMethod_New (new_function.ptr ());
624- }
625614 return new_function.ptr ();
626615 }
627616
628- if (is_method != pulled_from_instance_method) {
629- pybind11_fail (
630- " overloading a method with both static and instance methods is not supported; "
631- #if !defined(PYBIND11_DETAILED_ERROR_MESSAGES)
632- " #define PYBIND11_DETAILED_ERROR_MESSAGES or compile in debug mode for more "
633- " details"
634- #else
635- " error while attempting to bind "
636- + std::string (is_method ? " instance" : " static" ) + " method "
637- + std::string (pybind11::str (
638- ((handle) ((PyObject *) new_wrapper->current_scope )).attr (" __name__" )))
639- + " ." + std::string (new_wrapper->name ) + new_wrapper->signature
640- #endif
641- );
642- }
643-
644617 pybind_function *wrapper = (pybind_function *) existing_function.ptr ();
645618
646619 if (wrapper->current_scope != new_wrapper->current_scope ) {
647- if (is_method) {
648- return PyInstanceMethod_New (new_function.ptr ());
649- } else {
650- return new_function.ptr ();
651- }
620+ return new_function.ptr ();
652621 }
653622
654623 if (!wrapper->is_overload_set ) {
@@ -663,10 +632,6 @@ combine_functions(handle existing_function, handle new_function, bool prepend, b
663632
664633 wrapper->doc = wrapped->doc .c_str ();
665634
666- if (is_method) {
667- return PyInstanceMethod_New (existing_function.ptr ());
668- }
669-
670635 return existing_function;
671636}
672637
0 commit comments