ValueError: invalid signature: not all fields have an embedded name

Issue #144 new
Yurii Shevchuk
created an issue

I try to install PyBluez on OSX 10.11.2. I've already installed xcode 7.2.1 and pyobjc 3.1b. I've written a simple program. When I run this program I have an error.

import bluetooth

server_sock = bluetooth.BluetoothSocket(bluetooth.RFCOMM)
server_sock.bind(("", bluetooth.PORT_ANY))
server_sock.listen(1)
print("listening on port %d" % port)
Traceback (most recent call last):
  File "/Users/itdxer/.pyenv/versions/neupy/lib/python3.4/site-packages/PyBluez-0.22-py3.4.egg/lightblue/_IOBluetooth.py", line 47, in <module>
  File "/Users/itdxer/.pyenv/versions/neupy/lib/python3.4/site-packages/pyobjc_core-3.1b1-py3.4-macosx-10.10-x86_64.egg/objc/_bridgesupport.py", line 741, in initFrameworkWrapper
    _parseBridgeSupport(data, globals, frameworkName)
  File "/Users/itdxer/.pyenv/versions/neupy/lib/python3.4/site-packages/pyobjc_core-3.1b1-py3.4-macosx-10.10-x86_64.egg/objc/_bridgesupport.py", line 648, in _parseBridgeSupport
    objc.parseBridgeSupport(data, globals, frameworkName, *args, **kwds)
  File "/Users/itdxer/.pyenv/versions/neupy/lib/python3.4/site-packages/pyobjc_core-3.1b1-py3.4-macosx-10.10-x86_64.egg/objc/_bridgesupport.py", line 613, in parseBridgeSupport
    globals[name] = value = objc.createStructType(name, typestr, None)
  File "/Users/itdxer/.pyenv/versions/neupy/lib/python3.4/site-packages/pyobjc_core-3.1b1-py3.4-macosx-10.10-x86_64.egg/objc/_bridgesupport.py", line 811, in createStructType
    result = _orig_createStructType(name, typestr, fieldnames, doc, pack)
ValueError: invalid signature: not all fields have an embedded name

Traceback (most recent call last):
  File "bt.py", line 1, in <module>
    import bluetooth
  File "<frozen importlib._bootstrap>", line 2237, in _find_and_load
  File "<frozen importlib._bootstrap>", line 2226, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 1191, in _load_unlocked
  File "<frozen importlib._bootstrap>", line 1161, in _load_backward_compatible
  File "/Users/itdxer/.pyenv/versions/neupy/lib/python3.4/site-packages/PyBluez-0.22-py3.4.egg/bluetooth/__init__.py", line 47, in <module>
  File "<frozen importlib._bootstrap>", line 2237, in _find_and_load
  File "<frozen importlib._bootstrap>", line 2226, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 1191, in _load_unlocked
  File "<frozen importlib._bootstrap>", line 1161, in _load_backward_compatible
  File "/Users/itdxer/.pyenv/versions/neupy/lib/python3.4/site-packages/PyBluez-0.22-py3.4.egg/bluetooth/osx.py", line 1, in <module>
  File "<frozen importlib._bootstrap>", line 2237, in _find_and_load
  File "<frozen importlib._bootstrap>", line 2226, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 1191, in _load_unlocked
  File "<frozen importlib._bootstrap>", line 1161, in _load_backward_compatible
  File "/Users/itdxer/.pyenv/versions/neupy/lib/python3.4/site-packages/PyBluez-0.22-py3.4.egg/lightblue/__init__.py", line 160, in <module>
  File "<frozen importlib._bootstrap>", line 2237, in _find_and_load
  File "<frozen importlib._bootstrap>", line 2226, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 1191, in _load_unlocked
  File "<frozen importlib._bootstrap>", line 1161, in _load_backward_compatible
  File "/Users/itdxer/.pyenv/versions/neupy/lib/python3.4/site-packages/PyBluez-0.22-py3.4.egg/lightblue/_lightblue.py", line 28, in <module>
  File "<frozen importlib._bootstrap>", line 2237, in _find_and_load
  File "<frozen importlib._bootstrap>", line 2226, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 1191, in _load_unlocked
  File "<frozen importlib._bootstrap>", line 1161, in _load_backward_compatible
  File "/Users/itdxer/.pyenv/versions/neupy/lib/python3.4/site-packages/PyBluez-0.22-py3.4.egg/lightblue/_IOBluetooth.py", line 61, in <module>
AttributeError: 'module' object has no attribute 'setSignatureForSelector'

I use Python 3.4 and install all libraries in virtualenv environment. I investigate a bit and as I understood the issue with typestr variable.

result = _orig_createStructType(name, typestr, fieldnames, doc, pack)

Where:

name = 'IOBluetoothL2CAPChannelEvent'
typestr = 'b'{IOBluetoothL2CAPChannelEvent="eventType"i"u"(?="data"{IOBluetoothL2CAPChannelDataBlock="dataPtr"^v"dataSize"Q}"writeRefCon"^v"padding"[32C])"status"i}''
fieldnames = None
doc = None
pack = -1

I checked <struct> in the https://pythonhosted.org/pyobjc/metadata/bridgesupport.html and as I see the problem probably in (?="data"....) part, because other variables was identified without any problem and this (?="data....) part is the one obvious thing that do not exist in previous structures.

I've posted the same issue in pybluez issue tracker (https://github.com/karulis/pybluez/issues/113).

Comments (3)

  1. Ronald Oussoren repo owner

    The "(?=...)" bit describes a C union and those barely work at best, both because there is no clear consistent mapping from a union to a Python data structure and because libffi's support for unions is suboptimal.

    In the long run I'll add support for IOBluetooth and IOBluetoothUI to PyObjC itself, but I'm not sure when that will happen. The list of frameworks I need to look at is about 50 lines long at the moment.

  2. Log in to comment