Skip to content

Wrong error triggered in calls with keyword arguments #688

Description

@pschella

When a class with an overloaded copy constructor:

struct Bla {
Bla() = default;
explicit Bla(const Bla &, bool deep=true) { }
explicit Bla(const Bla &, int i, std::string s="", bool deep=true) { }
};

wrapped as

 py::class_<Bla>(m, "Bla")
.def(py::init<>())
.def(py::init<const Bla &, bool>(),
"other"_a, "deep"_a=true)
.def(py::init<const Bla &, int, std::string, bool>(),
"other"_a, "i"_a, "s"_a="", "deep"_a=true);

Is called with:

b = Bla()
c = Bla(b, 1, deep=False)

The error message reads: TypeError: __init__(): got multiple values for argument 'deep'. Which is confusing.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions