linux-nfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH pynfs] rpc.py: Don't try to subscript an exception.
@ 2023-03-28  0:48 NeilBrown
  2023-03-28 15:25 ` Frank Filz
  2023-03-30 15:33 ` Calum Mackay
  0 siblings, 2 replies; 3+ messages in thread
From: NeilBrown @ 2023-03-28  0:48 UTC (permalink / raw)
  To: Bruce Fields, Jeff Layton; +Cc: Linux NFS Mailing List


As far as I can tell python3 has never supported subscripting of
exceptions.
So don't try to...

Signed-off-by: NeilBrown <neilb@suse.de>
---
 nfs4.0/lib/rpc/rpc.py | 2 +-
 rpc/rpc.py            | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/nfs4.0/lib/rpc/rpc.py b/nfs4.0/lib/rpc/rpc.py
index 24a7fc72eff0..585db3551f73 100644
--- a/nfs4.0/lib/rpc/rpc.py
+++ b/nfs4.0/lib/rpc/rpc.py
@@ -227,7 +227,7 @@ class RPCClient(object):
                 sock.bind(('', port))
                 return
             except socket.error as why:
-                if why[0] == errno.EADDRINUSE:
+                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 1fe285aa2b5b..814de4e08bc9 100644
--- a/rpc/rpc.py
+++ b/rpc/rpc.py
@@ -846,7 +846,7 @@ class ConnectionHandler(object):
                 s.bind(('', using))
                 return
             except socket.error as why:
-                if why[0] == errno.EADDRINUSE:
+                if why.errno == errno.EADDRINUSE:
                     using += 1
                     if port < 1024 <= using:
                         # If we ask for a secure port, make sure we don't
-- 
2.40.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* RE: [PATCH pynfs] rpc.py: Don't try to subscript an exception.
  2023-03-28  0:48 [PATCH pynfs] rpc.py: Don't try to subscript an exception NeilBrown
@ 2023-03-28 15:25 ` Frank Filz
  2023-03-30 15:33 ` Calum Mackay
  1 sibling, 0 replies; 3+ messages in thread
From: Frank Filz @ 2023-03-28 15:25 UTC (permalink / raw)
  To: 'NeilBrown', 'Bruce Fields', 'Jeff Layton'
  Cc: 'Linux NFS Mailing List'

Thanks. I have this patch in my repo and keep not getting around to submitting it.

Frank

> -----Original Message-----
> From: NeilBrown [mailto:neilb@suse.de]
> Sent: Monday, March 27, 2023 5:49 PM
> To: Bruce Fields <bfields@fieldses.org>; Jeff Layton <jlayton@kernel.org>
> Cc: Linux NFS Mailing List <linux-nfs@vger.kernel.org>
> Subject: [PATCH pynfs] rpc.py: Don't try to subscript an exception.
> 
> 
> As far as I can tell python3 has never supported subscripting of exceptions.
> So don't try to...
> 
> Signed-off-by: NeilBrown <neilb@suse.de>
> ---
>  nfs4.0/lib/rpc/rpc.py | 2 +-
>  rpc/rpc.py            | 2 +-
>  2 files changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/nfs4.0/lib/rpc/rpc.py b/nfs4.0/lib/rpc/rpc.py index
> 24a7fc72eff0..585db3551f73 100644
> --- a/nfs4.0/lib/rpc/rpc.py
> +++ b/nfs4.0/lib/rpc/rpc.py
> @@ -227,7 +227,7 @@ class RPCClient(object):
>                  sock.bind(('', port))
>                  return
>              except socket.error as why:
> -                if why[0] == errno.EADDRINUSE:
> +                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 1fe285aa2b5b..814de4e08bc9 100644
> --- a/rpc/rpc.py
> +++ b/rpc/rpc.py
> @@ -846,7 +846,7 @@ class ConnectionHandler(object):
>                  s.bind(('', using))
>                  return
>              except socket.error as why:
> -                if why[0] == errno.EADDRINUSE:
> +                if why.errno == errno.EADDRINUSE:
>                      using += 1
>                      if port < 1024 <= using:
>                          # If we ask for a secure port, make sure we don't
> --
> 2.40.0


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH pynfs] rpc.py: Don't try to subscript an exception.
  2023-03-28  0:48 [PATCH pynfs] rpc.py: Don't try to subscript an exception NeilBrown
  2023-03-28 15:25 ` Frank Filz
@ 2023-03-30 15:33 ` Calum Mackay
  1 sibling, 0 replies; 3+ messages in thread
From: Calum Mackay @ 2023-03-30 15:33 UTC (permalink / raw)
  To: NeilBrown, Bruce Fields, Jeff Layton; +Cc: Calum Mackay, Linux NFS Mailing List


[-- Attachment #1.1: Type: text/plain, Size: 1672 bytes --]

On 28/03/2023 1:48 am, NeilBrown wrote:
> 
> As far as I can tell python3 has never supported subscripting of
> exceptions.
> So don't try to...
> 
> Signed-off-by: NeilBrown <neilb@suse.de>

Thanks very much Neil.

I still don't quite have a repo ready, but will apply this (and others) 
as soon as I do.

cheers,
calum.


> ---
>   nfs4.0/lib/rpc/rpc.py | 2 +-
>   rpc/rpc.py            | 2 +-
>   2 files changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/nfs4.0/lib/rpc/rpc.py b/nfs4.0/lib/rpc/rpc.py
> index 24a7fc72eff0..585db3551f73 100644
> --- a/nfs4.0/lib/rpc/rpc.py
> +++ b/nfs4.0/lib/rpc/rpc.py
> @@ -227,7 +227,7 @@ class RPCClient(object):
>                   sock.bind(('', port))
>                   return
>               except socket.error as why:
> -                if why[0] == errno.EADDRINUSE:
> +                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 1fe285aa2b5b..814de4e08bc9 100644
> --- a/rpc/rpc.py
> +++ b/rpc/rpc.py
> @@ -846,7 +846,7 @@ class ConnectionHandler(object):
>                   s.bind(('', using))
>                   return
>               except socket.error as why:
> -                if why[0] == errno.EADDRINUSE:
> +                if why.errno == errno.EADDRINUSE:
>                       using += 1
>                       if port < 1024 <= using:
>                           # If we ask for a secure port, make sure we don't

-- 
Calum Mackay
Linux Kernel Engineering
Oracle Linux and Virtualisation

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 840 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2023-03-30 17:39 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-28  0:48 [PATCH pynfs] rpc.py: Don't try to subscript an exception NeilBrown
2023-03-28 15:25 ` Frank Filz
2023-03-30 15:33 ` Calum Mackay

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).