From 0d9574d9fc274303b814db22dcad793ec95e6b5e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Marczykowski-G=C3=B3recki?= Date: Thu, 27 Jul 2017 22:15:02 +0200 Subject: [PATCH] api: use str(subject) instead of explicit subject.name This allows better flexibility, when subject is not necessary a VM object. --- qubes/api/__init__.py | 2 +- qubes/tests/api.py | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/qubes/api/__init__.py b/qubes/api/__init__.py index 38532913..f35974ec 100644 --- a/qubes/api/__init__.py +++ b/qubes/api/__init__.py @@ -323,7 +323,7 @@ class QubesDaemonProtocol(asyncio.Protocol): self.send_header(0x31) if subject is not self.app: - self.transport.write(subject.name.encode('ascii')) + self.transport.write(str(subject).encode('ascii')) self.transport.write(b'\0') self.transport.write(event.encode('ascii') + b'\0') diff --git a/qubes/tests/api.py b/qubes/tests/api.py index b24ab80e..ba74a208 100644 --- a/qubes/tests/api.py +++ b/qubes/tests/api.py @@ -77,7 +77,11 @@ class TestMgmt(object): class Subject: name = 'subject' - self.send_event(Subject, 'event', payload=untrusted_payload.decode()) + + def __str__(self): + return 'subject' + + self.send_event(Subject(), 'event', payload=untrusted_payload.decode()) try: # give some time to close the other end yield from asyncio.sleep(0.1)