Skip to content

Commit

Permalink
simplify _wrap functions with debugging conditional
Browse files Browse the repository at this point in the history
  • Loading branch information
Avasam committed Mar 17, 2024
1 parent e0fda45 commit 3d2e7ce
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 31 deletions.
6 changes: 3 additions & 3 deletions com/win32com/client/connect.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
21 changes: 5 additions & 16 deletions com/win32comext/axdebug/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
17 changes: 5 additions & 12 deletions com/win32comext/axscript/client/scriptdispatch.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))

0 comments on commit 3d2e7ce

Please sign in to comment.