Skip to content

Conversation

oschwald
Copy link
Member

See also #48.

@oschwald oschwald force-pushed the greg/ipaddress-get-support branch 3 times, most recently from beac746 to d95b236 Compare September 20, 2019 21:16
@coveralls
Copy link

coveralls commented Sep 20, 2019

Coverage Status

Coverage increased (+1.6%) to 93.994% when pulling a14fed4 on greg/ipaddress-get-support into 6142e41 on master.

@oschwald oschwald force-pushed the greg/ipaddress-get-support branch from 54dd122 to 4ad1b14 Compare September 20, 2019 22:35
@oschwald oschwald force-pushed the greg/ipaddress-get-support branch from 4ad1b14 to c161311 Compare September 20, 2019 22:45
Copy link
Contributor

@horgh horgh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work!

// 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);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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!

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if we should check if addresses is null. I don't know how that would be possible though.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we check success?

addr = (char *)&sin->sin6_addr;
}

inet_ntop(sa->sa_family, addr, ip, INET6_ADDRSTRLEN);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we check success?

@horgh horgh merged commit 17a155b into master Sep 23, 2019
@horgh horgh deleted the greg/ipaddress-get-support branch September 23, 2019 21:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants