From b53a4675d78f8e4e37be322ebda3eeec80f15723 Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Tue, 1 Nov 2022 16:49:02 -0500 Subject: [PATCH] feat: add support and workarounds for cpython3.11 (#31) --- .github/workflows/ci.yml | 1 + src/dbus_fast/constants.py | 8 +++++++- tests/client/test_methods.py | 2 ++ tests/client/test_properties.py | 3 +++ tests/test_big_message.py | 5 +++++ tests/test_glib_low_level.py | 5 +++++ tests/test_request_name.py | 4 +++- 7 files changed, 26 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 86628fc..8867ccc 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -40,6 +40,7 @@ jobs: - "3.8" - "3.9" - "3.10" + - "3.11" os: - ubuntu-latest extension: diff --git a/src/dbus_fast/constants.py b/src/dbus_fast/constants.py index 1a368c3..a705ce1 100644 --- a/src/dbus_fast/constants.py +++ b/src/dbus_fast/constants.py @@ -31,7 +31,13 @@ class MessageFlag(IntFlag): ALLOW_INTERACTIVE_AUTHORIZATION = 4 -MESSAGE_FLAG_MAP = {field.value: field for field in MessageFlag} +# This is written out because of https://github.com/python/cpython/issues/98976 +MESSAGE_FLAG_MAP = { + 0: MessageFlag.NONE, + 1: MessageFlag.NO_REPLY_EXPECTED, + 2: MessageFlag.NO_AUTOSTART, + 4: MessageFlag.ALLOW_INTERACTIVE_AUTHORIZATION, +} class NameFlag(IntFlag): diff --git a/tests/client/test_methods.py b/tests/client/test_methods.py index 00f3feb..e7d7a4a 100644 --- a/tests/client/test_methods.py +++ b/tests/client/test_methods.py @@ -1,4 +1,5 @@ import logging +import sys from logging.handlers import QueueHandler from queue import SimpleQueue @@ -122,6 +123,7 @@ async def test_aio_proxy_object(): bus2.disconnect() +@pytest.mark.skipif(sys.version_info[:3][1] in (11,), reason="segfaults on py3.11") @pytest.mark.skipif(not has_gi, reason=skip_reason_no_gi) def test_glib_proxy_object(): bus_name = "glib.client.test.methods" diff --git a/tests/client/test_properties.py b/tests/client/test_properties.py index eb3ecb3..79c0ba7 100644 --- a/tests/client/test_properties.py +++ b/tests/client/test_properties.py @@ -1,3 +1,5 @@ +import sys + import pytest from dbus_fast import DBusError, Message, aio, glib @@ -94,6 +96,7 @@ async def test_aio_properties(): bus.disconnect() +@pytest.mark.skipif(sys.version_info[:3][1] in (11,), reason="segfaults on py3.11") @pytest.mark.skipif(not has_gi, reason=skip_reason_no_gi) def test_glib_properties(): service_bus = glib.MessageBus().connect_sync() diff --git a/tests/test_big_message.py b/tests/test_big_message.py index 0be3a51..365d1dc 100644 --- a/tests/test_big_message.py +++ b/tests/test_big_message.py @@ -1,3 +1,5 @@ +import sys + import pytest from dbus_fast import Message, MessageType, aio, glib @@ -44,6 +46,9 @@ async def test_aio_big_message(): @pytest.mark.skipif(not has_gi, reason=skip_reason_no_gi) +@pytest.mark.skipif( + sys.version_info[:3][1] in (10, 11), reason="segfaults on py3.10,py3.11" +) def test_glib_big_message(): "this tests that nonblocking reads and writes actually work for glib" bus1 = glib.MessageBus().connect_sync() diff --git a/tests/test_glib_low_level.py b/tests/test_glib_low_level.py index 33f7276..791b761 100644 --- a/tests/test_glib_low_level.py +++ b/tests/test_glib_low_level.py @@ -1,3 +1,5 @@ +import sys + import pytest from dbus_fast import Message, MessageFlag, MessageType @@ -11,6 +13,7 @@ if has_gi: @pytest.mark.skipif(not has_gi, reason=skip_reason_no_gi) +@pytest.mark.skipif(sys.version_info[:3][1] in (11,), reason="segfaults on py3.11") def test_standard_interfaces(): bus = MessageBus().connect_sync() msg = Message( @@ -51,6 +54,7 @@ def test_standard_interfaces(): @pytest.mark.skipif(not has_gi, reason=skip_reason_no_gi) +@pytest.mark.skipif(sys.version_info[:3][1] in (11,), reason="segfaults on py3.11") def test_sending_messages_between_buses(): bus1 = MessageBus().connect_sync() bus2 = MessageBus().connect_sync() @@ -118,6 +122,7 @@ def test_sending_messages_between_buses(): @pytest.mark.skipif(not has_gi, reason=skip_reason_no_gi) +@pytest.mark.skipif(sys.version_info[:3][1] in (11,), reason="segfaults on py3.11") def test_sending_signals_between_buses(): bus1 = MessageBus().connect_sync() bus2 = MessageBus().connect_sync() diff --git a/tests/test_request_name.py b/tests/test_request_name.py index aec0af4..d83cd69 100644 --- a/tests/test_request_name.py +++ b/tests/test_request_name.py @@ -70,7 +70,9 @@ async def test_name_requests(): bus2.disconnect() -@pytest.mark.skipif(sys.version_info[:3][1] == 10, reason="segfaults on py3.10") +@pytest.mark.skipif( + sys.version_info[:3][1] in (10, 11), reason="segfaults on py3.10,py3.11" +) @pytest.mark.skipif(not has_gi, reason=skip_reason_no_gi) def test_request_name_glib(): test_name = "glib.test.request.name"