Skip to content

Commit d7699f8

Browse files
committed
[python-ldap] Move _ldap to ldap._ldap
This is necessary in order for type checking due to: python/typing#1333 Given that _ldap is an internal module, this change is hopefully ok.
1 parent ea6b625 commit d7699f8

File tree

13 files changed

+25
-21
lines changed

13 files changed

+25
-21
lines changed

Doc/fake_ldap_module_for_documentation.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
11
"""
2-
A module that mocks `_ldap` for the purposes of generating documentation
2+
A module that mocks `ldap._ldap` for the purposes of generating documentation
33
4-
This module provides placeholders for the contents of `_ldap`, making it
5-
possible to generate documentation even _ldap is not compiled.
4+
This module provides placeholders for the contents of `ldap._ldap`, making it
5+
possible to generate documentation even if ldap._ldap is not compiled.
66
It should also make the documentation independent of which features are
77
available in the system OpenLDAP library.
88
99
The overly long module name will show up in AttributeError messages,
10-
hinting that this is not the actual _ldap.
10+
hinting that this is not the actual ldap._ldap.
1111
1212
See https://www.python-ldap.org/ for details.
1313
"""
1414

1515
import sys
1616

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

2020
from constants import CONSTANTS
2121
from pkginfo import __version__

Lib/ldap/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,10 @@
3434
_trace_file = sys.stderr
3535
_trace_stack_limit = None
3636

37-
import _ldap
37+
import ldap._ldap as _ldap
3838
assert _ldap.__version__==__version__, \
3939
ImportError(f'ldap {__version__} and _ldap {_ldap.__version__} version mismatch!')
40-
from _ldap import *
40+
from ldap._ldap import *
4141
# call into libldap to initialize it right now
4242
LIBLDAP_API_INFO = _ldap.get_option(_ldap.OPT_API_INFO)
4343

File renamed without changes.

Lib/ldap/controls/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
from ldap.pkginfo import __version__
1212

13-
import _ldap
13+
import ldap._ldap as _ldap
1414
assert _ldap.__version__==__version__, \
1515
ImportError(f'ldap {__version__} and _ldap {_ldap.__version__} version mismatch!')
1616

Lib/ldap/controls/libldap.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
from ldap.pkginfo import __version__
99

10-
import _ldap
10+
import ldap._ldap as _ldap
1111
assert _ldap.__version__==__version__, \
1212
ImportError(f'ldap {__version__} and _ldap {_ldap.__version__} version mismatch!')
1313

Lib/ldap/dn.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"""
66
from ldap.pkginfo import __version__
77

8-
import _ldap
8+
import ldap._ldap as _ldap
99
assert _ldap.__version__==__version__, \
1010
ImportError(f'ldap {__version__} and _ldap {_ldap.__version__} version mismatch!')
1111

Lib/ldap/functions.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
"""
2-
functions.py - wraps functions of module _ldap
2+
functions.py - wraps functions of module ldap._ldap
33
44
See https://www.python-ldap.org/ for details.
55
"""
@@ -14,7 +14,9 @@
1414
'strf_secs','strp_secs',
1515
]
1616

17-
import sys,pprint,time,_ldap,ldap
17+
import sys,pprint,time
18+
import ldap._ldap as _ldap
19+
import ldap
1820
from calendar import timegm
1921

2022
from ldap import LDAPError

Lib/ldap/ldapobject.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
"""
2-
ldapobject.py - wraps class _ldap.LDAPObject
2+
ldapobject.py - wraps class ldap._ldap.LDAPObject
33
44
See https://www.python-ldap.org/ for details.
55
"""
@@ -36,7 +36,9 @@
3636
# Tracing is only supported in debugging mode
3737
import traceback
3838

39-
import sys,time,pprint,_ldap,ldap,ldap.sasl,ldap.functions
39+
import sys,time,pprint
40+
import ldap._ldap as _ldap
41+
import ldap, ldap.sasl, ldap.functions
4042
import warnings
4143

4244
from ldap.schema import SCHEMA_ATTRS

Lib/slapdtest/_slapdtest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
from types import TracebackType
2020
from typing_extensions import Self
2121

22-
# Switch off processing .ldaprc or ldap.conf before importing _ldap
22+
# Switch off processing .ldaprc or ldap.conf before importing ldap._ldap
2323
os.environ['LDAPNOINIT'] = '1'
2424

2525
import ldap

MANIFEST.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ include MANIFEST.in Makefile CHANGES INSTALL LICENCE README TODO
22
include tox.ini .coveragerc
33
include Modules/*.c Modules/*.h
44
include Lib/ldap/py.typed
5-
include Lib/_ldap.pyi
5+
include Lib/ldap/_ldap.pyi
66
recursive-include Build *.cfg*
77
recursive-include Lib *.py
88
recursive-include Demo *.py

0 commit comments

Comments
 (0)