From: Richard Si <63936253+ichard26@users.noreply.github.com>
Date: Sun, 5 Dec 2021 16:53:58 +0000 (-0500)
Subject: blib2to3 can raise TokenError and IndentationError too (#2671)
X-Git-Url: https://git.madduck.net/etc/vim.git/commitdiff_plain/d9eee31ec81c42d9953aee0d7f0adaf211519a10?ds=sidebyside

blib2to3 can raise TokenError and IndentationError too (#2671)
---

diff --git a/src/black/parsing.py b/src/black/parsing.py
index 2fd41f0..c101643 100644
--- a/src/black/parsing.py
+++ b/src/black/parsing.py
@@ -140,7 +140,7 @@ def matches_grammar(src_txt: str, grammar: Grammar) -> bool:
     drv = driver.Driver(grammar)
     try:
         drv.parse_string(src_txt, True)
-    except ParseError:
+    except (ParseError, TokenError, IndentationError):
         return False
     else:
         return True