summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWilliam S Fulton <wsf@fultondesigns.co.uk>2009-08-08 22:56:10 +0000
committerWilliam S Fulton <wsf@fultondesigns.co.uk>2009-08-08 22:56:10 +0000
commit136bd5175af2864ac32ded708e3f0ba7c249ed66 (patch)
treee29587148fcbd3618581e9696cbaf1dd41a449ca
parent60e20c6ec5a980d2363b0621f91a2a5dff4a095d (diff)
downloadswig-136bd5175af2864ac32ded708e3f0ba7c249ed66.tar.gz
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
-rw-r--r--CHANGES.current10
-rw-r--r--Source/Modules/python.cxx2
-rw-r--r--Source/Modules/tcl8.cxx4
3 files changed, 13 insertions, 3 deletions
diff --git a/CHANGES.current b/CHANGES.current
index e403c1b60..e3f690daa 100644
--- a/CHANGES.current
+++ b/CHANGES.current
@@ -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.
diff --git a/Source/Modules/python.cxx b/Source/Modules/python.cxx
index 5ae98407b..9475139a3 100644
--- a/Source/Modules/python.cxx
+++ b/Source/Modules/python.cxx
@@ -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);
diff --git a/Source/Modules/tcl8.cxx b/Source/Modules/tcl8.cxx
index 015ac5e45..ef6b3109e 100644
--- a/Source/Modules/tcl8.cxx
+++ b/Source/Modules/tcl8.cxx
@@ -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);