Merge pull request #1691 from jwilk-forks/isidentifier

Catch IndentationError in isidentifier()
This commit is contained in:
Kodi Arfer 2018-11-27 17:23:57 -05:00 committed by GitHub
commit 3e0112f362
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 6 additions and 1 deletions

View File

@ -30,6 +30,7 @@ Bug Fixes
objects.
* Fixed errors from `from __future__ import ...` statements and missing Hy
module docstrings caused by automatic importing of Hy builtins.
* Fixed crash in `mangle` for some pathological inputs
0.15.0
==============================

View File

@ -45,7 +45,7 @@ def isidentifier(x):
from io import StringIO
try:
tokens = list(T.generate_tokens(StringIO(x).readline))
except T.TokenError:
except (T.TokenError, IndentationError):
return False
return len(tokens) == 2 and tokens[0][0] == T.NAME

View File

@ -157,3 +157,7 @@
["⚘-⚘" "hyx_XflowerX_XflowerX"]]]
(assert (= (mangle a) b))
(assert (= (unmangle b) a))))
(defn test-mangle-bad-indent []
; Shouldn't crash with IndentationError
(mangle " 0\n 0"))