diff --git a/modules/modpython/znc.py b/modules/modpython/znc.py index ad77db6b..45430cbe 100644 --- a/modules/modpython/znc.py +++ b/modules/modpython/znc.py @@ -676,8 +676,9 @@ def make_inherit(cl, parent, attr): for x in parent.__dict__: if not x.startswith('_') and x not in cl.__dict__: setattr(cl, x, make_caller(parent, x, attr)) - if '_s' in parent.__dict__: - parent = parent._s + if parent.__bases__: + # Multiple inheritance is not supported (yet?) + parent = parent.__bases__[0] else: break diff --git a/test/integration/tests/scripting.cpp b/test/integration/tests/scripting.cpp index 2d9836bd..ebb4dba2 100644 --- a/test/integration/tests/scripting.cpp +++ b/test/integration/tests/scripting.cpp @@ -57,5 +57,47 @@ TEST_F(ZNCTest, Modpython) { client.ReadUntil("Hi\xEF\xBF\xBD, github issue"); } +TEST_F(ZNCTest, ModpythonSocket) { + if (QProcessEnvironment::systemEnvironment().value( + "DISABLED_ZNC_PERL_PYTHON_TEST") == "1") { + return; + } + auto znc = Run(); + znc->CanLeak(); + + InstallModule("socktest.py", R"( + import znc + + class acc(znc.Socket): + def OnReadData(self, data): + self.GetModule().PutModule('received {} bytes'.format(len(data))) + self.Close() + + class lis(znc.Socket): + def OnAccepted(self, host, port): + sock = self.GetModule().CreateSocket(acc) + sock.DisableReadLine() + return sock + + class socktest(znc.Module): + def OnLoad(self, args, ret): + listen = self.CreateSocket(lis) + self.port = listen.Listen() + return True + + def OnModCommand(self, cmd): + sock = self.CreateSocket() + sock.Connect('127.0.0.1', self.port) + sock.WriteBytes(b'blah') + )"); + + auto ircd = ConnectIRCd(); + auto client = LoginClient(); + client.Write("znc loadmod modpython"); + client.Write("znc loadmod socktest"); + client.Write("PRIVMSG *socktest :foo"); + client.ReadUntil("received 4 bytes"); +} + } // namespace } // namespace znc_inttest