Skip to content

Commit

Permalink
cidict: Re-add the data attribute
Browse files Browse the repository at this point in the history
  • Loading branch information
Petr Viktorin committed Jun 5, 2020
1 parent 2a2cef3 commit dada91a
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
11 changes: 11 additions & 0 deletions Lib/ldap/cidict.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,17 @@ def has_key(self, key):
"""Compatibility with python-ldap 2.x"""
return key in self

@property
def data(self):
"""Compatibility with older IterableUserDict-based implementation"""
warnings.warn(
'ldap.cidict.cidict.data is an internal attribute; it may be ' +
'removed at any time',
category=DeprecationWarning,
stacklevel=2,
)
return self._data


def strlist_minus(a,b):
"""
Expand Down
10 changes: 10 additions & 0 deletions Tests/t_cidict.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,16 @@ def test_strlist_deprecated(self):
strlist_func(["a"], ["b"])
self.assertEqual(len(w), 1)

def test_cidict_data(self):
"""test the deprecated data atrtribute"""
d = ldap.cidict.cidict({'A': 1, 'B': 2})
with warnings.catch_warnings(record=True) as w:
warnings.resetwarnings()
warnings.simplefilter('always', DeprecationWarning)
data = d.data
assert data == {'a': 1, 'b': 2}
self.assertEqual(len(w), 1)


if __name__ == '__main__':
unittest.main()

0 comments on commit dada91a

Please sign in to comment.