Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Broken on Python 3.11 #37

Open
lucaspcamargo opened this issue Nov 10, 2023 · 2 comments
Open

Broken on Python 3.11 #37

lucaspcamargo opened this issue Nov 10, 2023 · 2 comments

Comments

@lucaspcamargo
Copy link

Does not work with python 3.11. Fails with traceback:

Traceback (most recent call last):
  File "/home/camargo/venv-pystun/bin/pystun", line 8, in <module>
    sys.exit(main())
             ^^^^^^
  File "/home/camargo/venv-pystun/lib/python3.11/site-packages/stun/cli.py", line 51, in main
    nat_type, external_ip, external_port = stun.get_ip_info(
                                           ^^^^^^^^^^^^^^^^^
  File "/home/camargo/venv-pystun/lib/python3.11/site-packages/stun/__init__.py", line 252, in get_ip_info
    nat_type, nat = get_nat_type(s, source_ip, source_port,
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/camargo/venv-pystun/lib/python3.11/site-packages/stun/__init__.py", line 186, in get_nat_type
    _initialize()
  File "/home/camargo/venv-pystun/lib/python3.11/site-packages/stun/__init__.py", line 93, in _initialize
    dictValToAttr.update({items[i][1]: items[i][0]})
                          ~~~~~^^^
TypeError: 'dict_items' object is not subscriptable
@misan
Copy link

misan commented Nov 20, 2023

Indeed!

>>> import stun
>>> stun.get_ip_info(stun_host='stun.ekiga.net')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/misan/.local/lib/python3.10/site-packages/stun/__init__.py", line 252, in get_ip_info
    nat_type, nat = get_nat_type(s, source_ip, source_port,
  File "/home/misan/.local/lib/python3.10/site-packages/stun/__init__.py", line 186, in get_nat_type
    _initialize()
  File "/home/misan/.local/lib/python3.10/site-packages/stun/__init__.py", line 93, in _initialize
    dictValToAttr.update({items[i][1]: items[i][0]})
TypeError: 'dict_items' object is not subscriptable

@MorningLightMountain713
Copy link

MorningLightMountain713 commented Nov 28, 2023

This code doesn't look to be maintained; as the fixes are simple, I forked it and fixed the code for 3.11.

Its available on pypi as yapystun (Yet Another PyStun)

> pip install yapystun
Collecting yapystun
  Using cached yapystun-0.2.2-py3-none-any.whl (6.5 kB)
Installing collected packages: yapystun
Successfully installed yapystun-0.2.2

> pystun -H stun.l.google.com -P 19302
NAT Type: Full Cone
External IP: x.x.x.x
External Port: 54320

> python --version
Python 3.11.2

I haven't tested anything else. If it's broken, raise an issue and I'll fix it ASAP.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants