mirror of
https://github.com/boostorg/python.git
synced 2026-02-02 21:12:15 +00:00
bug fix in error reporting of __init__
[SVN r8316]
This commit is contained in:
@@ -154,7 +154,7 @@ PyObject* function::call(PyObject* args, PyObject* keywords) const
|
||||
message += description_as_string(desc);
|
||||
message += ",\nbut got ";
|
||||
tuple arguments(ref(args, ref::increment_count));
|
||||
message += argument_tuple_as_string(arguments);
|
||||
message += arguments_as_string(arguments);
|
||||
message += " instead.";
|
||||
PyErr_SetObject(PyExc_TypeError, message.get());
|
||||
}
|
||||
@@ -177,7 +177,7 @@ PyObject* function::call(PyObject* args, PyObject* keywords) const
|
||||
message += " matches argument(s):\n";
|
||||
|
||||
tuple arguments(ref(args, ref::increment_count));
|
||||
message += argument_tuple_as_string(arguments);
|
||||
message += arguments_as_string(arguments);
|
||||
|
||||
message += "\nCandidates are:\n";
|
||||
for (const function* f1 = this; f1 != 0; f1 = f1->m_overloads.get())
|
||||
@@ -192,6 +192,11 @@ PyObject* function::call(PyObject* args, PyObject* keywords) const
|
||||
return 0;
|
||||
}
|
||||
|
||||
string function::arguments_as_string(tuple arguments) const
|
||||
{
|
||||
return argument_tuple_as_string(arguments);
|
||||
}
|
||||
|
||||
bound_function* bound_function::create(const ref& target, const ref& fn)
|
||||
{
|
||||
bound_function* const result = free_list;
|
||||
|
||||
@@ -46,6 +46,7 @@ class function : public python_object
|
||||
|
||||
protected:
|
||||
virtual PyObject* description() const = 0;
|
||||
virtual string arguments_as_string(tuple args) const;
|
||||
private:
|
||||
virtual PyObject* do_call(PyObject* args, PyObject* keywords) const = 0;
|
||||
virtual string function_name() const = 0;
|
||||
|
||||
@@ -130,6 +130,7 @@ private: // override function hook
|
||||
PyObject* do_call(PyObject* args, PyObject* keywords) const;
|
||||
private:
|
||||
virtual instance_holder_base* create_holder(extension_instance* self, PyObject* tail_args, PyObject* keywords) const = 0;
|
||||
string arguments_as_string(tuple arguments) const;
|
||||
};
|
||||
""" + gen_functions("""
|
||||
|
||||
|
||||
@@ -33,4 +33,9 @@ namespace python { namespace detail {
|
||||
return none();
|
||||
}
|
||||
|
||||
string init::arguments_as_string(tuple arguments) const
|
||||
{
|
||||
return argument_tuple_as_string(arguments.slice(1, arguments.size()));
|
||||
}
|
||||
|
||||
}} // namespace python::detail
|
||||
|
||||
@@ -165,6 +165,7 @@ private: // override function hook
|
||||
PyObject* do_call(PyObject* args, PyObject* keywords) const;
|
||||
private:
|
||||
virtual instance_holder_base* create_holder(extension_instance* self, PyObject* tail_args, PyObject* keywords) const = 0;
|
||||
string arguments_as_string(tuple arguments) const;
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -15,13 +15,13 @@ a single long parameter.
|
||||
... print str(err)
|
||||
... else: print 'no exception'
|
||||
'demo.Foo.__init__' expected argument(s) (int),
|
||||
but got (demo.Foo) instead.
|
||||
but got () instead.
|
||||
>>> try: ext = Foo('foo')
|
||||
... except TypeError, err:
|
||||
... print str(err)
|
||||
... else: print 'no exception'
|
||||
'demo.Foo.__init__' expected argument(s) (int),
|
||||
but got (demo.Foo, string) instead.
|
||||
but got (string) instead.
|
||||
>>> ext = Foo(1)
|
||||
|
||||
Call a virtual function. This call takes a trip into C++ where
|
||||
@@ -363,7 +363,7 @@ Some simple overloading tests:
|
||||
... print str(err)
|
||||
... else: print 'no exception'
|
||||
No variant of overloaded function 'demo.Range.__init__' matches argument(s):
|
||||
(demo.Range, string)
|
||||
(string)
|
||||
Candidates are:
|
||||
(int)
|
||||
(int, int)
|
||||
@@ -617,7 +617,7 @@ Testing overloaded constructors
|
||||
... else:
|
||||
... print 'no exception'
|
||||
No variant of overloaded function 'demo.OverloadTest.__init__' matches argument(s):
|
||||
(demo.OverloadTest, int, string)
|
||||
(int, string)
|
||||
Candidates are:
|
||||
()
|
||||
(demo.OverloadTest)
|
||||
|
||||
Reference in New Issue
Block a user