From 1df78cf6695cfd46357436a69ae9f0398b2fb276 Mon Sep 17 00:00:00 2001 From: Avasam Date: Thu, 14 Mar 2024 12:28:45 -0400 Subject: [PATCH] Improve `DispatcherWin32dbg`'s deprecation warning and raised error (#2145) --- com/win32com/server/dispatcher.py | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/com/win32com/server/dispatcher.py b/com/win32com/server/dispatcher.py index 1b2fb4cea8..95791a3554 100644 --- a/com/win32com/server/dispatcher.py +++ b/com/win32com/server/dispatcher.py @@ -236,6 +236,13 @@ def _trace_(self, *args): win32api.OutputDebugString(str(args[-1]) + "\n") +DispatcherWin32dbg_deprecation_message = """\ +The DispatcherWin32dbg dispatcher is deprecated! +Please open an issue at https://github.com/mhammond/pywin32 is this is a problem. +Comment the relevant DeprecationWarning in dispatcher.py to re-enable.\ +""" + + class DispatcherWin32dbg(DispatcherBase): """A source-level debugger dispatcher @@ -246,10 +253,11 @@ class DispatcherWin32dbg(DispatcherBase): """ def __init__(self, policyClass, ob): + raise DeprecationWarning(DispatcherWin32dbg_deprecation_message) + # No one uses this, and it just causes py2exe to drag all of pythonwin in. + import pywin.debugger + pywin.debugger.brk() - print("The DispatcherWin32dbg dispatcher is deprecated!") - print("Please let me know if this is a problem.") - print("Uncomment the relevant lines in dispatcher.py to re-enable") # DEBUGGER Note - You can either: # * Hit Run and wait for a (non Exception class) exception to occur! # * Set a breakpoint and hit run. @@ -258,9 +266,12 @@ def __init__(self, policyClass, ob): def _HandleException_(self): """Invoke the debugger post mortem capability""" + raise DeprecationWarning(DispatcherWin32dbg_deprecation_message) # Save details away. typ, val, tb = exc_info() - # import pywin.debugger, pywin.debugger.dbgcon + import pywin.debugger + import pywin.debugger.dbgcon + debug = 0 try: raise typ(val)