crossbario / autobahn-python

WebSocket and WAMP in Python for Twisted and asyncio
https://crossbar.io/autobahn
MIT License
2.47k stars 763 forks source link

Can not import twisted.util #1559

Closed JakubHazik closed 2 years ago

JakubHazik commented 2 years ago

Can not import import autobahn.twisted.util, observed on the latest 22.4.1 version

Traceback (most recent call last):
  File "/home/jakub/PycharmProjects/pythonProject/main.py", line 2, in <module>
    import autobahn.twisted.util
  File "/home/jakub/PycharmProjects/pythonProject/.venv/lib/python3.8/site-packages/autobahn/twisted/__init__.py", line 36, in <module>
    from autobahn.twisted.util import sleep
  File "/home/jakub/PycharmProjects/pythonProject/.venv/lib/python3.8/site-packages/autobahn/twisted/util.py", line 192, in <module>
    def extract_peer_certificate(transport: TLSMemoryBIOProtocol) -> Optional[Dict[str, Any]]:
NameError: name 'TLSMemoryBIOProtocol' is not defined

The issue occurred when this import failed inside try-except scope: https://github.com/crossbario/autobahn-python/blob/308b5c74b25bb58b690182d899fc71cf86b07e46/autobahn/twisted/util.py#L120

Looks like a bad indentation for this method? https://github.com/crossbario/autobahn-python/blob/308b5c74b25bb58b690182d899fc71cf86b07e46/autobahn/twisted/util.py#L192

yan12125 commented 2 years ago

FWIW, I got the same issue and the error is gone after pip install pyopenssl

oberstet commented 2 years ago

damn, yes, that's a bug, the block should have 1 more indent, so that it resides under the import guard

oberstet commented 2 years ago

https://pypi.org/project/autobahn/22.4.2/ https://github.com/crossbario/autobahn-python/tree/v22.4.2