From c414026b298a9b7a07bf8a7b63f889dc17f05ee0 Mon Sep 17 00:00:00 2001 From: Sebastien Bourdeauducq Date: Fri, 2 Sep 2016 11:01:28 +0800 Subject: [PATCH] import_cache: make sure last line ends with \n as linecache does. Closes #547 --- artiq/compiler/import_cache.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/artiq/compiler/import_cache.py b/artiq/compiler/import_cache.py index 6a092e447..9300f5c39 100644 --- a/artiq/compiler/import_cache.py +++ b/artiq/compiler/import_cache.py @@ -29,7 +29,10 @@ def hook_exec_module(self, module): fn = module.__file__ try: with tokenize.open(fn) as fp: - cache[fn] = fp.readlines() + lines = fp.readlines() + if lines and not lines[-1].endswith("\n"): + lines[-1] += "\n" + cache[fn] = lines except: logger.warning("failed to add '%s' to cache", fn, exc_info=True) else: