Merge pull request #999 from Scorpil/fix_repl_bug_issue_982
Fix cmdline error to string conversion.
This commit is contained in:
commit
ba03d2351c
1
AUTHORS
1
AUTHORS
@ -66,3 +66,4 @@
|
|||||||
* Matthew Egan Odendahl <github.gilch@xoxy.net>
|
* Matthew Egan Odendahl <github.gilch@xoxy.net>
|
||||||
* Tim Martin <tim@asymptotic.co.uk>
|
* Tim Martin <tim@asymptotic.co.uk>
|
||||||
* Johnathon Mlady <john@digitalvectorz.com>
|
* Johnathon Mlady <john@digitalvectorz.com>
|
||||||
|
* Andrew Savchyn <dev@scorpil.com>
|
||||||
|
@ -97,7 +97,7 @@ class HyREPL(code.InteractiveConsole):
|
|||||||
if e.source is None:
|
if e.source is None:
|
||||||
e.source = source
|
e.source = source
|
||||||
e.filename = filename
|
e.filename = filename
|
||||||
sys.stderr.write(str(e))
|
print(e, file=sys.stderr)
|
||||||
return False
|
return False
|
||||||
|
|
||||||
try:
|
try:
|
||||||
@ -110,7 +110,7 @@ class HyREPL(code.InteractiveConsole):
|
|||||||
e.source = source
|
e.source = source
|
||||||
e.filename = filename
|
e.filename = filename
|
||||||
if SIMPLE_TRACEBACKS:
|
if SIMPLE_TRACEBACKS:
|
||||||
sys.stderr.write(str(e))
|
print(e, file=sys.stderr)
|
||||||
else:
|
else:
|
||||||
self.showtraceback()
|
self.showtraceback()
|
||||||
return False
|
return False
|
||||||
@ -184,7 +184,7 @@ def pretty_error(func, *args, **kw):
|
|||||||
return func(*args, **kw)
|
return func(*args, **kw)
|
||||||
except (HyTypeError, LexException) as e:
|
except (HyTypeError, LexException) as e:
|
||||||
if SIMPLE_TRACEBACKS:
|
if SIMPLE_TRACEBACKS:
|
||||||
sys.stderr.write(str(e))
|
print(e, file=sys.stderr)
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
raise
|
raise
|
||||||
|
|
||||||
@ -201,8 +201,8 @@ def run_module(mod_name):
|
|||||||
sys.argv = [pth] + sys.argv
|
sys.argv = [pth] + sys.argv
|
||||||
return run_file(pth)
|
return run_file(pth)
|
||||||
|
|
||||||
sys.stderr.write("{0}: module '{1}' not found.\n".format(hy.__appname__,
|
print("{0}: module '{1}' not found.\n".format(hy.__appname__, mod_name),
|
||||||
mod_name))
|
file=sys.stderr)
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
|
|
||||||
@ -328,8 +328,8 @@ def cmdline_handler(scriptname, argv):
|
|||||||
try:
|
try:
|
||||||
return run_file(options.args[0])
|
return run_file(options.args[0])
|
||||||
except HyIOError as e:
|
except HyIOError as e:
|
||||||
sys.stderr.write("hy: Can't open file '%s': [Errno %d] %s\n" %
|
print("hy: Can't open file '{0}': [Errno {1}] {2}\n".format(
|
||||||
(e.filename, e.errno, e.strerror))
|
e.filename, e.errno, e.strerror), file=sys.stderr)
|
||||||
sys.exit(e.errno)
|
sys.exit(e.errno)
|
||||||
|
|
||||||
# User did NOTHING!
|
# User did NOTHING!
|
||||||
@ -356,8 +356,8 @@ def hyc_main():
|
|||||||
print("Compiling %s" % file)
|
print("Compiling %s" % file)
|
||||||
pretty_error(write_hy_as_pyc, file)
|
pretty_error(write_hy_as_pyc, file)
|
||||||
except IOError as x:
|
except IOError as x:
|
||||||
sys.stderr.write("hyc: Can't open file '%s': [Errno %d] %s\n" %
|
print("hyc: Can't open file '{0}': [Errno {1}] {2}\n".format(
|
||||||
(x.filename, x.errno, x.strerror))
|
x.filename, x.errno, x.strerror), file=sys.stderr)
|
||||||
sys.exit(x.errno)
|
sys.exit(x.errno)
|
||||||
|
|
||||||
|
|
||||||
|
@ -25,8 +25,6 @@ import traceback
|
|||||||
|
|
||||||
from clint.textui import colored
|
from clint.textui import colored
|
||||||
|
|
||||||
from hy._compat import PY3
|
|
||||||
|
|
||||||
|
|
||||||
class HyError(Exception):
|
class HyError(Exception):
|
||||||
"""
|
"""
|
||||||
@ -101,12 +99,9 @@ class HyTypeError(TypeError):
|
|||||||
|
|
||||||
result += colored.yellow("%s: %s\n\n" %
|
result += colored.yellow("%s: %s\n\n" %
|
||||||
(self.__class__.__name__,
|
(self.__class__.__name__,
|
||||||
self.message))
|
self.message.encode('utf-8')))
|
||||||
|
|
||||||
if not PY3:
|
return result
|
||||||
return result.encode('utf-8')
|
|
||||||
else:
|
|
||||||
return result
|
|
||||||
|
|
||||||
|
|
||||||
class HyMacroExpansionError(HyTypeError):
|
class HyMacroExpansionError(HyTypeError):
|
||||||
|
Loading…
Reference in New Issue
Block a user