Issue #28815: Merge test_socket fix from 3.6