From d5c719f860ac5a57a113bec6d18edaa85d1a2a34 Mon Sep 17 00:00:00 2001 From: Anthony Sottile Date: Mon, 11 Jun 2018 11:32:55 -0700 Subject: [PATCH] Also catch `SyntaxError` from asyncio import Apparently, `asyncio` is installable in python 2 and an import can trigger this: ```bash pip install asyncio cached-property python -c 'import cached_property' ``` ```python $ python -c 'import cached_property' Traceback (most recent call last): File "", line 1, in File "/private/tmp/venv/lib/python2.7/site-packages/cached_property.py", line 12, in import asyncio File "/private/tmp/venv/lib/python2.7/site-packages/asyncio/__init__.py", line 9, in from . import selectors File "/private/tmp/venv/lib/python2.7/site-packages/asyncio/selectors.py", line 39 "{!r}".format(fileobj)) from None ^ SyntaxError: invalid syntax ``` Originally seen in https://github.com/pre-commit/pre-commit/issues/766 --- cached_property.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cached_property.py b/cached_property.py index eb9e90f..0410791 100644 --- a/cached_property.py +++ b/cached_property.py @@ -10,7 +10,7 @@ import threading try: import asyncio -except ImportError: +except (ImportError, SyntaxError): asyncio = None -- 2.30.2