aboutsummaryrefslogtreecommitdiffstats
path: root/package/firmware/wireless-regdb/patches/010-regdb-fix-compatibility-with-python2.patch
blob: 81f50f5dc02d02202bf64b537cdc4017aba76778 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
From 651e39dee8605995b736b6056c6f7dc5c5a9c948 Mon Sep 17 00:00:00 2001
From: Johannes Berg <johannes.berg@intel.com>
Date: Thu, 22 Aug 2019 21:46:27 +0200
Subject: [PATCH] regdb: fix compatibility with python2

Various changes in the commit mentioned below broke
compatibility with python2. Restore it in a way that
makes it worth with both versions.

Fixes: f3c4969c2485 ("wireless-regdb: make scripts compatible with Python 3")
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Seth Forshee <seth.forshee@canonical.com>
---
 db2bin.py  | 2 +-
 db2fw.py   | 2 +-
 dbparse.py | 3 +--
 3 files changed, 3 insertions(+), 4 deletions(-)

--- a/db2bin.py
+++ b/db2bin.py
@@ -118,7 +118,7 @@ reg_country_ptr.set()
 for alpha2 in countrynames:
     coll = countries[alpha2]
     # struct regdb_file_reg_country
-    output.write(struct.pack('>BBxBI', alpha2[0], alpha2[1], coll.dfs_region, reg_rules_collections[coll.permissions]))
+    output.write(struct.pack('>2sxBI', alpha2, coll.dfs_region, reg_rules_collections[coll.permissions]))
 
 
 if len(sys.argv) > 3:
--- a/db2fw.py
+++ b/db2fw.py
@@ -85,7 +85,7 @@ countrynames = list(countries)
 countrynames.sort()
 for alpha2 in countrynames:
     coll = countries[alpha2]
-    output.write(struct.pack('>BB', alpha2[0], alpha2[1]))
+    output.write(struct.pack('>2s', alpha2))
     country_ptrs[alpha2] = PTR(output)
 output.write(b'\x00' * 4)
 
--- a/dbparse.py
+++ b/dbparse.py
@@ -1,6 +1,5 @@
 #!/usr/bin/env python
 
-from builtins import bytes
 from functools import total_ordering
 import sys, math
 from math import ceil, log
@@ -359,7 +358,7 @@ class DBParser(object):
         for cname in cnames:
             if len(cname) != 2:
                 self._warn("country '%s' not alpha2" % cname)
-            cname = bytes(cname, 'ascii')
+            cname = cname.encode('ascii')
             if not cname in self._countries:
                 self._countries[cname] = Country(dfs_region, comments=self._comments)
             self._current_countries[cname] = self._countries[cname]