diff --git a/Lib/ldap/cidict.py b/Lib/ldap/cidict.py index db57468..3dcfe48 100644 --- a/Lib/ldap/cidict.py +++ b/Lib/ldap/cidict.py @@ -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): """ diff --git a/Tests/t_cidict.py b/Tests/t_cidict.py index b96a26e..6878617 100644 --- a/Tests/t_cidict.py +++ b/Tests/t_cidict.py @@ -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()