Skip to contentSkip to conversation

moveconfig.py: add try…except

PATCH New Trevor Woerner 2 participants 4 messages Mar 15, 2021 – Apr 13, 2021

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 moveconfig.py: add try…except

I keep getting a UnicodeDecodeError from one of the header files while modifying the headers:

Traceback (most recent call last):
File "tools/moveconfig.py", line 1953, in <module>
main()
File "tools/moveconfig.py", line 1927, in main
cleanup_headers(configs, options)
File "tools/moveconfig.py", line 675, in cleanup_headers
cleanup_one_header(header_path, patterns, options)
File "tools/moveconfig.py", line 599, in cleanup_one_header
lines = f.readlines()
File "/usr/lib64/python3.6/codecs.py", line 321, in decode
(result, consumed) = self._buffer_decode(data, self.errors, final)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0x83 in position 9: invalid start byte

I'm curious to know which header file is causing the problem.

---
 tools/moveconfig.py | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
tools/moveconfig.py +6 -1
index 9514d9a00c..dd92c00bb7 100755
@@ -596,7 +596,12 @@ def cleanup_one_header(header_path, patterns, options):
       options: option flags.
     """
     with open(header_path) as f:
-        lines = f.readlines()
+        try:
+            lines = f.readlines()
+        except:
+            print("caught exception: ", sys.exc_info()[0])
+            print("header_path: ", header_path)
+            lines = ""
 
     matched = []
     for i, line in enumerate(lines):
Signature · 1 line
2.30.0.rc0
#2 lore raw

PATCH 2/2 moveconfig.py: add to the "do not process" list

Skip the processing of *.aml and *.dat files while iterating through the source in order to process header files.

---
 tools/moveconfig.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/moveconfig.py +1 -1
index dd92c00bb7..1e08b3cada 100755
@@ -672,7 +672,7 @@ def cleanup_headers(configs, options):
                 continue
             for filename in filenames:
                 if not filename.endswith(('~', '.dts', '.dtsi', '.bin',
-                                          '.elf')):
+                                          '.elf','.aml','.dat')):
                     header_path = os.path.join(dirpath, filename)
                     # This file contains UTF-16 data and no CONFIG symbols
                     if header_path == 'include/video_font_data.h':
Signature · 1 line
2.30.0.rc0
#1 lore raw

PATCH 1/2 moveconfig.py: add try…except

In reply to Trevor Woerner

It looks like Simon beat me to this one with 7570d9bb47be24d9d73518742703f32126af8113 but I'm hoping 2/2 can still make it in.

Quoted 44 lines · Trevor Woerner

I keep getting a UnicodeDecodeError from one of the header files while modifying the headers:

Traceback (most recent call last):
File "tools/moveconfig.py", line 1953, in <module>
main()
File "tools/moveconfig.py", line 1927, in main
cleanup_headers(configs, options)
File "tools/moveconfig.py", line 675, in cleanup_headers
cleanup_one_header(header_path, patterns, options)
File "tools/moveconfig.py", line 599, in cleanup_one_header
lines = f.readlines()
File "/usr/lib64/python3.6/codecs.py", line 321, in decode
(result, consumed) = self._buffer_decode(data, self.errors, final)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0x83 in position 9: invalid start byte

I'm curious to know which header file is causing the problem.

---
 tools/moveconfig.py | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
tools/moveconfig.py +6 -1
index 9514d9a00c..dd92c00bb7 100755
@@ -596,7 +596,12 @@ def cleanup_one_header(header_path, patterns, options):
       options: option flags.
     """
     with open(header_path) as f:
-        lines = f.readlines()
+        try:
+            lines = f.readlines()
+        except:
+            print("caught exception: ", sys.exc_info()[0])
+            print("header_path: ", header_path)
+            lines = ""
 
     matched = []
     for i, line in enumerate(lines):
Signature · 1 line
2.30.0.rc0
#3 lore raw

PATCH 2/2 moveconfig.py: add to the "do not process" list

In reply to Trevor Woerner
Quoted 4 lines · Trevor Woerner

Skip the processing of *.aml and *.dat files while iterating through the source in order to process header files.

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 659 bytes
Desc: not available
URL: <https://lists.denx.de/pipermail/u-boot/attachments/20210413/6fc5a6df/attachment.sig>