Skip to content
Browse files

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
  • Loading branch information...
1 parent 42c877c commit a76179351bccc80fa7f19571bed0e340e05f7a08 @cboos cboos committed
Showing with 4 additions and 5 deletions.
  1. +4 −5 IPython/lib/inputhook.py
View
9 IPython/lib/inputhook.py
@@ -18,10 +18,6 @@
import os
import sys
import warnings
-if os.name == 'posix':
- import select
-elif sys.platform == 'win32':
- import msvcrt
#-----------------------------------------------------------------------------
# Constants
@@ -43,13 +39,16 @@
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
#-----------------------------------------------------------------------------

0 comments on commit a761793

Please sign in to comment.
Something went wrong with that request. Please try again.