#81 DoBrowse() dialog broken

open
nobody
Outlook (17)
5
2007-03-13
2007-03-13
No

On all my test systems (WinXP/WinVistaX64 / OL2007 / Python 2.4.4 / Pythonwin 210) clicking on the 'Browse' buttons in SpamBayes Manager on tab 'Notifications' gave an exception:

TypeError: Argument must be a 88-byte string

I couldn't find out the exact reason of the error because a shortage of documentation. So I wrote a reimplementation using GetOpenFileNameW() instead of GetOpenFileName().

I don't know if the previous code works on older versions of pythonwin32. So I left the old code unchanged and I think that this workaround maybe is the best solution for the problem.

Discussion

  • Mark Hammond

    Mark Hammond - 2007-03-14

    Logged In: YES
    user_id=14198
    Originator: NO

    It still works fine for me with the current CVS of pywin32. The code in question references 'sizeof(OPENFILENAME)' - is it possible you are building your own pywin32, and the windows headers you use have a different definition of OPENFILENAME?

    Looking at CommDlg.h, I see there are various different OPENFILENAME structures (eg, LPOPENFILENAME_NT4) - that is probably the root cause of the problem. I'm reluctant to apply this patch without better understanding the problem you are seeing.

     
  • Marko von Oppen

    Marko von Oppen - 2007-03-14

    Logged In: YES
    user_id=260951
    Originator: YES

    No I'm not using any self compiled pywin32 but official binary distributions of both Python and pywin32.

    I can reproduce that on two machines:
    1. Vista x64 German
    Python 2.4.4 (binary install from python.org)
    pywin32-2.4-210 binary (downloaded and installed from sf.net)
    2. Vmware pc (Host: XP SP2, Guest; XP SP2)
    Python 2.4.4 (binary install from python.org)
    pywin32-2.4-210 binary (downloaded and installed from sf.net)

    Here the output from console when running Outlook2000\dialogs\test_dialogs.py and clicking on the browse buttons:
    Traceback (most recent call last):
    File "S:\sbdev\spambayes_clean\Outlook2000\dialogs\dlgcore.py", line 310, in OnCommand
    self.ApplyHandlingOptionValueError(handler.OnCommand, wparam, lparam)
    File "S:\sbdev\spambayes_clean\Outlook2000\dialogs\dlgcore.py", line 262, in ApplyHandlingOptionValueError
    return func(*args)
    File "S:\sbdev\spambayes_clean\Outlook2000\dialogs\opt_processors.py", line 288, in OnCommand
    self.DoBrowse()
    File "S:\sbdev\spambayes_clean\Outlook2000\dialogs\opt_processors.py", line 277, in DoBrowse
    retval = win32gui.GetOpenFileName(str(ofn))
    TypeError: Argument must be a 88-byte string

    I tried to reproduce that under a clean installed Python 2.5 with pywin32-210 and got another error: When starting test_dialogs.py and clicking on an arbitrary tab I always get 3 exceptions:

    Python WNDPROC handler failed
    Traceback (most recent call last):
    File "S:\sbdev\spambayes_clean\Outlook2000\dialogs\dlgcore.py", line 288, in OnNotify
    hwndFrom, idFrom, code = struct.unpack(format, buf)
    File "C:\Python25\lib\struct.py", line 87, in unpack
    return o.unpack(s)
    struct.error: unpack requires a string argument of length 12
    Python WNDPROC handler failed
    Traceback (most recent call last):
    File "S:\sbdev\spambayes_clean\Outlook2000\dialogs\dlgcore.py", line 288, in OnNotify
    hwndFrom, idFrom, code = struct.unpack(format, buf)
    File "C:\Python25\lib\struct.py", line 87, in unpack
    return o.unpack(s)
    struct.error: unpack requires a string argument of length 12
    Python WNDPROC handler failed
    Traceback (most recent call last):
    File "S:\sbdev\spambayes_clean\Outlook2000\dialogs\dlgcore.py", line 288, in OnNotify
    hwndFrom, idFrom, code = struct.unpack(format, buf)
    File "C:\Python25\lib\struct.py", line 87, in unpack
    return o.unpack(s)
    struct.error: unpack requires a string argument of length 12

    Looking a little bit like coming from the same corner...

    Because I think it won't be so easy to debug the C code in the binary release I will have a look at the Python part.

    Marko

     

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks