Merge branch 'master' into pr/209

This commit is contained in:
Paul Tagliamonte 2013-06-25 19:24:29 -04:00
commit 612b9f783f
3 changed files with 32 additions and 21 deletions

21
bin/hy
View File

@ -4,26 +4,5 @@ import sys
from hy.cmdline import cmdline_handler 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__': if __name__ == '__main__':
sys.exit(cmdline_handler("hy", sys.argv)) sys.exit(cmdline_handler("hy", sys.argv))

View File

@ -49,6 +49,31 @@ from hy.models.symbol import HySymbol
_machine = Machine(Idle, 1, 0) _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): class HyREPL(code.InteractiveConsole):
def runsource(self, source, filename='<input>', symbol='single'): def runsource(self, source, filename='<input>', symbol='single'):

View File

@ -91,3 +91,10 @@ def test_hy2py():
assert len(ret[1]) > 1, f assert len(ret[1]) > 1, f
assert len(ret[2]) == 0, f assert len(ret[2]) == 0, f
assert i 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"