All of lore.kernel.org
 help / color / mirror / Atom feed
From: Tigran Mkrtchyan <tigran.mkrtchyan@desy.de>
To: bfields@fieldses.org
Cc: linux-nfs@vger.kernel.org, Tigran Mkrtchyan <tigran.mkrtchyan@desy.de>
Subject: [PATCH] rpc: fix str to bytes conversion
Date: Wed, 18 Mar 2020 11:40:31 +0100	[thread overview]
Message-ID: <20200318104031.289921-1-tigran.mkrtchyan@desy.de> (raw)

fix back channel ping from server
---
 rpc/rpc.py | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/rpc/rpc.py b/rpc/rpc.py
index c536384..d15cf06 100644
--- a/rpc/rpc.py
+++ b/rpc/rpc.py
@@ -693,8 +693,11 @@ class ConnectionHandler(object):
                 status, result, notify = tuple
             if result is None:
                 result = b''
+            if isinstance(result, str):
+                result = bytes(result, encoding='UTF-8')
+
             if not isinstance(result, bytes):
-                raise TypeError("Expected string")
+                raise TypeError("Expected bytes, got %s" % type(result))
             # status, result = method(msg_data, call_info)
             log_t.debug("Called method, got %r, %r" % (status, result))
         except rpclib.RPCDrop:
-- 
2.25.1


             reply	other threads:[~2020-03-18 10:40 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-18 10:40 Tigran Mkrtchyan [this message]
2020-03-24 21:18 ` [PATCH] rpc: fix str to bytes conversion J. Bruce Fields

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200318104031.289921-1-tigran.mkrtchyan@desy.de \
    --to=tigran.mkrtchyan@desy.de \
    --cc=bfields@fieldses.org \
    --cc=linux-nfs@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.