Merge pull request #1 from gou4shi1/master

sockets in Python 2 don't support "with". use contextlib.closing instead.
This commit is contained in:
依云 2017-05-29 18:19:21 +08:00 committed by GitHub
commit 83519f4ed3

View file

@ -4,6 +4,7 @@ import os
import vim
import socket
import struct
import contextlib
fcitxsocketfile = vim.eval('s:fcitxsocketfile')
@ -48,7 +49,7 @@ class FcitxComm(object):
if not self._connect():
return
with self.sock:
with contextlib.closing(self.sock):
try:
return func(*args, **kwargs)
except (socket.error, socket.timeout, struct.error) as e: