Skip to content

Commit

Permalink
Merge branch 'notify_callback_empty_message' of https://github.com/Mo…
Browse files Browse the repository at this point in the history
…cramis/dbus-fast into notify_callback_empty_message
  • Loading branch information
bdraco committed Sep 7, 2023
2 parents 1e44979 + 7b4e674 commit 52c6abf
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 8 deletions.
5 changes: 3 additions & 2 deletions src/dbus_fast/_private/unmarshaller.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
9 changes: 7 additions & 2 deletions src/dbus_fast/_private/unmarshaller.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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,
Expand Down
5 changes: 1 addition & 4 deletions tests/test_aio_multi_flags.py
Original file line number Diff line number Diff line change
@@ -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):
Expand All @@ -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()

0 comments on commit 52c6abf

Please sign in to comment.