Visitar URL original
ldap.set_option() loses the exception from a value whose `__bool__` raises · Issue #694 · python-ldap/python-ldap · GitHub
Skip to content

ldap.set_option() loses the exception from a value whose __bool__ raises #694

Open

Description

@theosotr

Passing a value whose __bool__ raises to a boolean option such as OPT_RESTART does not propagate that exception. The original error is discarded and replaced by "SystemError: returned
a result with an exception set".

Expected: the RuntimeError from __bool__ should reach the caller.

Environment

  • python-ldap 3.4.8 (built from source against OpenLDAP 2.6.10)
  • Python 3.13.5

Reproducer

import ldap

class Flag:
    def __bool__(self):
        raise RuntimeError("Flag.__bool__")

ldap.set_option(ldap.OPT_RESTART, Flag())
RuntimeError: Flag.__bool__

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "min.py", line 9, in <module>
    ldap.set_option(ldap.OPT_RESTART, Flag())
  File ".../ldap/functions.py", line 114, in set_option
    return _ldap_function_call(None,_ldap.set_option,option,invalue)
  File ".../ldap/functions.py", line 52, in _ldap_function_call
    result = func(*args,**kwargs)
SystemError: <built-in function set_option> returned a result with an exception set

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions