Skip to content

Dataclass serializer generation fails in 3.14 #1880

@HC4L

Description

@HC4L

Describe the bug

Using uadiscover or any other method to open a connection to a server.
When creating the serializer for the class asyncua.ua.uaprotocol_hand.Hello a "property" field is included in the fields to create serializers for.
I think there is a change in 3.14 for the internal representation of dataclasses.
Works in 3.13.

Stacktrace:

Traceback (most recent call last):
  File "/xxx/.venv/bin/uadiscover", line 7, in <module>
    sys.exit(uadiscover())
             ~~~~~~~~~~^^
  File "/xxx/.venv/lib/python3.14/site-packages/asyncua/tools.py", line 684, in uadiscover
    asyncio.run(_uadiscover())
    ~~~~~~~~~~~^^^^^^^^^^^^^^^
  File "/usr/lib/python3.14/asyncio/runners.py", line 204, in run
    return runner.run(main)
           ~~~~~~~~~~^^^^^^
  File "/usr/lib/python3.14/asyncio/runners.py", line 127, in run
    return self._loop.run_until_complete(task)
           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^
  File "/usr/lib/python3.14/asyncio/base_events.py", line 719, in run_until_complete
    return future.result()
           ~~~~~~~~~~~~~^^
  File "/xxx/.venv/lib/python3.14/site-packages/asyncua/tools.py", line 720, in _uadiscover
    for i, server in enumerate(await client.connect_and_find_servers(), start=1):
                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/xxx/.venv/lib/python3.14/site-packages/asyncua/client/client.py", line 286, in connect_and_find_servers
    await self.open_secure_channel()  # spec says it should not be necessary to open channel
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/xxx/.venv/lib/python3.14/site-packages/asyncua/client/client.py", line 410, in open_secure_channel
    result = await self.uaclient.open_secure_channel(params)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/xxx/.venv/lib/python3.14/site-packages/asyncua/client/ua_client.py", line 344, in open_secure_channel
    return await self.protocol.open_secure_channel(params)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/xxx/.venv/lib/python3.14/site-packages/asyncua/client/ua_client.py", line 259, in open_secure_channel
    await wait_for(self._send_request(request, message_type=ua.MessageType.SecureOpen), self.timeout)
                   ~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/xxx/.venv/lib/python3.14/site-packages/asyncua/client/ua_client.py", line 153, in _send_request
    binreq = struct_to_binary(request)
  File "/xxx/.venv/lib/python3.14/site-packages/asyncua/ua/ua_binary.py", line 344, in struct_to_binary
    serializer = create_dataclass_serializer(obj.__class__)
  File "/xxx/.venv/lib/python3.14/site-packages/asyncua/ua/ua_binary.py", line 332, in create_dataclass_serializer
    encoding_functions = [(f.name, field_serializer(f.type, dataclazz)) for f in data_fields]
                                   ~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^
  File "/xxx/.venv/lib/python3.14/site-packages/asyncua/ua/ua_binary.py", line 284, in field_serializer
    serializer = create_type_serializer(uatype)
  File "/xxx/.venv/lib/python3.14/site-packages/asyncua/ua/ua_binary.py", line 369, in create_type_serializer
    if issubclass(uatype, Enum):
       ~~~~~~~~~~^^^^^^^^^^^^^^
TypeError: issubclass() arg 1 must be a class

To Reproduce

Use uadiscover or the default example to connect to a server.

Version

Python-Version: 3.14.0

opcua-asyncio Version (e.g. master branch, 0.9): 1.1.8

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions