diff --git a/CHANGES b/CHANGES index d157c5e..8008588 100644 --- a/CHANGES +++ b/CHANGES @@ -7,6 +7,11 @@ Lib/ * removed unused 2nd argument of ldap.schema.tokenizer.split_tokens() * fixed method calls in ReconnectLDAPObject (thanks to Philipp Hahn) +Modules/ +* an empty info message is replaced with str(errno) if errno is non-zero + which gives more information e.g. in case of ldap.SERVER_DOWN + (thanks to Markus Klein) + Tests/ * re-factored t_ldap_schema_tokenizer.py @@ -1348,4 +1353,4 @@ Released 2.0.0pre02 2002-02-01 ---------------------------------------------------------------- Released 1.10alpha3 2000-09-19 -$Id: CHANGES,v 1.413 2017/04/24 08:25:16 stroeder Exp $ +$Id: CHANGES,v 1.414 2017/04/24 18:32:50 stroeder Exp $ diff --git a/Modules/errors.c b/Modules/errors.c index c34167c..4d7e0e1 100644 --- a/Modules/errors.c +++ b/Modules/errors.c @@ -2,10 +2,12 @@ * errors that arise from ldap use * Most errors become their own exception * See http://www.python-ldap.org/ for details. - * $Id: errors.c,v 1.27 2017/04/24 13:48:15 stroeder Exp $ */ + * $Id: errors.c,v 1.28 2017/04/24 18:32:51 stroeder Exp $ */ #include "common.h" #include "errors.h" +#include +#include /* the base exception class */ @@ -96,13 +98,17 @@ LDAPerror( LDAP *l, char *msg ) if (str) PyDict_SetItemString( info, "info", str ); Py_XDECREF(str); - } else if (ldap_get_option(l, LDAP_OPT_ERROR_STRING, &error) >= 0 - && error != NULL) { - if (*error != '\0') { + } else if (ldap_get_option(l, LDAP_OPT_ERROR_STRING, &error) >= 0) { + if (error != NULL && *error != '\0') { str = PyString_FromString(error); if (str) PyDict_SetItemString( info, "info", str ); Py_XDECREF(str); + } else if (errno != 0) { + str = PyString_FromString(strerror(errno)); + if(str) + PyDict_SetItemString( info, "info", str); + Py_XDECREF(str); } ldap_memfree(error); }