TIL: A Linux IPv6 socket will accept IPv4 connections (unless the IPV6_V6ONLY socket option is set). That's nice.
Such a socket bound to the loopback address (127.0.0.1 or ::1) will accept connections received on other interfaces. That's a bit more of a surprise.
Oops, if it's actually on the loopback interface it won't accept connections from other interfaces which is less of a surprise.
(Got muddled up between Python code which wasn't working as expected and version written in C to make sure I understood the underlying interface.)