Author: Tim Felgentreff <timfelgentr...@gmail.com> Branch: Changeset: r45:b1d5a1b8744f Date: 2013-11-10 19:15 +0100 http://bitbucket.org/pypy/lang-scheme/changeset/b1d5a1b8744f/
Log: fix compile on windows, add nicer error when file not found diff --git a/scheme/execution.py b/scheme/execution.py --- a/scheme/execution.py +++ b/scheme/execution.py @@ -137,4 +137,3 @@ return loc return None - diff --git a/scheme/targetscheme.py b/scheme/targetscheme.py --- a/scheme/targetscheme.py +++ b/scheme/targetscheme.py @@ -2,6 +2,7 @@ A simple standalone target for the scheme interpreter. """ +import os import sys from rpython.rlib.streamio import open_file_as_stream from rpython.rlib.parsing.makepackrat import BacktrackException @@ -14,13 +15,23 @@ def entry_point(argv): if len(argv) == 2: - code = open_file_as_stream(argv[1]).readall() + path = argv[1] + try: + f = open_file_as_stream(path, buffering=0) + except OSError as e: + os.write(2, "%s -- %s (LoadError)\n" % (os.strerror(e.errno), path)) + return 1 + try: + code = f.readall() + finally: + f.close() + try: t = parse(code) except BacktrackException, e: (line, col) = e.error.get_line_column(code) #expected = " ".join(e.error.expected) - print "parse error in line %d, column %d" % (line, col) + os.write(2, "parse error in line %d, column %d" % (line, col)) return 1 #this should not be necessary here @@ -51,4 +62,3 @@ if __name__ == '__main__': entry_point(sys.argv) - _______________________________________________ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit