From 0ba620fc7310021ef205c278ae207214b0fcf9bc Mon Sep 17 00:00:00 2001 From: Gregor Best Date: Tue, 28 Jul 2015 16:46:26 +0200 Subject: [PATCH] Explicitly set missing source on LexExceptions This fixes the following code: (import [hy.lex [tokenize]]) (tokenize "(foo))") --- hy/lex/__init__.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/hy/lex/__init__.py b/hy/lex/__init__.py index 8153aa8..f1a74aa 100644 --- a/hy/lex/__init__.py +++ b/hy/lex/__init__.py @@ -35,3 +35,7 @@ def tokenize(buf): pos = e.getsourcepos() raise LexException("Could not identify the next token.", pos.lineno, pos.colno) + except LexException as e: + if e.source is None: + e.source = buf + raise