@@ -1173,7 +1173,7 @@ public static object getnameinfo(CodeContext/*!*/ context, [NotNone] PythonTuple
11731173 // Host
11741174 IList < IPAddress > addrs ;
11751175 try {
1176- addrs = HostToAddresses ( context , host , AddressFamily . InterNetwork ) ;
1176+ addrs = HostToAddresses ( context , host , AddressFamily . InterNetwork , getHostEntry : false ) ;
11771177 } catch ( IndexOutOfRangeException ) {
11781178 throw MakeGaiException ( context , EAI_NODATA ) ;
11791179 }
@@ -2002,7 +2002,7 @@ private static IPAddress HostToAddress(CodeContext/*!*/ context, string host, Ad
20022002 /// not the same as the specified family. gaierror is also raised if the hostname cannot be
20032003 /// converted to an IP address (e.g. through a name lookup failure).
20042004 /// </summary>
2005- private static IPAddress [ ] HostToAddresses ( CodeContext /*!*/ context , string host , AddressFamily family ) {
2005+ private static IPAddress [ ] HostToAddresses ( CodeContext /*!*/ context , string host , AddressFamily family , bool getHostEntry = true ) {
20062006 host = ConvertSpecialAddresses ( host ) ;
20072007 try {
20082008 bool numeric = true ;
@@ -2022,6 +2022,9 @@ private static IPAddress[] HostToAddresses(CodeContext/*!*/ context, string host
20222022 }
20232023 // Incorrect family will raise EAI_NODATA exception below
20242024 } else {
2025+ if ( ! getHostEntry ) {
2026+ throw MakeGaiException ( context , EAI_NONAME ) ;
2027+ }
20252028 IPHostEntry hostEntry = Dns . GetHostEntry ( host ) ;
20262029 List < IPAddress > addrs = new List < IPAddress > ( ) ;
20272030 foreach ( IPAddress ip in hostEntry . AddressList ) {
@@ -2032,7 +2035,7 @@ private static IPAddress[] HostToAddresses(CodeContext/*!*/ context, string host
20322035 if ( addrs . Count > 0 ) return addrs . ToArray ( ) ;
20332036 }
20342037 throw MakeGaiException ( context , EAI_NODATA ) ;
2035- } catch ( SocketException ex ) {
2038+ } catch ( SocketException ex ) {
20362039 throw MakeGaiException ( context , ex ) ;
20372040 }
20382041 }
0 commit comments