Message 125153 - Python tracker
Rereading the doc link I pointed at, I guess detach() is part of the new API since 3.1, so doesn't need to be checked for in 3.1+ code... but instead, may need to be coded as:
try:
sys.stdin = sys.stdin.detach()
except UnsupportedOperation:
pass