PyGObject,dbus python和元类

时间:2019-01-28 16:46:10

标签: python dbus pygobject dbus-python

我想子类化两个python类:一个来自PyGObject,一个来自python3-dbus:

import gi
from gi.repository import GObject
import dbus.service

class Test(GObject.Object, dbus.service.Object):
    pass

但是我收到以下错误:

$ python3 test.py
Traceback (most recent call last):
    File ".../test.py", line 5, in <module>
       class Test(GObject.Object, dbus.service.Object):
TypeError: metaclass conflict: the metaclass of a derived class must be a (non-strict) subclass of the metaclasses of all its bases

我已经发现这是因为GObject.Objectdbus.service.Object具有不同的元类,我也需要对它们进行子类化:

class M_Test(gi.types.GObjectMeta, dbus.service.InterfaceType):
    pass

class Test(GObject.Object, dbus.service.Object):
    __metaclass__=M_Test
    pass

但是它没有帮助,我继续收到相同的错误。对于gi.types.GObjectMetadbus.service.InterfaceType,也许GObject.Objectdbus.service.Object不是正确的元类。有人知道如何合并GObject.Objectdbus.service.Object的元类吗?

1 个答案:

答案 0 :(得分:1)

Python3更改了指定元类的语法。 PEP-3115

现在是<?php if(isset($_GET["token"]) && isset($_GET["r"])) { $token = $_GET["token"]; $r = $_GET["r"]; $kript = 'r='. $r .';token=' . $token; } ?>