Antoine Pitrou added the comment:
The problem is not in the import, but when displaying the traceback of the
exception. In other words, if you catch the exception, no attempt to open
stdin happens:
$ strace -e open ./python
[...]
Python 3.5.0a0 (default:3417a95df7e2, Apr 16 2014, 17:57:12)
Antoine Pitrou added the comment:
Also, by construction it will only happen if the import happens under the
interpreter prompt (hence the stdin filename).
I honestly don't think this deserves introducing some complication, only to
avoid a couple filesystem accesses.
--