[PATCH] rpcctl: SyntaxWarning: 'return' in a 'finally' block

Salvatore Bonaccorso <[email protected]>
Newsgroups org.kernel.vger.linux-nfs
Message-ID <[email protected]>
Trent W. Buck reported that when using rpcctl with Python 3.14
version, a SyntaxWarning warning is issued on the use of return in the
finally block in the read_info_file function.

Replace the finally clause with an except BaseException, and dedent the
return by one level up.

Reported-by: "Trent W. Buck" <[email protected]>
Link: https://docs.python.org/3/whatsnew/3.14.html#pep-765-control-flow-in-finally-blocks
Closes: https://bugs.debian.org/1144982
Signed-off-by: Salvatore Bonaccorso <[email protected]>
---
 tools/rpcctl/rpcctl.py | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/tools/rpcctl/rpcctl.py b/tools/rpcctl/rpcctl.py
index 29ae7d26f50e..42e238ca1c52 100755
--- a/tools/rpcctl/rpcctl.py
+++ b/tools/rpcctl/rpcctl.py
@@ -43,8 +43,9 @@ def read_info_file(path):
         with open(path) as info:
             lines = [line.split("=", 1) for line in info if "=" in line]
             res.update({key: int(val.strip()) for (key, val) in lines})
-    finally:
-        return res
+    except BaseException:
+        pass
+    return res
 
 
 class Xprt:
-- 
2.55.0
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.