-
Notifications
You must be signed in to change notification settings - Fork 291
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
Improve handling of bitfields in ctypes #1441
Conversation
22453b3
to
5d07702
Compare
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.
Looks good to me! Good thing you took this on since I almost certainly wouldn't have been as thorough! 😄
} | ||
} | ||
} else { | ||
throw PythonOps.TypeErrorForTypeMismatch("int", value); |
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 this bit is unreachable so you can throw InvalidOperationException?
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.
Right. It's a left-over from a pre-3.8 code version.
value = (BigInteger)bits; | ||
} | ||
|
||
} else if (value is bool bVal) { |
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.
Is this reachable or bool
will be caught by the IsBoolType
check above?
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.
No, not reachable. Again a leftover from a previous version.
@@ -50,6 +50,10 @@ public abstract class _Structure : CData { | |||
INativeType nativeType = NativeType; | |||
StructType st = (StructType)nativeType; | |||
|
|||
if (args is null) { // None passed as a sole argument |
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.
Interesting, None
gives null
here? Would adding the NotNoneAttribute
solve this?
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.
Yes, None
gives null
. This is the consequence that the DLR allows to bind to the param object[]
array directly (just like C#). We have discussed it before (IronLanguages/dlr#249). Although then I was arguing against it, I now think that for params arrays it will be better to keep the behaviour as it is now.
But indeed, [NotNone]
prevents it from happening, pushing null
into the params array. Good insight! It is an elegant solution.
Thanks for the review! |
Addressed #1439 and a few other issues that caught my attention. The most interesting is a fix for python/cpython#90914, which was reported just 3 months ago and is still not resolved. Funny thought that IronPython on one point will be ahead of CPython. Not that this functionality is used anywhere in the wild, since it is not working yet in CPython.