mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-28 12:32:05 -06:00
python/qemu: fix socket.makefile() typing
Note: A bug in typeshed (https://github.com/python/typeshed/issues/3977) misinterprets the type of makefile(). Work around this by explicitly stating that we are opening a text-mode file. Signed-off-by: John Snow <jsnow@redhat.com> Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> Message-Id: <20200514055403.18902-13-jsnow@redhat.com> Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
This commit is contained in:
parent
3797dbcbb7
commit
0add048fbd
2 changed files with 15 additions and 7 deletions
|
@ -11,6 +11,10 @@ import json
|
|||
import errno
|
||||
import socket
|
||||
import logging
|
||||
from typing import (
|
||||
Optional,
|
||||
TextIO,
|
||||
)
|
||||
|
||||
|
||||
class QMPError(Exception):
|
||||
|
@ -61,7 +65,7 @@ class QEMUMonitorProtocol:
|
|||
self.__events = []
|
||||
self.__address = address
|
||||
self.__sock = self.__get_sock()
|
||||
self.__sockfile = None
|
||||
self.__sockfile: Optional[TextIO] = None
|
||||
self._nickname = nickname
|
||||
if self._nickname:
|
||||
self.logger = logging.getLogger('QMP').getChild(self._nickname)
|
||||
|
@ -157,7 +161,7 @@ class QEMUMonitorProtocol:
|
|||
@raise QMPCapabilitiesError if fails to negotiate capabilities
|
||||
"""
|
||||
self.__sock.connect(self.__address)
|
||||
self.__sockfile = self.__sock.makefile()
|
||||
self.__sockfile = self.__sock.makefile(mode='r')
|
||||
if negotiate:
|
||||
return self.__negotiate_capabilities()
|
||||
return None
|
||||
|
@ -180,7 +184,7 @@ class QEMUMonitorProtocol:
|
|||
"""
|
||||
self.__sock.settimeout(timeout)
|
||||
self.__sock, _ = self.__sock.accept()
|
||||
self.__sockfile = self.__sock.makefile()
|
||||
self.__sockfile = self.__sock.makefile(mode='r')
|
||||
return self.__negotiate_capabilities()
|
||||
|
||||
def cmd_obj(self, qmp_cmd):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue