[libvirt] [PATCH python 02/14] examples: Ensure we write bytes to the self-pipe

Daniel P. Berrange berrange at redhat.com
Mon Dec 9 15:15:37 UTC 2013


From: "Daniel P. Berrange" <berrange at redhat.com>

Strings in python3 default to unicode, so when writing to
the self-pipe we must be sure to use bytes by calling the
encode() method.

Signed-off-by: Daniel P. Berrange <berrange at redhat.com>
---
 examples/event-test.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/examples/event-test.py b/examples/event-test.py
index cf1a8b8..1402c04 100644
--- a/examples/event-test.py
+++ b/examples/event-test.py
@@ -236,7 +236,7 @@ class virEventLoopPure:
     def interrupt(self):
         if self.runningPoll and not self.pendingWakeup:
             self.pendingWakeup = True
-            os.write(self.pipetrick[1], 'c')
+            os.write(self.pipetrick[1], 'c'.encode("UTF-8"))
 
 
     # Registers a new file handle 'fd', monitoring  for 'events' (libvirt
-- 
1.8.3.1




More information about the libvir-list mailing list