File tree Expand file tree Collapse file tree 2 files changed +8
-1
lines changed Expand file tree Collapse file tree 2 files changed +8
-1
lines changed Original file line number Diff line number Diff line change @@ -321,6 +321,9 @@ The module defines the following exceptions:
321
321
is set to a truncated form of the name provided or alias dereferenced
322
322
for the lowest entry (object or alias) that was matched.
323
323
324
+ Most exceptions from protocol results also carry the :py:attr: `errnum `
325
+ attribute.
326
+
324
327
325
328
.. py :exception :: ADMINLIMIT_EXCEEDED
326
329
Original file line number Diff line number Diff line change @@ -196,7 +196,7 @@ LDAPerror(LDAP *l, char *msg)
196
196
int
197
197
LDAPinit_constants (PyObject * m )
198
198
{
199
- PyObject * exc ;
199
+ PyObject * exc , * nobj ;
200
200
201
201
/* simple constants */
202
202
@@ -226,6 +226,10 @@ LDAPinit_constants(PyObject *m)
226
226
#define add_err (n ) do { \
227
227
exc = PyErr_NewException("ldap." #n, LDAPexception_class, NULL); \
228
228
if (exc == NULL) return -1; \
229
+ nobj = PyLong_FromLong(LDAP_##n); \
230
+ if (nobj == NULL) return -1; \
231
+ if (PyObject_SetAttrString(exc, "errnum", nobj) != 0) return -1; \
232
+ Py_DECREF(nobj); \
229
233
errobjects[LDAP_##n+LDAP_ERROR_OFFSET] = exc; \
230
234
if (PyModule_AddObject(m, #n, exc) != 0) return -1; \
231
235
Py_INCREF(exc); \
You can’t perform that action at this time.
0 commit comments