0002-MakeHeader-open-files-using-binary-mode.patch 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. From 1a83a3e6ae0841a0dc4c7eb08a1a71930e99666c Mon Sep 17 00:00:00 2001
  2. From: Romain Naour <romain.naour@gmail.com>
  3. Date: Sun, 18 Mar 2018 21:57:54 +0100
  4. Subject: [PATCH] MakeHeader: open files using binary mode
  5. By default, open(sys.argv[1]) use Unicode mode.
  6. The readlines() will try to convert with the default codec
  7. (which depends on the i18n settings, so 'ascii' under
  8. LC_ALL=C)
  9. Open files using binary mode so no conversion will be done
  10. by readlines(). But then, normal strings can't be used in
  11. the rest of the code; either all strings have to be prefixed
  12. with b'' or (simpler) the read line has to be converted to
  13. a unicode string by calling decode() on it.
  14. http://lists.busybox.net/pipermail/buildroot/2018-February/214373.html
  15. Fixes:
  16. http://autobuild.buildroot.net/results/9ce/9ce2ef5ef694253b9759016c9702c5c6be7849a1
  17. Signed-off-by: Romain Naour <romain.naour@gmail.com>
  18. ---
  19. scripts/MakeHeader.py | 3 ++-
  20. 1 file changed, 2 insertions(+), 1 deletion(-)
  21. diff --git a/scripts/MakeHeader.py b/scripts/MakeHeader.py
  22. index 4841bda..dd0798c 100755
  23. --- a/scripts/MakeHeader.py
  24. +++ b/scripts/MakeHeader.py
  25. @@ -16,7 +16,7 @@ SKIPONE=4
  26. state = ANY
  27. static = 0
  28. -file = open(sys.argv[1])
  29. +file = open(sys.argv[1], 'rb')
  30. name = sys.argv[1][:-2]
  31. out = StringIO()
  32. @@ -31,6 +31,7 @@ out.write( "#define HEADER_" + os.path.basename(name) + "\n")
  33. is_blank = False
  34. for line in file.readlines():
  35. line = line[:-1]
  36. + line = line.decode('utf-8')
  37. if state == ANY:
  38. if line == '/*{':
  39. state = COPY
  40. --
  41. 2.14.3