Skip to contentSkip to conversation

tools: ynl: avoid dict errors on older Python versions

PATCH Applied Jakub Kicinski 4 participants 4 messages May 24, 2023 – May 26, 2023

Subsystems (3)
lore
Share & tools
lore

Jakub Kicinski

author maintainer
#0 lore raw

PATCH 1/1 tools: ynl: avoid dict errors on older Python versions

Python 3.9.0 or newer supports combining dicts() with |, but older versions of Python are still used in the wild (e.g. on CentOS 8, which goes EoL May 31, 2024). With Python 3.6.8 we get:

TypeError: unsupported operand type(s) for |: 'dict' and 'dict'

Use older syntax. Tested with non-legacy families only.

Fixes f036d936ca57 ("tools: ynl: Add fixed-header support to ynl")

---
CC: [email protected]

This is arguably not a fix, but those trying YNL on 6.4 will likely appreciate not running into the problem.

---
 tools/net/ynl/lib/ynl.py | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
tools/net/ynl/lib/ynl.py +3 -2
index 39a2296c0003..7c7a54d6841c 100644
@@ -578,8 +578,9 @@ genl_family_name_to_id = None
                         print('Unexpected message: ' + repr(gm))
                         continue
 
-                rsp.append(self._decode(gm.raw_attrs, op.attr_set.name)
-                           | gm.fixed_header_attrs)
+                rsp_msg = self._decode(gm.raw_attrs, op.attr_set.name)
+                rsp_msg.update(gm.fixed_header_attrs)
+                rsp.append(rsp_msg)
 
         if not rsp:
             return None
Signature · 1 line
2.40.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 11 lines · Jakub Kicinski

Python 3.9.0 or newer supports combining dicts() with |, but older versions of Python are still used in the wild (e.g. on CentOS 8, which goes EoL May 31, 2024). With Python 3.6.8 we get:

TypeError: unsupported operand type(s) for |: 'dict' and 'dict'

Use older syntax. Tested with non-legacy families only.

Fixes f036d936ca57 ("tools: ynl: Add fixed-header support to ynl")
maintainer Reviewed-by Tested-by on v1 1/1
#2 lore raw
In reply to Jakub Kicinski
Quoted 9 lines · Jakub Kicinski

Python 3.9.0 or newer supports combining dicts() with |, but older versions of Python are still used in the wild (e.g. on CentOS 8, which goes EoL May 31, 2024). With Python 3.6.8 we get:

TypeError: unsupported operand type(s) for |: 'dict' and 'dict'

Use older syntax. Tested with non-legacy families only.

Quoted 7 lines
Fixes f036d936ca57 ("tools: ynl: Add fixed-header support to ynl")

---
CC: [email protected]

This is arguably not a fix, but those trying YNL on 6.4 will likely appreciate not running into the problem.

I just hit the issue on Ubuntu on a BF2 so thank you for getting a fix out before me! Tested with ovs_datapath.

#3 lore raw
In reply to Jakub Kicinski
This patch was applied to netdev/net.git (main) by Jakub Kicinski <[email protected]>:

Hello:

This patch was applied to netdev/net.git (main)
by Jakub Kicinski <[email protected]>:

Quoted 8 lines · On Wed, 24 May 2023 10:07:12 -0700 you wrote:

Python 3.9.0 or newer supports combining dicts() with |, but older versions of Python are still used in the wild (e.g. on CentOS 8, which goes EoL May 31, 2024). With Python 3.6.8 we get:

TypeError: unsupported operand type(s) for |: 'dict' and 'dict'

[...]

Here is the summary with links:
- [net] tools: ynl: avoid dict errors on older Python versions

    https://git.kernel.org/netdev/net/c/081e8df68199

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html