File tree Expand file tree Collapse file tree 2 files changed +21
-0
lines changed
Expand file tree Collapse file tree 2 files changed +21
-0
lines changed Original file line number Diff line number Diff line change @@ -329,6 +329,13 @@ The module defines the following exceptions:
329329 is set to a truncated form of the name provided or alias dereferenced
330330 for the lowest entry (object or alias) that was matched.
331331
332+ The field :py:const: `msgid ` is set in the dictionary where the
333+ exception can be associated with an asynchronous request.
334+ This can be used in asynchronous code where :py:meth: `result() ` raises the
335+ result of an operation as an exception. For example, this is the case for
336+ :py:meth: `compare() `, always raises the boolean result as an exception
337+ (:py:exc: `COMPARE_TRUE ` or :py:exc: `COMPARE_FALSE `).
338+
332339 Most exceptions from protocol results also carry the :py:attr: `errnum `
333340 attribute.
334341
Original file line number Diff line number Diff line change @@ -673,6 +673,20 @@ def test_compare_s_invalidattr(self):
673673 with self .assertRaises (ldap .UNDEFINED_TYPE ):
674674 result = l .compare_s ('cn=Foo1,%s' % base , 'invalidattr' , b'invalid' )
675675
676+ def test_compare_true_exception_contains_message_id (self ):
677+ base = self .server .suffix
678+ l = self ._ldap_conn
679+ msgid = l .compare ('cn=Foo1,%s' % base , 'cn' , b'Foo1' )
680+ with self .assertRaises (ldap .COMPARE_TRUE ) as cm :
681+ l .result ()
682+ self .assertEqual (cm .exception .args [0 ]["msgid" ], msgid )
683+
684+ def test_async_search_no_such_object_exception_contains_message_id (self ):
685+ msgid = self ._ldap_conn .search ("CN=XXX" , ldap .SCOPE_SUBTREE )
686+ with self .assertRaises (ldap .NO_SUCH_OBJECT ) as cm :
687+ self ._ldap_conn .result ()
688+ self .assertEqual (cm .exception .args [0 ]["msgid" ], msgid )
689+
676690
677691class Test01_ReconnectLDAPObject (Test00_SimpleLDAPObject ):
678692 """
You can’t perform that action at this time.
0 commit comments