Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork32k
gh-132987: Support __index__() in the socket module#133093
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
gh-132987: Support __index__() in the socket module#133093
Uh oh!
There was an error while loading.Please reload this page.
Conversation
ntohl(), htonl(), if_indextoname(), getaddrinfo() now use __index__() ifavailable.Also fix the Argument Clinic names for module-level functions (althoughthis does not affect the user).
As a side effect, ValueError is now raised instead of OverflowError for negative values. See also#74020. |
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
class uint16_converter(CConverter): | ||
type = "uint16_t" | ||
converter = '_PyLong_UInt16_Converter' | ||
class uint32_converter(CConverter): | ||
type = "uint32_t" | ||
converter = '_PyLong_UInt32_Converter' |
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.
Would it be possible to move uint16_t and uint32_t converters directly to Argument Clinic as built-in converters?
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 am going to do this in more general way in a separate issue. There are other converters defined in different files.
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.
Ok, it makes sense.
} | ||
UNSIGNED_INT_CONVERTER(UInt16, uint16_t) | ||
UNSIGNED_INT_CONVERTER(UInt32, uint32_t) |
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.
You might use PyLong_AsUInt32() for this converter.
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, PyLong_AsUInt32 cannot be used as a converter. It has wrong signature and returns wrong 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.
See#133583.
Co-authored-by: Victor Stinner <vstinner@python.org>
4265854
intopython:mainUh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
ntohl(), htonl(), if_indextoname(), getaddrinfo() now useindex() if available.
Also fix the Argument Clinic names for module-level functions (although this does not affect the user).