diff --git a/com/win32com/client/connect.py b/com/win32com/client/connect.py index 7cb3969464..5a8f638351 100644 --- a/com/win32com/client/connect.py +++ b/com/win32com/client/connect.py @@ -24,9 +24,9 @@ def __del__(self): def _wrap(self, obj): useDispatcher = None if self.debug: - from win32com.server import dispatcher - - useDispatcher = dispatcher.DefaultDebugDispatcher + from win32com.server.dispatcher import ( + DefaultDebugDispatcher as useDispatcher, + ) return win32com.server.util.wrap(obj, useDispatcher=useDispatcher) def Connect(self, coInstance, eventInstance, eventCLSID=None): diff --git a/com/win32comext/axdebug/util.py b/com/win32comext/axdebug/util.py index 46806ae547..7b53fb3db0 100644 --- a/com/win32comext/axdebug/util.py +++ b/com/win32comext/axdebug/util.py @@ -34,23 +34,12 @@ def trace(*args): # (Now this is only true for Document objects, and Python # now does ensure this. +def _wrap(object, iid): + useDispatcher = None + if debugging: + from win32com.server.policy import DispatcherWin32trace as useDispatcher -def _wrap_nodebug(object, iid): - return win32com.server.util.wrap(object, iid) - - -def _wrap_debug(object, iid): - import win32com.server.policy - - dispatcher = win32com.server.policy.DispatcherWin32trace - return win32com.server.util.wrap(object, iid, useDispatcher=dispatcher) - - -if debugging: - _wrap = _wrap_debug -else: - _wrap = _wrap_nodebug - + return win32com.server.util.wrap(object, iid, useDispatcher=useDispatcher) def RaiseNotImpl(who=None): if who is not None: diff --git a/com/win32comext/axscript/client/scriptdispatch.py b/com/win32comext/axscript/client/scriptdispatch.py index 2c15d74367..150d471485 100644 --- a/com/win32comext/axscript/client/scriptdispatch.py +++ b/com/win32comext/axscript/client/scriptdispatch.py @@ -95,23 +95,16 @@ def _getdispid_(self, name, fdex): return win32com.server.policy.DynamicPolicy._getdispid_(self, name, fdex) -def _wrap_debug(obj): +def _wrap(obj): + useDispatcher = None + if debugging: + from win32com.server.policy import DispatcherWin32trace as useDispatcher return win32com.server.util.wrap( obj, usePolicy=StrictDynamicPolicy, - useDispatcher=win32com.server.policy.DispatcherWin32trace, + useDispatcher=useDispatcher, ) -def _wrap_nodebug(obj): - return win32com.server.util.wrap(obj, usePolicy=StrictDynamicPolicy) - - -if debugging: - _wrap = _wrap_debug -else: - _wrap = _wrap_nodebug - - def MakeScriptDispatch(engine, namespace): return _wrap(ScriptDispatch(engine, namespace))