Repository navigation
Add support for ipaddress objects in "get" method - #50
Merged
Merged
Conversation
oschwald
force-pushed
the
greg/ipaddress-get-support
branch
3 times, most recently
from
September 20, 2019 21:16
beac746 to
d95b236
Compare
oschwald
force-pushed
the
greg/ipaddress-get-support
branch
from
September 20, 2019 22:35
54dd122 to
4ad1b14
Compare
Also, add a missing return when getting packed attribute fails in extension.
oschwald
force-pushed
the
greg/ipaddress-get-support
branch
from
September 20, 2019 22:45
4ad1b14 to
c161311
Compare
horgh
requested changes
Sep 23, 2019
| // Although this should work on Python 3, we will hopefully delete | ||
| // this soon and the Python 3 version is cleaner. | ||
| const char *ipstr = PyString_AsString(obj); | ||
| Py_ssize_t len = strlen(ipstr); |
Contributor
There was a problem hiding this comment.
Would PyString_Size or something be more correct? Just thinking whether it is talking about bytes or not, and whether there could be internal NULs. But I don't know!
Member
Author
There was a problem hiding this comment.
I thought I tried it and it didn't work for some reason, but it seems to work now. I was trying to fix Python 2 support before my self-imposed deadline on Friday though so I was a bit rushed.
| ipstr); | ||
| return 0; | ||
| } | ||
| memcpy(ip_address, addresses->ai_addr, addresses->ai_addrlen); |
Contributor
There was a problem hiding this comment.
I wonder if we should check if addresses is null. I don't know how that would be possible though.
Member
Author
There was a problem hiding this comment.
Hmm, I think getaddrinfo would have to be out of spec for that to happen, but I suppose it doesn't hurt.
|
|
||
| static char *format_sockaddr(struct sockaddr *sa) | ||
| { | ||
| char *ip = calloc(INET6_ADDRSTRLEN, sizeof(char)); |
| addr = (char *)&sin->sin6_addr; | ||
| } | ||
|
|
||
| inet_ntop(sa->sa_family, addr, ip, INET6_ADDRSTRLEN); |
horgh
approved these changes
Sep 23, 2019
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
See also #48.