Skip to content

Deprecate cidict's strlist functions #336

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 5, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions Lib/ldap/cidict.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

See https://www.python-ldap.org/ for details.
"""
import warnings

from ldap import __version__

Expand Down Expand Up @@ -62,6 +63,11 @@ def strlist_minus(a,b):
Return list of all items in a which are not in b (a - b).
a,b are supposed to be lists of case-insensitive strings.
"""
warnings.warn(
"strlist functions are deprecated and will be removed in 3.4",
category=DeprecationWarning,
stacklevel=2,
)
temp = cidict()
for elt in b:
temp[elt] = elt
Expand All @@ -77,6 +83,11 @@ def strlist_intersection(a,b):
"""
Return intersection of two lists of case-insensitive strings a,b.
"""
warnings.warn(
"strlist functions are deprecated and will be removed in 3.4",
category=DeprecationWarning,
stacklevel=2,
)
temp = cidict()
for elt in a:
temp[elt] = elt
Expand All @@ -92,6 +103,11 @@ def strlist_union(a,b):
"""
Return union of two lists of case-insensitive strings a,b.
"""
warnings.warn(
"strlist functions are deprecated and will be removed in 3.4",
category=DeprecationWarning,
stacklevel=2,
)
temp = cidict()
for elt in a:
temp[elt] = elt
Expand Down
14 changes: 14 additions & 0 deletions Tests/t_cidict.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

import os
import unittest
import warnings

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

def test_strlist_deprecated(self):
strlist_funcs = [
ldap.cidict.strlist_intersection,
ldap.cidict.strlist_minus,
ldap.cidict.strlist_union
]
for strlist_func in strlist_funcs:
with warnings.catch_warnings(record=True) as w:
warnings.resetwarnings()
warnings.simplefilter("always", DeprecationWarning)
strlist_func(["a"], ["b"])
self.assertEqual(len(w), 1)


if __name__ == '__main__':
unittest.main()
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