File tree 1 file changed +5
-5
lines changed
1 file changed +5
-5
lines changed Original file line number Diff line number Diff line change @@ -504,15 +504,15 @@ class cpp_function : public function {
504
504
505
505
auto self_value_and_holder = value_and_holder ();
506
506
if (overloads->is_constructor ) {
507
- const auto tinfo = get_type_info ((PyTypeObject *) overloads->scope .ptr ());
508
- const auto pi = reinterpret_cast <instance *>(parent.ptr ());
509
- self_value_and_holder = pi ->get_value_and_holder (tinfo, false );
510
-
511
- if (!self_value_and_holder.type || !self_value_and_holder.inst ) {
507
+ if (!PyObject_TypeCheck (parent.ptr (), (PyTypeObject *) overloads->scope .ptr ())) {
512
508
PyErr_SetString (PyExc_TypeError, " __init__(self, ...) called with invalid `self` argument" );
513
509
return nullptr ;
514
510
}
515
511
512
+ const auto tinfo = get_type_info ((PyTypeObject *) overloads->scope .ptr ());
513
+ const auto pi = reinterpret_cast <instance *>(parent.ptr ());
514
+ self_value_and_holder = pi ->get_value_and_holder (tinfo, true );
515
+
516
516
// If this value is already registered it must mean __init__ is invoked multiple times;
517
517
// we really can't support that in C++, so just ignore the second __init__.
518
518
if (self_value_and_holder.instance_registered ())
You can’t perform that action at this time.
0 commit comments