Merge branch 'master' into pr/209
This commit is contained in:
commit
612b9f783f
21
bin/hy
21
bin/hy
@ -4,26 +4,5 @@ import sys
|
||||
from hy.cmdline import cmdline_handler
|
||||
|
||||
|
||||
class HyQuitter(object):
|
||||
def __init__(self, name):
|
||||
self.name = name
|
||||
|
||||
def __repr__(self):
|
||||
return "Use (%s) or Ctrl-D (i.e. EOF) to exit" % (self.name)
|
||||
|
||||
__str__ = __repr__
|
||||
|
||||
def __call__(self, code=None):
|
||||
try:
|
||||
sys.stdin.close()
|
||||
except:
|
||||
pass
|
||||
raise SystemExit(code)
|
||||
|
||||
|
||||
__builtins__.quit = HyQuitter('quit')
|
||||
__builtins__.exit = HyQuitter('exit')
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
sys.exit(cmdline_handler("hy", sys.argv))
|
||||
|
@ -49,6 +49,31 @@ from hy.models.symbol import HySymbol
|
||||
|
||||
_machine = Machine(Idle, 1, 0)
|
||||
|
||||
try:
|
||||
import __builtin__ as builtins
|
||||
except ImportError:
|
||||
import builtins
|
||||
|
||||
|
||||
class HyQuitter(object):
|
||||
def __init__(self, name):
|
||||
self.name = name
|
||||
|
||||
def __repr__(self):
|
||||
return "Use (%s) or Ctrl-D (i.e. EOF) to exit" % (self.name)
|
||||
|
||||
__str__ = __repr__
|
||||
|
||||
def __call__(self, code=None):
|
||||
try:
|
||||
sys.stdin.close()
|
||||
except:
|
||||
pass
|
||||
raise SystemExit(code)
|
||||
|
||||
builtins.quit = HyQuitter('quit')
|
||||
builtins.exit = HyQuitter('exit')
|
||||
|
||||
|
||||
class HyREPL(code.InteractiveConsole):
|
||||
def runsource(self, source, filename='<input>', symbol='single'):
|
||||
|
@ -91,3 +91,10 @@ def test_hy2py():
|
||||
assert len(ret[1]) > 1, f
|
||||
assert len(ret[2]) == 0, f
|
||||
assert i
|
||||
|
||||
|
||||
def test_bin_hy_builtins():
|
||||
import hy.cmdline # NOQA
|
||||
|
||||
assert str(exit) == "Use (exit) or Ctrl-D (i.e. EOF) to exit"
|
||||
assert str(quit) == "Use (quit) or Ctrl-D (i.e. EOF) to exit"
|
||||
|
Loading…
x
Reference in New Issue
Block a user