Review patch fixing packed bitfields in ctypes struct/union
Hi folks, I know this is a high-volume list so sorry for being yet another voice screaming into your mailbox, but I do not know how else to handle this. A few months ago, I opened a pull request fixing packed bitfields in ctypes struct/union, which right now are being incorrectly created. The offsets and size are all wrong in some cases, fields which should be packed end up with padding between them. bpo: https://bugs.python.org/issue29753 PR: https://github.com/python/cpython/pull/19850 Since ctypes has no maintainer it has been very hard tracking down someone who is up to review this. So, if this issue sparks some interest to you, or you just want to help me out, please have a look :) Cheers, Filipe Laíns
Hello! Thank you for this patch! I can't help land it, but it looks sane to me. I fear you have discovered a fundamental truth about ctypes though -- it tries to mimic what C compilers do and this inevitably leads to many discrepancies. E.g. if a C structure you're trying to use is wrapped in an #ifdef, one has to then try to mimic that ifdef in Python, which may be impossible or very fragile. If you're encountering such issues, you might save yourself future pain and bugs by switching to an alternative approach (cython, CFFI, struct module -- it depends on what problem you're trying to solve). Will hold thumbs that you find someone to review and merge the patch! Yours sincerely, Simon Cross
On 11/20/2020 4:03 AM, Simon Cross wrote:
Thank you for this [cttpes] patch! > I can't help land it, but it looks sane to me.
If you have a github account, you can help by reviewing it. Check the spelling, grammar, and clarity of comments, docstrings, and news item. Can the code be improved. If you have a local cpython clone, make a branch from the PR and test it. Does it really fix the issue? -- Terry Jan Reedy
The PR already has a fair amount of good review and discussion. Me doing a superficial review is not going to help get it merged.
On Fri, 2020-11-20 at 00:20 +0000, Filipe Laíns wrote:
Hi folks,
I know this is a high-volume list so sorry for being yet another voice screaming into your mailbox, but I do not know how else to handle this.
A few months ago, I opened a pull request fixing packed bitfields in ctypes struct/union, which right now are being incorrectly created. The offsets and size are all wrong in some cases, fields which should be packed end up with padding between them.
bpo: https://bugs.python.org/issue29753 PR: https://github.com/python/cpython/pull/19850
Since ctypes has no maintainer it has been very hard tracking down someone who is up to review this. So, if this issue sparks some interest to you, or you just want to help me out, please have a look :)
Cheers, Filipe Laíns
I am bumping this as the issue has not been resolved yet. I can jump into a call with someone to go over the code if that helps. Cheers, Filipe Laíns
participants (4)
-
Filipe Laíns
-
Filipe Laíns
-
Simon Cross
-
Terry Reedy