Explorar el Código

Make readline import optional

Ryan C. Thompson hace 6 años
padre
commit
130932244c
Se han modificado 1 ficheros con 6 adiciones y 1 borrados
  1. 6 1
      roll.py

+ 6 - 1
roll.py

@@ -4,7 +4,6 @@ import attr
 import logging
 import re
 import sys
-import readline
 import operator
 import traceback
 from numbers import Number
@@ -40,6 +39,12 @@ logger.addHandler(logging.StreamHandler())
 for handler in logger.handlers:
     handler.setFormatter(logFormatter)
 
+try:
+    # If imported, input() automatically uses it
+    import readline
+except ImportError:
+    logger.warning("Could not import readline: Advanced line editing unavailable")
+
 sysrand = SystemRandom()
 randint = sysrand.randint