010-regdb-fix-compatibility-with-python2.patch 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. From 651e39dee8605995b736b6056c6f7dc5c5a9c948 Mon Sep 17 00:00:00 2001
  2. From: Johannes Berg <[email protected]>
  3. Date: Thu, 22 Aug 2019 21:46:27 +0200
  4. Subject: [PATCH] regdb: fix compatibility with python2
  5. Various changes in the commit mentioned below broke
  6. compatibility with python2. Restore it in a way that
  7. makes it worth with both versions.
  8. Fixes: f3c4969c2485 ("wireless-regdb: make scripts compatible with Python 3")
  9. Signed-off-by: Johannes Berg <[email protected]>
  10. Signed-off-by: Seth Forshee <[email protected]>
  11. ---
  12. db2bin.py | 2 +-
  13. db2fw.py | 2 +-
  14. dbparse.py | 3 +--
  15. 3 files changed, 3 insertions(+), 4 deletions(-)
  16. --- a/db2bin.py
  17. +++ b/db2bin.py
  18. @@ -118,7 +118,7 @@ reg_country_ptr.set()
  19. for alpha2 in countrynames:
  20. coll = countries[alpha2]
  21. # struct regdb_file_reg_country
  22. - output.write(struct.pack('>BBxBI', alpha2[0], alpha2[1], coll.dfs_region, reg_rules_collections[coll.permissions]))
  23. + output.write(struct.pack('>2sxBI', alpha2, coll.dfs_region, reg_rules_collections[coll.permissions]))
  24. if len(sys.argv) > 3:
  25. --- a/db2fw.py
  26. +++ b/db2fw.py
  27. @@ -85,7 +85,7 @@ countrynames = list(countries)
  28. countrynames.sort()
  29. for alpha2 in countrynames:
  30. coll = countries[alpha2]
  31. - output.write(struct.pack('>BB', alpha2[0], alpha2[1]))
  32. + output.write(struct.pack('>2s', alpha2))
  33. country_ptrs[alpha2] = PTR(output)
  34. output.write(b'\x00' * 4)
  35. --- a/dbparse.py
  36. +++ b/dbparse.py
  37. @@ -1,6 +1,5 @@
  38. #!/usr/bin/env python
  39. -from builtins import bytes
  40. from functools import total_ordering
  41. import sys, math
  42. from math import ceil, log
  43. @@ -359,7 +358,7 @@ class DBParser(object):
  44. for cname in cnames:
  45. if len(cname) != 2:
  46. self._warn("country '%s' not alpha2" % cname)
  47. - cname = bytes(cname, 'ascii')
  48. + cname = cname.encode('ascii')
  49. if not cname in self._countries:
  50. self._countries[cname] = Country(dfs_region, comments=self._comments)
  51. self._current_countries[cname] = self._countries[cname]