diff --git a/src/dbus_fast/_private/unmarshaller.pxd b/src/dbus_fast/_private/unmarshaller.pxd index 7539015b..0a2942de 100644 --- a/src/dbus_fast/_private/unmarshaller.pxd +++ b/src/dbus_fast/_private/unmarshaller.pxd @@ -11,6 +11,7 @@ cdef object ARRAY cdef object UNIX_FDS_CMSG_LENGTH cdef object SOL_SOCKET cdef object SCM_RIGHTS +cdef object MESSAGE_FLAG_INTENUM cdef unsigned int UINT32_SIZE cdef unsigned int INT16_SIZE @@ -112,8 +113,8 @@ cdef class Unmarshaller: cdef unsigned int _body_len cdef unsigned int _serial cdef unsigned int _header_len - cdef unsigned int _message_type - cdef unsigned int _flag + cdef object _message_type + cdef object _flag cdef unsigned int _msg_len cdef unsigned int _is_native cdef object _uint32_unpack diff --git a/src/dbus_fast/_private/unmarshaller.py b/src/dbus_fast/_private/unmarshaller.py index a3626c7b..2c12e97b 100644 --- a/src/dbus_fast/_private/unmarshaller.py +++ b/src/dbus_fast/_private/unmarshaller.py @@ -6,12 +6,14 @@ from struct import Struct from typing import Any, Callable, Dict, Iterable, List, Optional, Tuple, Union -from ..constants import MESSAGE_FLAG_MAP, MESSAGE_TYPE_MAP +from ..constants import MESSAGE_FLAG_MAP, MESSAGE_TYPE_MAP, MessageFlag from ..errors import InvalidMessageError from ..message import Message from ..signature import SignatureType, Variant, get_signature_tree from .constants import BIG_ENDIAN, LITTLE_ENDIAN, PROTOCOL_VERSION +MESSAGE_FLAG_INTENUM = MessageFlag + MAX_UNIX_FDS = 16 MAX_UNIX_FDS_SIZE = array.array("i").itemsize UNIX_FDS_CMSG_LENGTH = socket.CMSG_LEN(MAX_UNIX_FDS_SIZE) @@ -702,9 +704,12 @@ def _read_body(self) -> None: tree = get_signature_tree(signature) body = [self._readers[t.token](self, t) for t in tree.types] + flags = MESSAGE_FLAG_MAP.get(self._flag) + if flags is None: + flags = MESSAGE_FLAG_INTENUM(self._flag) self._message = Message( message_type=MESSAGE_TYPE_MAP[self._message_type], - flags=MESSAGE_FLAG_MAP[self._flag], + flags=flags, unix_fds=self._unix_fds, signature=tree, body=body, diff --git a/tests/test_aio_multi_flags.py b/tests/test_aio_multi_flags.py index ddc3f2fd..c332a9af 100644 --- a/tests/test_aio_multi_flags.py +++ b/tests/test_aio_multi_flags.py @@ -1,13 +1,9 @@ -import asyncio - import pytest -from dbus_fast import Message, MessageFlag, MessageType from dbus_fast.aio import MessageBus from dbus_fast.service import ServiceInterface, method -@pytest.mark.xfail @pytest.mark.asyncio async def test_multiple_flags_in_message(): class ExampleInterface(ServiceInterface): @@ -22,4 +18,5 @@ def Echo(self, what: "s") -> "s": # noqa: F821 interface = ExampleInterface("test.interface") bus.export("/test/path", interface) await bus.request_name("test.name") + bus.disconnect() await bus.wait_for_disconnect()