-
-
Notifications
You must be signed in to change notification settings - Fork 100
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
[server\register.py] Use WinDLL instead of windll + import improvement #737
Conversation
Thank you for taking on such a significant task. In this repository, the CI pipeline does not run automatically for contributor pull requests until the first PR is merged and approved by a maintainer. And I noticed that some of the CI pipeline's automated tests are failing. I recommend cherry-picking smaller, less impactful changes, such as the |
For the parts where Also, since your first PR has not yet been approved and merged, my approval is required each time you push changes to trigger the CI pipeline. |
I agree that the PR has a lot of changes, but if you review it commit per commit, it shouldn't be unmanageable. Creating multiple PR will require you the same amount of work but simply on a longer period of time because I won't open all the PR in one shot. If you still maintain your opinion, how do you expect me to divide the commit? One for
I think it's better to only keep OleDLL or WinDLL to have more consistent code. Having both of them is pretty useless since I specify the I choosed File "C:\Users\moi15moi\Documents\GitHub\comtypes\comtypes\test\test_showevents.py", line 24, in comtypes.test.test_showevents.ShowEventsExamples.StdFont_ShowEvents
Failed example:
font.Name = 'Arial'
Exception raised:
Traceback (most recent call last):
File "C:\Users\moi15moi\AppData\Local\Programs\Python\Python311\Lib\doctest.py", line 1353, in __run
exec(compile(example.source, filename, "single",
File "<doctest comtypes.test.test_showevents.ShowEventsExamples.StdFont_ShowEvents[5]>", line 1, in <module>
font.Name = 'Arial'
^^^^^^^^^
File "C:\Users\moi15moi\Documents\GitHub\comtypes\comtypes\_post_coinit\_cominterface_meta_patcher.py", line 33, in __setattr__
object.__setattr__(self, self.__map_case__.get(name.lower(), name), value)
File "C:\Users\moi15moi\Documents\GitHub\comtypes\comtypes\_memberspec.py", line 514, in fset
return obj.Invoke(memid, value, _invkind=invkind)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\moi15moi\Documents\GitHub\comtypes\comtypes\automation.py", line 879, in Invoke
dp = self.__make_dp(_invkind, *args)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\moi15moi\Documents\GitHub\comtypes\comtypes\automation.py", line 854, in __make_dp
array[i].value = a
^^^^^^^^^^^^^^
File "C:\Users\moi15moi\Documents\GitHub\comtypes\comtypes\automation.py", line 290, in _set_value
self._.c_void_p = _SysAllocStringLen(value, len(value))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "_ctypes/callproc.c", line 1000, in GetResult
OverflowError: Python int too large to convert to C long I am unsure why this issue only occurs with
I simply created a PR on my fork. It is easier for me since it automatically run the test. |
Nevertheless, there is value in splitting changes into multiple PRs one by one. Consider a case where changes to For example, "Small CLs" in "Google Engineering Practices Documentation" shows great practices about these.
When reviewing a PR related to a similar replacement task (#657) in the past, I noticed that a single PR with changes to the existing codebase spanning multiple modules and exceeding about 30 lines placed a cognitive burden on reviewers.1 I propose splitting PRs (or issues) based on the following priorities:
The basis for this prioritization is that this type of task does not require making extensive code changes all at once to avoid breaking something or ensuring functionality. Footnotes
|
Indeed, this is puzzling. That said, despite the issue described in #735, I think it’s reasonable to start by just only replacing |
I believe this memory leak is a one-time glitch. By re-running the failed jobs multiple times, it is possible to get CI results where this error does not occur. |
This perspective remains unchanged. |
Done. Let me know what you think. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since the CI has passed, it has been confirmed that there is no issue with the WinDLL
change itself.
Now, it's just a matter of adjusting the scope of the changes.
comtypes/server/register.py
Outdated
from ctypes import WinError, windll | ||
from ctypes import WinDLL, WinError | ||
from ctypes.wintypes import HKEY, LONG, LPCWSTR | ||
from os.path import abspath, basename, dirname, splitext |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's fine to leave os.path.foobar
as is. For #735, let's limit it to changes in the import and reference methods from ctypes
and comtypes
, and move the rest to a separate scope.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done. Let me know what you think.
- Prefer `from import` over `import` - Use LPCWSTR instead of c_wchar_p. - Don't directly import `comtypes.server.localserver` in a function.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you!
The PR written "Fix #735 ..." on the Kanban might automatically close by GitHub's "Linked Issue" feature when it is merged.
https://docs.github.com/en/issues/tracking-your-work-with-issues/using-issues/linking-a-pull-request-to-an-issue
Of course, I understand that the scope of #735 isn't limited to just the changes in server/register.py
.
If the issue does get closed, I’ll reopen it manually.
Fix #735 for the server\register.py module