Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix uninitialized member failure #1894

Merged
merged 1 commit into from
Jun 9, 2022
Merged

Conversation

CristiFati
Copy link
Contributor

@CristiFati CristiFati commented Jun 8, 2022

First of all I want to mention that I don't have very much experience with COM, while its PyWin32 wrappers are some kind of a nebula.

I discovered this while investigating [SO]: win32com.client combrowse.main() (Python Object Browser) is not responding Python 3.9.

Very easy to reproduce:

[cfati@CFATI-5510-0:C:\Windows\System32]> "e:\Work\Dev\VEnvs\py_pc064_03.09_test0\Scripts\python.exe" -c "from win32com.client.combrowse import HLIRoot as HO;print(HO(''))"
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "e:\Work\Dev\VEnvs\py_pc064_03.09_test0\lib\site-packages\Pythonwin\pywin\tools\browser.py", line 56, in __repr__
    + repr(self.myobject)
AttributeError: 'HLIRoot' object has no attribute 'myobject'

At the beginning I wanted to modify browser.HLIPythonObject.__repr__, but I realized that would only be a lame workaround (gainarie), so after a bit of code browsing I came up with this.

After patching the file:

[cfati@CFATI-5510-0:C:\Windows\System32]> "e:\Work\Dev\VEnvs\py_pc064_03.09_test0\Scripts\python.exe" -c "from win32com.client.combrowse import HLIRoot as HO;print(HO(''))"
HLIPythonObject(Generic) - name: None object: None

As a note, the crash is no longer visible (the dialog only flashes, because the program terminates), but if adding a time.sleep after the dialog is displayed, it is mostly frozen, not sure should I call some of its methods (like Wndproc)? Not an MFC fan.

Copy link
Owner

@mhammond mhammond left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That makes sense and looks great, thanks!

@mhammond mhammond merged commit e1c0237 into mhammond:main Jun 9, 2022
@CristiFati CristiFati deleted the cfati_dev00 branch June 9, 2022 09:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants