From a76179351bccc80fa7f19571bed0e340e05f7a08 2011-10-09 12:12:00 From: Christian Boos Date: 2011-10-09 12:12:00 Subject: [PATCH] inputhook: improve stdin_ready() - move select and msvcrt imports in the function itself as they're only needed there - switch on os.name for platform dependent code - for unknow platforms, assume there's something to read --- diff --git a/IPython/lib/inputhook.py b/IPython/lib/inputhook.py index 782b4de..655c1d0 100644 --- a/IPython/lib/inputhook.py +++ b/IPython/lib/inputhook.py @@ -18,10 +18,6 @@ import ctypes import os import sys import warnings -if os.name == 'posix': - import select -elif sys.platform == 'win32': - import msvcrt #----------------------------------------------------------------------------- # Constants @@ -43,13 +39,16 @@ GUI_PYGLET = 'pyglet' def stdin_ready(): if os.name == 'posix': + import select infds, outfds, erfds = select.select([sys.stdin],[],[],0) if infds: return True else: return False - elif sys.platform == 'win32': + elif os.name == 'nt': + import msvcrt return msvcrt.kbhit() + return True # assume there's something so that we won't wait forever #-----------------------------------------------------------------------------