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 @@ -198,7 +198,7 @@ LDAPerror(LDAP *l, char *msg)
198
198
int
199
199
LDAPinit_constants (PyObject * m )
200
200
{
201
- PyObject * exc ;
201
+ PyObject * exc , * nobj ;
202
202
203
203
/* simple constants */
204
204
@@ -228,6 +228,10 @@ LDAPinit_constants(PyObject *m)
228
228
#define add_err (n ) do { \
229
229
exc = PyErr_NewException("ldap." #n, LDAPexception_class, NULL); \
230
230
if (exc == NULL) return -1; \
231
+ nobj = PyLong_FromLong(LDAP_##n); \
232
+ if (nobj == NULL) return -1; \
233
+ if (PyObject_SetAttrString(exc, "errnum", nobj) != 0) return -1; \
234
+ Py_DECREF(nobj); \
231
235
errobjects[LDAP_##n+LDAP_ERROR_OFFSET] = exc; \
232
236
if (PyModule_AddObject(m, #n, exc) != 0) return -1; \
233
237
Py_INCREF(exc); \
You can’t perform that action at this time.
0 commit comments