asyncio/websocket.py not compatible with Python 3.7 syntax changes
See original GitHub issueThis change in Python 3.7:
Backwards incompatible syntax changes:
async and await are now reserved keywords.
Broke this code block in asyncio/websocket.py:
if hasattr(asyncio, 'ensure_future'):
ensure_future = asyncio.ensure_future
else: # Deprecated since Python 3.4.4
ensure_future = asyncio.async
Example failure log:
Traceback (most recent call last):
File REDACTED, line 18, in <module>
from autobahn.asyncio.websocket import WebSocketServerFactory, WebSocketServerProtocol
File “/usr/local/lib/python3.7/site-packages/autobahn/asyncio/__init__.py”, line 36, in <module>
from autobahn.asyncio.websocket import \
File “/usr/local/lib/python3.7/site-packages/autobahn/asyncio/websocket.py”, line 52
ensure_future = asyncio.async
^
SyntaxError: invalid syntax
I fixed the issue locally by just deleting the old import, but I don’t know what preferred fix in autobahn official library is. It would probably work to use getattr(asyncio, “async”) to preserve backwards compatibility while still respecting the new Python 3.7 syntax rules.
Issue Analytics
- State:
- Created 5 years ago
- Reactions:2
- Comments:6 (5 by maintainers)
Top Results From Across the Web
What's New In Python 3.7 — Python 3.11.1 documentation
This article explains the new features in Python 3.7, compared to 3.6. Python 3.7 was released on June 27, 2018. ... Backwards incompatible...
Read more >What's New In Python 3.8 — Python 3.11.1 documentation
This article explains the new features in Python 3.8, compared to 3.7. ... are handled by the script); this change is backward incompatible...
Read more >What's New In Python 3.9 — Python 3.11.1 documentation
These paths now remain valid after the current directory is changed by ... asyncio now raises TyperError when calling incompatible methods with an...
Read more >What's New In Python 3.10 — Python 3.11.1 documentation
This article explains the new features in Python 3.10, compared to 3.9. Python 3.10 was released on October 4, 2021. For full details,...
Read more >PEP 606 – Python Compatibility Version
Any incompatible change can break an unknown number of Python projects. ... In Python 3.7, a __getattr__() has been added to the collections ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
The fix proposed by @Ardonius should do exactly that:
Even if I use the latest version, the test suite still fails because it tries to import a nonexistent module (
asyncio.test_utils
).