From: Anthony Sottile Date: Mon, 11 Jun 2018 18:32:55 +0000 (-0700) Subject: Also catch `SyntaxError` from asyncio import X-Git-Tag: 1.4.3~2^2 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=d5c719f860ac5a57a113bec6d18edaa85d1a2a34;p=cached-property.git 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 --- 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