|
From: David L. <dav...@it...> - 2002-07-28 11:41:47
|
On Sun, 28 Jul 2002, Jacek Konieczny typed thusly:
> On Sat, Jul 27, 2002 at 10:38:35PM +0200, Michael Str=F6der wrote:
> It seems ldap_str2objectclass() fails, but no proper python-way error
> hadnling is done. The fix should be easy (just replace
> /* XXX Do error handling... */ with exception object initialization).
> Unfortunately I am not able to do it now (lack of time) :-(
is ret important?
is a subclassed error the right thing to do?
Index: schema.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
RCS file: /cvsroot/python-ldap/python-ldap/Modules/schema.c,v
retrieving revision 1.2
diff -u -r1.2 schema.c
--- schema.c=094 May 2002 18:14:48 -0000=091.2
+++ schema.c=0928 Jul 2002 11:39:00 -0000
@@ -8,6 +8,8 @@
#include "schema.h"
#include "ldap_schema.h"
+static PyObject *SchemaError;
+
/*
This utility function takes a null delimited C array of (null
delimited) C strings, creates its python equivalent and returns a
@@ -91,8 +93,7 @@
=09return NULL;
o =3D ldap_str2objectclass( oc_string, &ret, &errp, flag);
if (ret) {
- printf("Error: %d: %s", ret, errp);
- /* XXX Do error handling... */
+ PyErr_SetString(SchemaError, errp);
return NULL;
}
@@ -139,8 +140,7 @@
return NULL;
a =3D ldap_str2attributetype( at_string, &ret, &errp, flag);
if (ret) {
- printf("Error: %d: %s", ret, errp);
- /* XXX Do error handling... */
+ PyErr_SetString(SchemaError, errp);
return NULL;
}
@@ -208,8 +208,7 @@
return NULL;
s =3D ldap_str2syntax(syn_string, &ret, &errp, flag);
if (ret) {
- printf("Error: %d: %s", ret, errp);
- /* XXX Do error handling... */
+ PyErr_SetString(SchemaError, errp);
return NULL;
}
py_ret =3D PyList_New(4);
@@ -243,8 +242,7 @@
return NULL;
m =3D ldap_str2matchingrule(mr_string, &ret, &errp, flag);
if (ret) {
- printf("Error: %d: %s", ret, errp);
- /* XXX Do error handling... */
+ PyErr_SetString(SchemaError, errp);
return NULL;
}
py_ret =3D PyList_New(6);
@@ -285,5 +283,8 @@
void
LDAPinit_schema( PyObject* d ) {
+ SchemaError =3D PyErr_NewException("ldap.SchemaError",
+=09LDAPexception_class, NULL);
+ PyDict_SetItemString(d, "SchemaError", SchemaError);
LDAPadd_methods( d, methods );
}
--=20
David Leonard Dav...@it...
Dept of Inf. Tech. and Elec. Engg _ Ph:+61 404 844 850
The University of Queensland |+| http://www.itee.uq.edu.au/~leonard/
QLD 4072 AUSTRALIA ~` '~ B73CD65FBEF4C089B79A8EBADF1A932F13E=
A0FC8
|