mhammond / pywin32

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

Fixed unbound global variables in `pywin.dialogs.ideoptions.OptionsPropPage`'s `OnFormat*` methods #2283

Open Avasam opened 3 weeks ago

Avasam commented 3 weeks ago

Looking at the implementation of interact.SaveFontPreferences this almost certainly meant to use the variables in interact. Although these still fail because calling self.GetFormat results in AttributeError: 'PyCPropertyPage' object has no attribute 'GetFormat':

>>> from pywin.dialogs import ideoptions; ideoptions.OptionsPropPage().OnFormatInput(None,None)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Program Files\Python39\lib\site-packages\Pythonwin\pywin\dialogs\ideoptions.py", line 122, in OnFormatInput
    fmt = self.GetFormat(formatInput)
  File "C:\Program Files\Python39\lib\site-packages\Pythonwin\pywin\mfc\object.py", line 24, in __getattr__
    return getattr(o, attr)
AttributeError: 'PyCPropertyPage' object has no attribute 'GetFormat'

For all I know these methods might always have been broken in the past 25 years. At least this allows us to turn on reportUnboundVariable in pyright.