Thanks to visit codestin.com
Credit goes to github.com

Skip to content

conn.set_option(-1, '') does not fail sometimes #100

Closed
@tiran

Description

@tiran

I started to create tests for SimpleLDAPObject.set_option and noticed something strange. Sometimes a set_option call does not fail although it should fail, e.g. conn.set_option(-1, '') should fail with ValueError: unknown option -1.

While I was investigating the issue with pdb, I ran into failing pdb session. pdb's interactive session just failed with RuntimeWarning: tp_compare didn't return -1 or -2 for exception:

........> /home/heimes/dev/redhat/python-ldap/Tests/t_ldap_options.py(141)test_invalid()
-> self.conn._l.set_option(-1, '')
(Pdb) n
--Return--
/usr/lib64/python2.7/bdb.py:351: RuntimeWarning: tp_compare didn't return -1 or -2 for exception
  i = max(0, len(stack) - 1)
E
======================================================================
ERROR: test_invalid (__main__.TestLDAPObjectOptions)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "Tests/t_ldap_options.py", line 141, in test_invalid
    self.conn._l.set_option(-1, '')
  File "/usr/lib64/python2.7/bdb.py", line 53, in trace_dispatch
    return self.dispatch_return(frame, arg)
  File "/usr/lib64/python2.7/bdb.py", line 88, in dispatch_return
    self.user_return(frame, arg)
  File "/usr/lib64/python2.7/pdb.py", line 190, in user_return
    self.interaction(frame, None)
  File "/usr/lib64/python2.7/pdb.py", line 208, in interaction
    self.setup(frame, traceback)
  File "/usr/lib64/python2.7/pdb.py", line 119, in setup
    self.stack, self.curindex = self.get_stack(f, t)
  File "/usr/lib64/python2.7/bdb.py", line 351, in get_stack
    i = max(0, len(stack) - 1)
ValueError: unknown option -1

----------------------------------------------------------------------
Ran 9 tests in 8.825s

Python 3 doesn't like conn.set_option(-1, '') either:

ValueError: unknown option -1

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

Traceback (most recent call last):
  File "Tests/t_ldap_options.py", line 140, in test_invalid
    self.conn._l.set_option(-1, '')
SystemError: <built-in method set_option of LDAP object at 0x7f01fdb16bc0> returned a result with an error set

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