mhammond / pywin32

Python for Windows (pywin32) Extensions
4.91k stars 783 forks source link

Improve `DispatcherWin32dbg`'s deprecation warning and raised error #2145

Closed Avasam closed 3 months ago

Avasam commented 8 months ago

This used to raise without even printing the warning!

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
NameError: name 'pywin' is not defined

I could've moved the print statements up, but instead I've improved the error by raising a DeprecationWarning with the message:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
DeprecationWarning: The DispatcherWin32dbg dispatcher is deprecated!
Please let me know if this is a problem.
Comment the relevant DeprecationWarning in dispatcher.py to re-enable

Note that if you want to send an actual warning, we should use the warning module. But this used to raise an error already. It's just clearer now.

Alternatively we could just remove this class entirely if you did not get any report of users needing it.