Skip to contentSkip to conversation

rpcctl: SyntaxWarning: 'return' in a 'finally' block

PATCH In review Salvatore Bonaccorso 2 participants 5 messages Aug 22 – Aug 31

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 rpcctl: SyntaxWarning: 'return' in a 'finally' block

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.

---
 tools/rpcctl/rpcctl.py | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
tools/rpcctl/rpcctl.py +3 -2
index 29ae7d26f50e..42e238ca1c52 100755
@@ -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:
Signature · 1 line
2.55.0
#1 lore raw

Hi,

Quoted 33 lines · Salvatore Bonaccorso

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.

---
 tools/rpcctl/rpcctl.py | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
tools/rpcctl/rpcctl.py +3 -2
index 29ae7d26f50e..42e238ca1c52 100755
@@ -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:
Signature · 1 line
2.55.0

Including Anna's oracle.com address.

Regards,
Salvatore

#2 lore raw
In reply to Salvatore Bonaccorso
Quoted 11 lines · Salvatore Bonaccorso

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.

Committed... (tag: nfs-utils-2-9-3-rc2)

steved.

Quoted 20 lines
---
  tools/rpcctl/rpcctl.py | 5 +++--
  1 file changed, 3 insertions(+), 2 deletions(-)
tools/rpcctl/rpcctl.py +3 -2
index 29ae7d26f50e..42e238ca1c52 100755
@@ -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:
#3 lore raw
In reply to Salvatore Bonaccorso
Quoted 11 lines · Salvatore Bonaccorso

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.

Committed... (tag: nfs-utils-2-9-3-rc2)

steved.

Quoted 20 lines
---
  tools/rpcctl/rpcctl.py | 5 +++--
  1 file changed, 3 insertions(+), 2 deletions(-)
tools/rpcctl/rpcctl.py +3 -2
index 29ae7d26f50e..42e238ca1c52 100755
@@ -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:
#4 lore raw
In reply to Salvatore Bonaccorso
Quoted 11 lines · Salvatore Bonaccorso

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.

Committed... (tag: nfs-utils-2-9-3-rc2)

steved.

Quoted 20 lines
---
  tools/rpcctl/rpcctl.py | 5 +++--
  1 file changed, 3 insertions(+), 2 deletions(-)
tools/rpcctl/rpcctl.py +3 -2
index 29ae7d26f50e..42e238ca1c52 100755
@@ -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: