From: Calum Mackay <calum.mackay@oracle.com>
To: Chen Hanxiao <chenhx.fnst@fujitsu.com>
Cc: Calum Mackay <calum.mackay@oracle.com>, linux-nfs@vger.kernel.org
Subject: Re: [PATCH] pynfs: rpc.py: use OSError.errno to fix a not subscriptable exception
Date: Fri, 13 Dec 2024 21:49:41 +0000 [thread overview]
Message-ID: <3da64b87-1a22-468d-aa6c-ab28b0ea5e10@oracle.com> (raw)
In-Reply-To: <20241128123642.1636-1-chenhx.fnst@fujitsu.com>
On 28/11/2024 12:36 pm, Chen Hanxiao wrote:
> In python3, socket.error is a deprecated alias of OSError
> https://docs.python.org/3/library/socket.html#socket.error
>
> Also, use socket.error[0] will raise:
> TypeError: 'OSError' object is not subscriptable
>
> Signed-off-by: Chen Hanxiao <chenhx.fnst@fujitsu.com>
Applied.
Thank you very much.
best wishes,
calum.
> ---
> nfs4.0/lib/rpc/rpc.py | 4 ++--
> rpc/rpc.py | 4 ++--
> 2 files changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/nfs4.0/lib/rpc/rpc.py b/nfs4.0/lib/rpc/rpc.py
> index 24a7fc7..243ef9e 100644
> --- a/nfs4.0/lib/rpc/rpc.py
> +++ b/nfs4.0/lib/rpc/rpc.py
> @@ -226,8 +226,8 @@ class RPCClient(object):
> try:
> sock.bind(('', port))
> return
> - except socket.error as why:
> - if why[0] == errno.EADDRINUSE:
> + except OSError as why:
> + if why.errno == errno.EADDRINUSE:
> port += 1
> else:
> print("Could not use low port")
> diff --git a/rpc/rpc.py b/rpc/rpc.py
> index 1fe285a..124e97a 100644
> --- a/rpc/rpc.py
> +++ b/rpc/rpc.py
> @@ -845,8 +845,8 @@ class ConnectionHandler(object):
> try:
> s.bind(('', using))
> return
> - except socket.error as why:
> - if why[0] == errno.EADDRINUSE:
> + except OSError as why:
> + if why.errno == errno.EADDRINUSE:
> using += 1
> if port < 1024 <= using:
> # If we ask for a secure port, make sure we don't
prev parent reply other threads:[~2024-12-13 21:49 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-11-28 12:36 [PATCH] pynfs: rpc.py: use OSError.errno to fix a not subscriptable exception Chen Hanxiao
2024-12-13 21:49 ` Calum Mackay [this message]
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=3da64b87-1a22-468d-aa6c-ab28b0ea5e10@oracle.com \
--to=calum.mackay@oracle.com \
--cc=chenhx.fnst@fujitsu.com \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox