Skip to content

Commit

Permalink
Lib/ldap: Provide _trace atributes in non-debug mode
Browse files Browse the repository at this point in the history
All use of these attributes *should* be guarded by `if __debug__`.
However, that's not always the case. Providing different API based
on __debug__ is unnecessarily fragile.

This is intended as a quick fix for a maintenance release.

Fixes: https://github.com/python-ldap/python-ldap/issues/226
  • Loading branch information
Petr Viktorin committed Jul 30, 2018
1 parent 363e417 commit be8e3c6
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions Lib/ldap/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,13 @@
_trace_file = open(_trace_file, 'a')
atexit.register(_trace_file.close)
_trace_stack_limit = None
else:
# Any use of the _trace attributes should be guarded by `if __debug__`,
# so they should not be needed here.
# But, providing different API for debug mode is unnecessarily fragile.
_trace_level = 0
_trace_file = sys.stderr
_trace_stack_limit = None

import _ldap
assert _ldap.__version__==__version__, \
Expand Down

0 comments on commit be8e3c6

Please sign in to comment.