#1144982 python3.14 says /sbin/rpcctl:47: SyntaxWarning: 'return' in a 'finally' block

Package:
nfs-common
Source:
nfs-common
Description:
NFS support files common to client and server
Submitter:
Trent W. Buck
Date:
2026-08-22 15:13:01 UTC
Severity:
normal
Tags:
#1144982#5
Date:
2026-08-21 07:14:59 UTC
From:
To:
Debian 14 / python 3.14 now complains about rpcctl.

    root@hera:/# rpcctl --help
    /sbin/rpcctl:47: SyntaxWarning: 'return' in a 'finally' block
      return res
    [...]

    root@hera:/# sed -n -e '38,48p' /sbin/rpcctl

    def read_info_file(path):
        """Read an xprt or xprt switch information file."""
        res = collections.defaultdict(int)
        try:
            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

Based on https://github.com/iritkatriel/finally#:~:text=contains%20only%20a%20return
I think the correct fix is this edit:

        -finally:
        -    return res
        +return res

See also:

https://docs.python.org/3/whatsnew/3.14.html#pep-765-control-flow-in-finally-blocks
https://peps.python.org/pep-0765/

#1144982#12
Date:
2026-08-22 14:41:42 UTC
From:
To:
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" <trentbuck@gmail.com>
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 <carnil@debian.org>
---
 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:

#1144982#19
Date:
2026-08-22 15:11:39 UTC
From:
To:
Hi,

Including Anna's oracle.com address.

Regards,
Salvatore