Bug #68053 Connector/Python breaks on Windows7
Submitted: 8 Jan 2013 23:19 Modified: 26 Feb 2013 12:57
Reporter: Daniel Padwa Email Updates:
Status: Closed Impact on me:
None 
Category:Connector / Python Severity:S2 (Serious)
Version:1.0.8 OS:Windows (Windows 7)
Assigned to: Geert Vanderkelen CPU Architecture:Any

[8 Jan 2013 23:19] Daniel Padwa
Description:
Connector/Python emulates inet_pton in network.py.   With Python 2.6 on Windows 7, it calls into the ws2_32.dll inet_pton function, but misinterprets the error status.   This breaks IPv4 connectivity.

How to repeat:
Try to use the connector on Windows7 to connect over IPv4.  You get an InterfaceError

Suggested fix:
Change the comparison on line 53 of network.py to be res<=0 instead of res==0.   This will cause a -1 return code from inet_pton to be properly interpreted as an error, and thus cause a fallback to IPv4.
[24 Jan 2013 18:41] Sveta Smirnova
Thank you for the report.

Verified as described using code analysis and this manual: http://msdn.microsoft.com/en-us/library/windows/desktop/cc805844%28v=vs.85%29.aspx
[28 Jan 2013 10:12] Geert Vanderkelen
Thanks for the report.
The problem found in bug #68065 is similar, and we will fix both with the same patch.

Marking bug #68065 as duplicate of #68053.
[26 Feb 2013 12:57] Geert Vanderkelen
Please check MySQL Connector/Python 1.0.9.
[26 Feb 2013 13:03] Geert Vanderkelen
Changelog for 1.0.9:

Fixed IPv6 for older Microsoft Windows versions. Also improved the associated code for all operating systems: we now use socket.getaddrinfo() instead of inet_pton() to check whether we are connecting using IPv4 or IPv6.

A new connection option force_ipv6 has been introduced. When set to True, IPv6 will be used when an address resolves to both IPv4 and IPv6. Otherwise, IPv4 is favored.