Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
e4dced2
[python-ldap] Remove compatibility wrappers for Py2/Py3
Alphix Jan 26, 2024
8cffd59
[python-ldap] Make __version__ imports more consistent
Alphix Jan 26, 2024
12296b5
[python-ldap] Type fixes for Lib/ldap/__init__.py
Alphix Jan 26, 2024
22b93fd
[python-ldap] Type fixes for Lib/ldap/asyncsearch.py
Alphix Jan 26, 2024
d3a8eda
[python-ldap] Type fixes for Lib/ldap/cidict.py
Alphix Jan 26, 2024
3ece60b
[python-ldap] Type fixes for Lib/ldap/constants.py
Alphix Jan 26, 2024
de58066
[python-ldap] Type fixes for Lib/ldap/controls/psearch.py
Alphix Jan 26, 2024
750d7b5
[python-ldap] Type fixes for Lib/ldap/controls/psearch.py
Alphix Jan 26, 2024
be76c0f
[python-ldap] Type fixes for Lib/ldap/controls/simple.py
Alphix Jan 26, 2024
5cd19ac
[python-ldap] Type fixes for Lib/ldap/controls/sss.py
Alphix Jan 26, 2024
b03a788
[python-ldap] Type fixes for Lib/ldap/extop/__init__.py
Alphix Jan 26, 2024
797345c
[python-ldap] Type fixes for Lib/ldap/modlist.py
Alphix Jan 26, 2024
b987005
[python-ldap] Type fixes for Lib/ldap/resiter.py
Alphix Jan 26, 2024
dfba175
[python-ldap] Type fixes for Lib/ldap/sasl.py
Alphix Jan 26, 2024
3669da2
[python-ldap] Type fixes for Lib/ldap/syncrepl.py
Alphix Jan 27, 2024
de5cbeb
[python-ldap] Type fixes for Lib/ldapurl.py
Alphix Jan 27, 2024
bb2ce4d
[python-ldap] Type fixes for Lib/slaptest/*
Alphix Jan 27, 2024
26c8efa
[python-ldap] Type fixes for Lib/ldif.py
Alphix Jan 27, 2024
6851dba
[python-ldap] Type fixes for Lib/ldap/ldapobject.py
Alphix Jan 27, 2024
2e4ca9e
[python-ldap] Type fixes for Lib/ldap/schema/subentry.py
Alphix Jan 27, 2024
ff4a332
[python-ldap] Type fixes for Lib/ldap/schema/models.py
Alphix Jan 27, 2024
94f2ee3
[python-ldap] Type fixes for Lib/ldap/controls/openldap.py
Alphix Jan 27, 2024
58078e8
[python-ldap] Type fixes for Lib/ldap/controls/pagedresults.py
Alphix Jan 27, 2024
3d99e7a
[python-ldap] Type fixes for Lib/ldap/extop/__init__.py
Alphix Jan 27, 2024
56d5411
[python-ldap] Improve documentation in Lib/ldap/dn.py
Alphix Jan 27, 2024
f7335e9
[python-ldap] Fix KNOWN_RESPONSE_CONTROLS registration in Lib/ldap/co…
Alphix Jan 27, 2024
9ee2836
[python-ldap] Add type annotations
Alphix Jan 27, 2024
b061236
[python-ldap] Integrate typing into the build/CI system
Alphix Jan 27, 2024
9dd6c0e
[python-ldap] Move _ldap to ldap._ldap
Alphix Jan 30, 2024
80a7ff4
[python-ldap] Add stubtest to typing CI
Alphix Jan 30, 2024
e59d703
[python-ldap] Refresh type annotations branch on top of main
Alphix Jun 1, 2026
c68dcba
[python-ldap] Remove threading fallback
Alphix Jun 1, 2026
9bb9c39
[python-ldap] Replace Optional[X] with X | None
Alphix Jun 1, 2026
1cb6135
[python-ldap] Generate _ldap.pyi constants from constants.py
Alphix Jun 1, 2026
ebf5da0
[python-ldap] Fix mypy compatibility for componentType overrides
Alphix Jun 1, 2026
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
12 changes: 6 additions & 6 deletions 12 Doc/fake_ldap_module_for_documentation.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
"""
A module that mocks `_ldap` for the purposes of generating documentation
A module that mocks `ldap._ldap` for the purposes of generating documentation

This module provides placeholders for the contents of `_ldap`, making it
possible to generate documentation even _ldap is not compiled.
This module provides placeholders for the contents of `ldap._ldap`, making it
possible to generate documentation even if ldap._ldap is not compiled.
It should also make the documentation independent of which features are
available in the system OpenLDAP library.

The overly long module name will show up in AttributeError messages,
hinting that this is not the actual _ldap.
hinting that this is not the actual ldap._ldap.

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

import sys

# Cause `import _ldap` to import this module instead of the actual `_ldap`.
sys.modules['_ldap'] = sys.modules[__name__]
# Cause `import ldap._ldap` to import this module instead of the actual module.
sys.modules['ldap._ldap'] = sys.modules[__name__]

from constants import CONSTANTS
from pkginfo import __version__
Expand Down
45 changes: 20 additions & 25 deletions 45 Lib/ldap/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,27 @@

# This is also the overall release version number

from __future__ import annotations
from ldap.pkginfo import __version__, __author__, __license__

import os
import sys

import threading

from typing import Any, Type


if __debug__:
# Tracing is only supported in debugging mode
import atexit
import traceback
_trace_level = int(os.environ.get("PYTHON_LDAP_TRACE_LEVEL", 0))
_trace_file = os.environ.get("PYTHON_LDAP_TRACE_FILE")
if _trace_file is None:
_trace_file_path = os.environ.get("PYTHON_LDAP_TRACE_FILE")
if _trace_file_path is None:
_trace_file = sys.stderr
else:
_trace_file = open(_trace_file, 'a')
_trace_file = open(_trace_file_path, 'a')
atexit.register(_trace_file.close)
_trace_stack_limit = None
else:
Expand All @@ -31,10 +37,10 @@
_trace_file = sys.stderr
_trace_stack_limit = None

import _ldap
import ldap._ldap as _ldap
assert _ldap.__version__==__version__, \
ImportError(f'ldap {__version__} and _ldap {_ldap.__version__} version mismatch!')
from _ldap import *
from ldap._ldap import *
# call into libldap to initialize it right now
LIBLDAP_API_INFO = _ldap.get_option(_ldap.OPT_API_INFO)

Expand All @@ -43,22 +49,7 @@
if k.startswith('OPT_'):
OPT_NAMES_DICT[v]=k

class DummyLock:
"""Define dummy class with methods compatible to threading.Lock"""
def __init__(self):
pass
def acquire(self):
pass
def release(self):
pass

try:
# Check if Python installation was build with thread support
import threading
except ImportError:
LDAPLockBaseClass = DummyLock
else:
LDAPLockBaseClass = threading.Lock
LDAPLockBaseClass = threading.Lock


class LDAPLock:
Expand All @@ -69,7 +60,11 @@ class LDAPLock:
"""
_min_trace_level = 3

def __init__(self,lock_class=None,desc=''):
def __init__(
self,
lock_class: Type[Any] | None = None,
desc: str = ''
) -> None:
"""
lock_class
Class compatible to threading.Lock
Expand All @@ -79,19 +74,19 @@ def __init__(self,lock_class=None,desc=''):
self._desc = desc
self._lock = (lock_class or LDAPLockBaseClass)()

def acquire(self):
def acquire(self) -> bool:
if __debug__:
global _trace_level
if _trace_level>=self._min_trace_level:
_trace_file.write('***{}.acquire() {} {}\n'.format(self.__class__.__name__,repr(self),self._desc))
return self._lock.acquire()

def release(self):
def release(self) -> None:
if __debug__:
global _trace_level
if _trace_level>=self._min_trace_level:
_trace_file.write('***{}.release() {} {}\n'.format(self.__class__.__name__,repr(self),self._desc))
return self._lock.release()
self._lock.release()


# Create module-wide lock for serializing all calls into underlying LDAP lib
Expand Down
Loading
Morty Proxy This is a proxified and sanitized view of the page, visit original site.