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

Enable creating subclasses of com_record #2361

Open
geppi opened this issue Aug 13, 2024 · 2 comments · May be fixed by #2437
Open

Enable creating subclasses of com_record #2361

geppi opened this issue Aug 13, 2024 · 2 comments · May be fixed by #2437

Comments

@geppi
Copy link
Contributor

geppi commented Aug 13, 2024

It would be desirable to create subclasses of com_record to enable typing of interface methods that expect a particular structure as a parameter.

I've just started to look into writing C/C++ Python extensions and therefore probably do not understand what problems it would create when the PyRecord::Type structure would be modified to allow this.

Wouldn't it be just sufficient to set the field:

Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags

and to define a function for the tp_new field in the PyRecord::Type structure?

This function could make use of the PyRecord::pythoncom_GetRecordFromGuids function to create the new instance.

I'm wondering what the reason was, to just allow the creation of com_record instances via the factory function win32com.client.Record and not allow the creation of subclasses. Would this open a Pandora's box of issues that I probably do not see?

@mhammond
Copy link
Owner

I suspect this was done for 20 year old reasons that no longer apply. I see no problem with allowing subclasses here.

@geppi
Copy link
Contributor Author

geppi commented Dec 13, 2024

I've opened PR #2437 to implement this.
This was trickier than expected.

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 a pull request may close this issue.

2 participants