Skip to content

Commit dada91a

Browse files
committed
cidict: Re-add the data attribute
1 parent 2a2cef3 commit dada91a

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

Lib/ldap/cidict.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,17 @@ def has_key(self, key):
5858
"""Compatibility with python-ldap 2.x"""
5959
return key in self
6060

61+
@property
62+
def data(self):
63+
"""Compatibility with older IterableUserDict-based implementation"""
64+
warnings.warn(
65+
'ldap.cidict.cidict.data is an internal attribute; it may be ' +
66+
'removed at any time',
67+
category=DeprecationWarning,
68+
stacklevel=2,
69+
)
70+
return self._data
71+
6172

6273
def strlist_minus(a,b):
6374
"""

Tests/t_cidict.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,16 @@ def test_strlist_deprecated(self):
6262
strlist_func(["a"], ["b"])
6363
self.assertEqual(len(w), 1)
6464

65+
def test_cidict_data(self):
66+
"""test the deprecated data atrtribute"""
67+
d = ldap.cidict.cidict({'A': 1, 'B': 2})
68+
with warnings.catch_warnings(record=True) as w:
69+
warnings.resetwarnings()
70+
warnings.simplefilter('always', DeprecationWarning)
71+
data = d.data
72+
assert data == {'a': 1, 'b': 2}
73+
self.assertEqual(len(w), 1)
74+
6575

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

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy