Skip to content

Commit

Permalink
Remove long deprecated functions ldap.open() and ldap.init()
Browse files Browse the repository at this point in the history
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
  • Loading branch information
Jon Dufresne authored and Petr Viktorin committed Mar 14, 2018
1 parent 9a74c29 commit 60b761b
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 53 deletions.
26 changes: 4 additions & 22 deletions Doc/reference/ldap.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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://<hostname>:<port>'``
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://<hostname>:<port>'``
instead.

.. py:function:: get_option(option) -> int|string
Expand All @@ -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:

Expand Down
2 changes: 1 addition & 1 deletion Lib/ldap/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
30 changes: 0 additions & 30 deletions Lib/ldap/functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 60b761b

Please sign in to comment.