Python and Tcl - improve error message for missing constructor when the reason is because the class is abstract.

git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11518 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
William S Fulton 2009-08-08 22:56:10 +00:00
commit 136bd5175a
3 changed files with 13 additions and 3 deletions

View file

@ -1,6 +1,16 @@
Version 1.3.40 (in progress)
============================
2009-08-08: wsfulton
[Python] More user friendly AttributeError is raised when there are
no constructors generated for the proxy class in the event that the
class is abstract - the error message is now
"No constructor defined - class is abstract" whereas if there are no
public constructors for any other reason and the class is not abstract,
the message remains
"No constructor defined".
[tcl] Similarly for tcl when using -itcl.
2009-08-04: olly
[PHP] Fix generated code to work with PHP 5.3.

View file

@ -2984,7 +2984,7 @@ public:
Delete(realct);
}
if (!have_constructor) {
Printv(f_shadow_file, tab4, "def __init__(self, *args, **kwargs): raise AttributeError(\"No constructor defined\")\n", NIL);
Printv(f_shadow_file, tab4, "def __init__(self, *args, **kwargs): raise AttributeError(\"", "No constructor defined", (Getattr(n, "abstract") ? " - class is abstract" : ""), "\")\n", NIL);
} else if (fastinit) {
Printv(f_wrappers, "SWIGINTERN PyObject *", class_name, "_swiginit(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {\n", NIL);

View file

@ -931,13 +931,13 @@ public:
Printv(f_shadow, " constructor { } {\n", NIL);
Printv(f_shadow, " # This constructor will fail if called directly\n", NIL);
Printv(f_shadow, " if { [info class] == \"::", class_name, "\" } {\n", NIL);
Printv(f_shadow, " error \"No constructor for class ", class_name, "\"\n", NIL);
Printv(f_shadow, " error \"No constructor for class ", class_name, (Getattr(n, "abstract") ? " - class is abstract" : ""), "\"\n", NIL);
Printv(f_shadow, " }\n", NIL);
Printv(f_shadow, " }\n", NIL);
}
Printv(f_shadow, "}\n\n", NIL);
};
}
Printv(f_wrappers, "static swig_class *swig_", mangled_classname, "_bases[] = {", base_class, "0};\n", NIL);
Printv(f_wrappers, "static const char * swig_", mangled_classname, "_base_names[] = {", base_class_names, "0};\n", NIL);