What does it say when you turn on debugging? Deadlock with telnet is common when unexpected responses come from the server.
For example, the login() docs say: "If any of those prompts sent by the remote side don't match what's expected, this method will time-out, unless timeout is turned off."