Skip to content

Commit 269df17

Browse files
authored
Deprecate cidict's strlist functions
The functions are undocumented, untested, unused, and can now be trivialy implemented with set operations. python-ldap#336 Signed-off-by: Christian Heimes <cheimes@redhat.com>
1 parent f8f10a9 commit 269df17

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-0
lines changed

Lib/ldap/cidict.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
66
See https://www.python-ldap.org/ for details.
77
"""
8+
import warnings
89

910
from ldap import __version__
1011

@@ -62,6 +63,11 @@ def strlist_minus(a,b):
6263
Return list of all items in a which are not in b (a - b).
6364
a,b are supposed to be lists of case-insensitive strings.
6465
"""
66+
warnings.warn(
67+
"strlist functions are deprecated and will be removed in 3.4",
68+
category=DeprecationWarning,
69+
stacklevel=2,
70+
)
6571
temp = cidict()
6672
for elt in b:
6773
temp[elt] = elt
@@ -77,6 +83,11 @@ def strlist_intersection(a,b):
7783
"""
7884
Return intersection of two lists of case-insensitive strings a,b.
7985
"""
86+
warnings.warn(
87+
"strlist functions are deprecated and will be removed in 3.4",
88+
category=DeprecationWarning,
89+
stacklevel=2,
90+
)
8091
temp = cidict()
8192
for elt in a:
8293
temp[elt] = elt
@@ -92,6 +103,11 @@ def strlist_union(a,b):
92103
"""
93104
Return union of two lists of case-insensitive strings a,b.
94105
"""
106+
warnings.warn(
107+
"strlist functions are deprecated and will be removed in 3.4",
108+
category=DeprecationWarning,
109+
stacklevel=2,
110+
)
95111
temp = cidict()
96112
for elt in a:
97113
temp[elt] = elt

Tests/t_cidict.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
import os
99
import unittest
10+
import warnings
1011

1112
# Switch off processing .ldaprc or ldap.conf before importing _ldap
1213
os.environ['LDAPNOINIT'] = '1'
@@ -48,6 +49,19 @@ def test_cidict(self):
4849
self.assertEqual(cix.has_key("abcdef"), False)
4950
self.assertEqual(cix.has_key("AbCDef"), False)
5051

52+
def test_strlist_deprecated(self):
53+
strlist_funcs = [
54+
ldap.cidict.strlist_intersection,
55+
ldap.cidict.strlist_minus,
56+
ldap.cidict.strlist_union
57+
]
58+
for strlist_func in strlist_funcs:
59+
with warnings.catch_warnings(record=True) as w:
60+
warnings.resetwarnings()
61+
warnings.simplefilter("always", DeprecationWarning)
62+
strlist_func(["a"], ["b"])
63+
self.assertEqual(len(w), 1)
64+
5165

5266
if __name__ == '__main__':
5367
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