Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions src/core/IronPython.Modules/_socket.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1173,7 +1173,7 @@ public static object getnameinfo(CodeContext/*!*/ context, [NotNone] PythonTuple
// Host
IList<IPAddress> addrs;
try {
addrs = HostToAddresses(context, host, AddressFamily.InterNetwork);
addrs = HostToAddresses(context, host, AddressFamily.InterNetwork, getHostEntry: false);
} catch (IndexOutOfRangeException) {
throw MakeGaiException(context, EAI_NODATA);
}
Expand Down Expand Up @@ -2002,7 +2002,7 @@ private static IPAddress HostToAddress(CodeContext/*!*/ context, string host, Ad
/// not the same as the specified family. gaierror is also raised if the hostname cannot be
/// converted to an IP address (e.g. through a name lookup failure).
/// </summary>
private static IPAddress[] HostToAddresses(CodeContext/*!*/ context, string host, AddressFamily family) {
private static IPAddress[] HostToAddresses(CodeContext/*!*/ context, string host, AddressFamily family, bool getHostEntry = true) {
host = ConvertSpecialAddresses(host);
try {
bool numeric = true;
Expand All @@ -2022,6 +2022,9 @@ private static IPAddress[] HostToAddresses(CodeContext/*!*/ context, string host
}
// Incorrect family will raise EAI_NODATA exception below
} else {
if (!getHostEntry) {
throw MakeGaiException(context, EAI_NONAME);
}
IPHostEntry hostEntry = Dns.GetHostEntry(host);
List<IPAddress> addrs = new List<IPAddress>();
foreach (IPAddress ip in hostEntry.AddressList) {
Expand All @@ -2032,7 +2035,7 @@ private static IPAddress[] HostToAddresses(CodeContext/*!*/ context, string host
if (addrs.Count > 0) return addrs.ToArray();
}
throw MakeGaiException(context, EAI_NODATA);
} catch (SocketException ex) {
} catch (SocketException ex) {
throw MakeGaiException(context, ex);
}
}
Expand Down
1 change: 1 addition & 0 deletions src/core/IronPython/Runtime/Operations/StringOps.cs
Original file line number Diff line number Diff line change
Expand Up @@ -623,6 +623,7 @@ public static bool isalpha([NotNone] this string self) {
return true;
}

// new in Python 3.7
public static bool isascii([NotNone] this string self) {
foreach (char c in self) {
if (c > 0x7f) return false;
Expand Down
4 changes: 2 additions & 2 deletions tests/suite/modules/network_related/test__socket.py
Original file line number Diff line number Diff line change
Expand Up @@ -352,8 +352,8 @@ def test_getnameinfo(self):
host, service = _socket.getnameinfo( ("127.0.0.1", 80), 0)
self.assertEqual(service, "http")
#IP gives a TypeError
#self.assertRaises(SystemError, _socket.getnameinfo, ("127.0.0.1"), 8)
#self.assertRaises(SystemError, _socket.getnameinfo, (321), 8)
self.assertRaises(TypeError, _socket.getnameinfo, ("127.0.0.1"), 8)
self.assertRaises(TypeError, _socket.getnameinfo, (321), 8)
self.assertRaises(TypeError, _socket.getnameinfo, ("127.0.0.1"), '0')
self.assertRaises(TypeError, _socket.getnameinfo, ("127.0.0.1", 80, 0, 0, 0), 8)
self.assertRaises(_socket.gaierror, _socket.getnameinfo, ('no such host will ever exist', 80), 8)
Expand Down
4 changes: 0 additions & 4 deletions tests/suite/test_socket_stdlib.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,6 @@ def load_tests(loader, standard_tests, pattern):
failing_tests += [
test.test_socket.NonBlockingTCPTests('testRecv'), # TODO: figure out
]
if not is_mono:
failing_tests += [
test.test_socket.GeneralModuleTests('test_getnameinfo'), # https://github.com/IronLanguages/ironpython3/issues/1222
]
if is_linux:
failing_tests += [
test.test_socket.GeneralModuleTests('test_idna'), # TODO: figure out
Expand Down
Loading