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

NameError: name '_cast_uint32_native' is not defined #129

Closed
konyshev-dmitry opened this issue Oct 31, 2022 · 7 comments · Fixed by #130
Closed

NameError: name '_cast_uint32_native' is not defined #129

konyshev-dmitry opened this issue Oct 31, 2022 · 7 comments · Fixed by #130
Labels
bug Something isn't working

Comments

@konyshev-dmitry
Copy link

Using Bleak to fetch Bluetooth Low Energy (BLE) devices.

Versions of dbus-fast <=1.50.0 are working fine.
Versions of dbus-fast >=1.51.0 give:
File "/home/d/.local/lib/python3.11/site-packages/dbus_fast/_private/unmarshaller.py", line 434, in _read_header self._body_len = _cast_uint32_native(self._buf, 4) # pragma: no cover ^^^^^^^^^^^^^^^^^^^ NameError: name '_cast_uint32_native' is not defined

Ubuntu 20.04.5 (amd64 and aarch64), Python 3.8-3.11

@konyshev-dmitry konyshev-dmitry added the bug Something isn't working label Oct 31, 2022
@bdraco
Copy link
Member

bdraco commented Oct 31, 2022

We don’t have python 3.11 support yet, but your post implies you have the issue on other versions as well.

Can you post the trace from 3.10/3.9/3.8?

@konyshev-dmitry
Copy link
Author

konyshev-dmitry commented Oct 31, 2022

$ python3.8 --version
Python 3.8.10
$ python3.8 blu.py
Traceback (most recent call last):
  File "blu.py", line 9, in <module>
    asyncio.run(main())
  File "/usr/lib/python3.8/asyncio/runners.py", line 44, in run
    return loop.run_until_complete(main)
  File "/usr/lib/python3.8/asyncio/base_events.py", line 616, in run_until_complete
    return future.result()
  File "blek.py", line 5, in main
    devices = await BleakScanner.discover()
  File "/home/d/.local/lib/python3.8/site-packages/bleak/__init__.py", line 216, in discover
    async with cls(**kwargs) as scanner:
  File "/home/d/.local/lib/python3.8/site-packages/bleak/__init__.py", line 126, in __aenter__
    await self._backend.start()
  File "/home/d/.local/lib/python3.8/site-packages/bleak/backends/bluezdbus/scanner.py", line 174, in start
    manager = await get_global_bluez_manager()
  File "/home/d/.local/lib/python3.8/site-packages/bleak/backends/bluezdbus/manager.py", line 891, in get_global_bluez_manager
    await instance.async_init()
  File "/home/d/.local/lib/python3.8/site-packages/bleak/backends/bluezdbus/manager.py", line 191, in async_init
    await bus.connect()
  File "/home/d/.local/lib/python3.8/site-packages/dbus_fast/aio/message_bus.py", line 230, in connect
    return await future
  File "/home/d/.local/lib/python3.8/site-packages/dbus_fast/aio/message_bus.py", line 209, in on_hello
    raise err
  File "/home/d/.local/lib/python3.8/site-packages/dbus_fast/aio/message_reader.py", line 22, in _message_reader
    message = unmarshall()
  File "/home/d/.local/lib/python3.8/site-packages/dbus_fast/_private/unmarshaller.py", line 615, in unmarshall
    self._read_header()
  File "/home/d/.local/lib/python3.8/site-packages/dbus_fast/_private/unmarshaller.py", line 527, in _read_header
    self._body_len = _cast_uint32_native(self._buf, 4)  # pragma: no cover
NameError: name '_cast_uint32_native' is not defined
$ pip list
Package             Version
------------------- --------------------
async-timeout       4.0.2
bcrypt              3.1.7
bleak               0.19.1
blinker             1.4
Brlapi              0.7.0
certifi             2019.11.28
chardet             3.0.4
Click               7.0
colorama            0.4.3
cryptography        2.8
cupshelpers         1.0
dbus-fast           1.59.1
dbus-next           0.2.3
dbus-python         1.2.16
defer               1.0.6
distro              1.4.0
distro-info         0.23ubuntu1
duplicity           0.8.12.0
entrypoints         0.3
fasteners           0.14.1
future              0.18.2
gpg                 1.13.1-unknown
httplib2            0.14.0
idna                2.8
keyring             18.0.1
launchpadlib        1.10.13
lazr.restfulclient  0.14.2
lazr.uri            1.0.3
lockfile            0.12.2
louis               3.12.0
macaroonbakery      1.3.1
Mako                1.1.0
MarkupSafe          1.1.0
monotonic           1.5
netifaces           0.10.4
oauthlib            3.1.0
olefile             0.46
paramiko            2.6.0
pexpect             4.6.0
Pillow              7.0.0
pip                 22.3
protobuf            3.6.1
pycairo             1.16.2
pycrypto            2.6.1
pycups              1.9.73
PyGObject           3.36.0
PyJWT               1.7.1
pymacaroons         0.13.0
PyNaCl              1.3.0
pyRFC3339           1.1
python-apt          2.0.0+ubuntu0.20.4.8
python-dateutil     2.7.3
python-debian       0.1.36ubuntu1
pytz                2019.3
pyxdg               0.26
PyYAML              5.3.1
reportlab           3.5.34
requests            2.22.0
requests-unixsocket 0.2.0
SecretStorage       2.3.1
setuptools          45.2.0
simplejson          3.16.0
six                 1.14.0
ssh-import-id       5.10
systemd-python      234
typing_extensions   4.4.0
ufw                 0.36
urllib3             1.25.8
usb-creator         0.3.7
wadllib             1.3.3
wheel               0.34.2
xkit                0.0.0
$ dpkg --status bluez | grep '^Version:'
Version: 5.53-0ubuntu3.6

Using standard Bleak example code:

import asyncio
from bleak import BleakScanner

async def main():
    devices = await BleakScanner.discover()
    for d in devices:
        print(d)

asyncio.run(main())

@bdraco
Copy link
Member

bdraco commented Oct 31, 2022

Are you using the wheels from PyPI or building for source?

Is the cython extension being compiled or are you running pure python only?

@bdraco
Copy link
Member

bdraco commented Oct 31, 2022

Pushed 1.59.2

Please let me know if that resolves it for you

@bdraco
Copy link
Member

bdraco commented Oct 31, 2022

It will take 10-15 minutes before wheels are uploaded
https://github.com/Bluetooth-Devices/dbus-fast/actions/runs/3360664409

@konyshev-dmitry
Copy link
Author

Thanks, the issue is resolved.

And thanks again, it was really [dbus-]fast!

@bdraco
Copy link
Member

bdraco commented Nov 1, 2022

1.61.0 has python 3.11 support

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants