-
-
Notifications
You must be signed in to change notification settings - Fork 98
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
Documentation should mention that it is unnecessary to release returned objects #612
Comments
Hi, @bytesized. Indeed, those who are familiar with COM and are used to explicitly releasing COM interface pointers that are no longer in use might find this package's implementation weird. The originator of this package likely aimed to make it easier for users to work with the COM framework by using Through the functionality of metaclasses, when an instance of an comtypes/comtypes/_post_coinit/unknwn.py Lines 371 to 386 in 3e3977d
Additionally, it's worth mentioning that when the Line 180 in 3e3977d
comtypes/comtypes/_post_coinit/unknwn.py Lines 25 to 47 in 3e3977d
comtypes/comtypes/_post_coinit/unknwn.py Lines 54 to 66 in 3e3977d
It is true that there is no documentation indicating that users generally do not need to manually call |
In the past, changes were made in #215 to define However, I should mention that if alternative cleanup operations are not performed or the modified class attributes are not restored, it will be necessary to manually and properly release the COM pointers present in the running Python interpreter. |
As a byproduct of investigating the issues with Python 3.13 and metaclasses in #618, I came across several projects that apply workarounds to Some of these projects used Since version 1.4.5, the definition of
In #215, the behavior at shutdown was made customizable for users by turning the function hooked to Similarly, it might benefit users if |
Coming from
C++
COM, where very simple COM usage looks likeit was highly confusing to try out this library for the first time and do something like this
I tried looking through the documentation for
CreateObject
and using the search bar to look for "Release" and a few similar search terms, but couldn't find anything related.This feels weird since
AddRef
andRelease
are standard COM methods and are made available to the interface consumer. They just don't quite seem to work as expected. Normally, things are handed to you (byCoCreateInstance
, for example) alreadyAddRef
ed. So you have toRelease
them, plus an additionalRelease
for every additionalAddRef
. But this implementation does not match this; it's strictly oneRelease
perAddRef
.It seems like if this COM library is going to differ from the usual COM conventions, the documentation should at least mention it.
The text was updated successfully, but these errors were encountered: