From be8e3c6ca28ca2468aee5828073583fbe92b0c14 Mon Sep 17 00:00:00 2001 From: Petr Viktorin Date: Mon, 30 Jul 2018 19:01:48 +0200 Subject: [PATCH] Lib/ldap: Provide _trace atributes in non-debug mode 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 --- Lib/ldap/__init__.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Lib/ldap/__init__.py b/Lib/ldap/__init__.py index 068f9e6..951f957 100644 --- a/Lib/ldap/__init__.py +++ b/Lib/ldap/__init__.py @@ -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__, \