diff mbox series

[v3,3/5] python3: no need to use an OrderedDict

Message ID 20261113143038.1651404-3-ross.burton@arm.com
State Changes Requested
Headers show
Series [v3,1/5] python3: remove obsolete reformatting of _sysconfigdata*.py | expand

Commit Message

Ross Burton Nov. 13, 2026, 2:30 p.m. UTC
As of Python 3.7, standard dictionaries are sorted by insertion order.
As this stable order was the only reason for using OrderedDict, we can
switch to using a normal dictionary.

Signed-off-by: Ross Burton <ross.burton@arm.com>
---
 meta/recipes-devtools/python/python3/create_manifest3.py | 7 +++----
 meta/recipes-devtools/python/python3_3.14.10.bb          | 4 ++--
 2 files changed, 5 insertions(+), 6 deletions(-)
diff mbox series

Patch

diff --git a/meta/recipes-devtools/python/python3/create_manifest3.py b/meta/recipes-devtools/python/python3/create_manifest3.py
index 288d5ede3a2..6d3108e46f7 100644
--- a/meta/recipes-devtools/python/python3/create_manifest3.py
+++ b/meta/recipes-devtools/python/python3/create_manifest3.py
@@ -43,7 +43,6 @@  import sys
 import subprocess
 import json
 import os
-import collections
 
 if '-d' in sys.argv:
     debugFlag = '-d'
@@ -60,7 +59,7 @@  for p in sys.path:
         nativelibfolder = p[:p.find(pivot)+len(pivot)]
 
 # Empty dict to hold the whole manifest
-new_manifest = collections.OrderedDict()
+new_manifest = {}
 
 # Check for repeated files, folders and wildcards
 allfiles = []
@@ -103,7 +102,7 @@  with open('python3-manifest.json') as manifest:
     manifest.seek(0)
     comments = manifest.read(json_start)
     manifest_str = manifest.read()
-    old_manifest = json.loads(manifest_str, object_pairs_hook=collections.OrderedDict)
+    old_manifest = json.loads(manifest_str)
 
 #
 # First pass to get core-package functionality, because we base everything on the fact that core is actually working
@@ -219,7 +218,7 @@  for pypkg in old_manifest:
 
 for pypkg in old_manifest:
     # Use an empty dict as data structure to hold data for each package and fill it up
-    new_manifest[pypkg] = collections.OrderedDict()
+    new_manifest[pypkg] = {}
     new_manifest[pypkg]['summary'] = old_manifest[pypkg]['summary']
     new_manifest[pypkg]['rdepends'] = []
     new_manifest[pypkg]['files'] = []
diff --git a/meta/recipes-devtools/python/python3_3.14.10.bb b/meta/recipes-devtools/python/python3_3.14.10.bb
index d8ccd3c2cc2..9c45f8e0c67 100644
--- a/meta/recipes-devtools/python/python3_3.14.10.bb
+++ b/meta/recipes-devtools/python/python3_3.14.10.bb
@@ -404,7 +404,7 @@  py_package_preprocess () {
 INCLUDE_PYCS ?= "1"
 
 python(){
-    import collections, json
+    import json
 
     filename = os.path.join(d.getVar('THISDIR'), 'python3', 'python3-manifest.json')
     # This python changes the datastore based on the contents of a file, so mark
@@ -416,7 +416,7 @@  python(){
         json_start = manifest_str.find('# EOC') + 6
         manifest_file.seek(json_start)
         manifest_str = manifest_file.read()
-        python_manifest = json.loads(manifest_str, object_pairs_hook=collections.OrderedDict)
+        python_manifest = json.loads(manifest_str)
 
     # First set RPROVIDES for -native case
     # Hardcoded since it cant be python3-native-foo, should be python3-foo-native