Skip to content

Commit

Permalink
Added safety assertion when importing _ldap: ldap.pkginfo.__version__…
Browse files Browse the repository at this point in the history
… must match _ldap.__version__
  • Loading branch information
stroeder committed Nov 12, 2017
1 parent 0f8e8ba commit 072f5cf
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 11 deletions.
2 changes: 2 additions & 0 deletions CHANGES
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ Modules/
Lib/
* ldap.__version__, ldap.__author__ and ldap.__license__ now
imported from new sub-module ldap.pkginfo also to setup.py
* Added safety assertion when importing _ldap:
ldap.pkginfo.__version__ must match _ldap.__version__
* removed stand-alone module dsml
* slapdtest.SlapdObject.restart() just restarts slapd
without cleaning any data
Expand Down
4 changes: 4 additions & 0 deletions Lib/ldap/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,11 @@
_trace_file = sys.stderr
_trace_stack_limit = None

from ldap.pkginfo import __version__

import _ldap
assert _ldap.__version__==__version__, \
ImportError('ldap %s and _ldap %s version mismatch!' % (__version__,_ldap.__version__))
from _ldap import *

OPT_NAMES_DICT = {}
Expand Down
21 changes: 13 additions & 8 deletions Lib/ldap/controls/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,19 @@
Each class provides support for a certain control.
"""

from ldap import __version__
from ldap.pkginfo import __version__

import _ldap
assert _ldap.__version__==__version__, \
ImportError('ldap %s and _ldap %s version mismatch!' % (__version__,_ldap.__version__))

import ldap

try:
from pyasn1.error import PyAsn1Error
except ImportError:
PyAsn1Error = None


__all__ = [
'KNOWN_RESPONSE_CONTROLS',
Expand All @@ -32,13 +44,6 @@
# response control OID to class registry
KNOWN_RESPONSE_CONTROLS = {}

import _ldap,ldap

try:
from pyasn1.error import PyAsn1Error
except ImportError:
PyAsn1Error = None


class RequestControl:
"""
Expand Down
9 changes: 8 additions & 1 deletion Lib/ldap/controls/libldap.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,14 @@
See https://www.python-ldap.org/ for details.
"""

import _ldap,ldap
from ldap.pkginfo import __version__

import _ldap
assert _ldap.__version__==__version__, \
ImportError('ldap %s and _ldap %s version mismatch!' % (__version__,_ldap.__version__))

import ldap

from ldap.controls import RequestControl,LDAPControl,KNOWN_RESPONSE_CONTROLS


Expand Down
5 changes: 3 additions & 2 deletions Lib/ldap/dn.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,11 @@
- Tested with Python 2.0+
"""

from ldap import __version__

from ldap.pkginfo import __version__

import _ldap
assert _ldap.__version__==__version__, \
ImportError('ldap %s and _ldap %s version mismatch!' % (__version__,_ldap.__version__))

import ldap.functions

Expand Down

0 comments on commit 072f5cf

Please sign in to comment.