From 60b761b5b2ac4da380f89a3357a1628acb3b8471 Mon Sep 17 00:00:00 2001 From: Jon Dufresne Date: Wed, 14 Mar 2018 07:12:42 -0700 Subject: [PATCH] Remove long deprecated functions ldap.open() and ldap.init() The functions have been deprecated since at least 2011. That has been lots of time for library users to see the warning and update calling code. https://github.com/python-ldap/python-ldap/pull/124 --- Doc/reference/ldap.rst | 26 ++++---------------------- Lib/ldap/__init__.py | 2 +- Lib/ldap/functions.py | 30 ------------------------------ 3 files changed, 5 insertions(+), 53 deletions(-) diff --git a/Doc/reference/ldap.rst b/Doc/reference/ldap.rst index 5d15158..6203a2d 100644 --- a/Doc/reference/ldap.rst +++ b/Doc/reference/ldap.rst @@ -67,28 +67,6 @@ This module defines the following functions: :rfc:`4516` - Lightweight Directory Access Protocol (LDAP): Uniform Resource Locator -.. py:function:: open(host [, port=PORT]) -> LDAPObject object - - Opens a new connection with an LDAP server, and return an LDAP object (see - :ref:`ldap-objects`) used to perform operations on that server. *host* is a - string containing solely the host name. *port* is an integer specifying the - port where the LDAP server is listening (default is 389). - - .. deprecated:: 3.0 - - ``ldap.open()`` is deprecated. It will be removed in version 3.1. Use - :func:`ldap.initialize()` with a URI like ``'ldap://:'`` - instead. - -.. py:function:: init(host [, port=PORT]) -> LDAPObject object - - Alias of :func:`ldap.open()`. - - .. deprecated:: 3.0 - - ``ldap.init()`` is deprecated. It will be removed in version 3.1. Use - :func:`ldap.initialize()` with a URI like ``'ldap://:'`` - instead. .. py:function:: get_option(option) -> int|string @@ -100,6 +78,10 @@ This module defines the following functions: This function sets the value of the global option specified by *option* to *invalue*. +.. versionchanged:: 3.1 + + The deprecated functions ``ldap.init()`` and ``ldap.open()`` were removed. + .. _ldap-constants: diff --git a/Lib/ldap/__init__.py b/Lib/ldap/__init__.py index 72e1e4b..068f9e6 100644 --- a/Lib/ldap/__init__.py +++ b/Lib/ldap/__init__.py @@ -91,7 +91,7 @@ def release(self): # Create module-wide lock for serializing all calls into underlying LDAP lib _ldap_module_lock = LDAPLock(desc='Module wide') -from ldap.functions import open,initialize,init,get_option,set_option,escape_str,strf_secs,strp_secs +from ldap.functions import initialize,get_option,set_option,escape_str,strf_secs,strp_secs from ldap.ldapobject import NO_UNIQUE_ENTRY, LDAPBytesWarning diff --git a/Lib/ldap/functions.py b/Lib/ldap/functions.py index 6c351ef..ae83d08 100644 --- a/Lib/ldap/functions.py +++ b/Lib/ldap/functions.py @@ -85,36 +85,6 @@ def initialize(uri,trace_level=0,trace_file=sys.stdout,trace_stack_limit=None, b return LDAPObject(uri,trace_level,trace_file,trace_stack_limit,bytes_mode) -def open(host,port=389,trace_level=0,trace_file=sys.stdout,trace_stack_limit=None,bytes_mode=None): - """ - Return LDAPObject instance by opening LDAP connection to - specified LDAP host - - Parameters: - host - LDAP host and port, e.g. localhost - port - integer specifying the port number to use, e.g. 389 - trace_level - If non-zero a trace output of LDAP calls is generated. - trace_file - File object where to write the trace output to. - Default is to use stdout. - bytes_mode - Whether to enable "bytes_mode" for backwards compatibility under Py2. - """ - import warnings - warnings.warn( - 'ldap.open() is deprecated. Use ldap.initialize() instead. It will be ' - 'removed in python-ldap 3.1.', - category=DeprecationWarning, - stacklevel=2, - ) - return initialize('ldap://%s:%d' % (host,port),trace_level,trace_file,trace_stack_limit,bytes_mode) - -init = open - - def get_option(option): """ get_option(name) -> value