utils/getdeveloperlib.py: fix check_output() return value decoding
PATCH 1/2 utils/getdeveloperlib.py: fix check_output() return value decoding
In Python 3.x, check_output() returns a "bytes" array, and not a string. Its result needs to be decoded to be turned into a string. Without this fix, "get-developers -c" bails out with:
Traceback (most recent call last):
File "/home/thomas/projets/buildroot/./utils/get-developers", line 105, in <module>
__main__()
File "/home/thomas/projets/buildroot/./utils/get-developers", line 53, in __main__
files = getdeveloperlib.check_developers(devs)
File "/home/thomas/projets/buildroot/utils/getdeveloperlib.py", line 280, in check_developers
files = subprocess.check_output(cmd).strip().split("\n")
TypeError: a bytes-like object is required, not 'str'
--- utils/getdeveloperlib.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
utils/getdeveloperlib.py +1 -1
@@ -277,7 +277,7 @@ def check_developers(developers, basepath=None): if basepath is None: basepath = os.getcwd() cmd = ["git", "--git-dir", os.path.join(basepath, ".git"), "ls-files"] - files = subprocess.check_output(cmd).strip().split("\n") + files = subprocess.check_output(cmd).decode(sys.stdout.encoding).strip().split("\n") unhandled_files = [] for f in files: handled = False
Signature · 6 lines
2.31.1 _______________________________________________ buildroot mailing list [email protected] https://lists.buildroot.org/mailman/listinfo/buildroot
PATCH 2/2 utils/getdeveloperlib.py: call Developer.hasfile() with relative path
In commit40bb37bd70d46822e803aaa5169dee8ff8b51093 ("utils/getdeveloperlib.py:
use relative paths for files"), the Developer class was changed to use relative paths, including for its .hasfile() method.
However the check_developers() function of getdeveloperlib.py was not updated accordingly, and continued to pass absolute paths. This caused "get-developers -c" to return the entire list of files in Buildroot as being unmaintained, as none of them were matching the file listed in the DEVELOPERS file.
--- utils/getdeveloperlib.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
utils/getdeveloperlib.py +1 -1
@@ -282,7 +282,7 @@ def check_developers(developers, basepath=None): for f in files: handled = False for d in developers: - if d.hasfile(os.path.join(basepath, f)): + if d.hasfile(f): handled = True break if not handled:
Signature · 6 lines
2.31.1 _______________________________________________ buildroot mailing list [email protected] https://lists.buildroot.org/mailman/listinfo/buildroot
Re: [Buildroot] [PATCH 2/2] utils/getdeveloperlib.py: call Developer.hasfile() with relative path
Quoted 7 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
"Thomas" == Thomas Petazzoni <[email protected]> writes:
In commit
40bb37bd70d46822e803aaa5169dee8ff8b51093("utils/getdeveloperlib.py:
use relative paths for files"), the Developer class was changed to use relative paths, including for its .hasfile() method.
Quoted 7 lines
However the
check_developers()function ofgetdeveloperlib.pywas not updated accordingly, and continued to pass absolute paths. This caused "get-developers -c" to return the entire list of files in Buildroot as being unmaintained, as none of them were matching the file listed in the DEVELOPERS file.Signed-off-by Thomas Petazzoni <[email protected]>
Committed to 2021.02.x and 2021.08.x, thanks.
Signature · 5 lines
Bye, Peter Korsgaard _______________________________________________ buildroot mailing list [email protected] https://lists.buildroot.org/mailman/listinfo/buildroot
Quoted 8 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
"Thomas" == Thomas Petazzoni <[email protected]> writes:
In Python 3.x,
check_output()returns a "bytes" array, and not a string. Its result needs to be decoded to be turned into a string. Without this fix, "get-developers -c" bails out with:Traceback (most recent call last):
File "/home/thomas/projets/buildroot/./utils/get-developers", line 105, in <module>
Quoted 8 lines
__main__()File "
/home/thomas/projets/buildroot/./utils/get-developers", line 53, in__main__
files =getdeveloperlib.check_developers(devs)
File "/home/thomas/projets/buildroot/utils/getdeveloperlib.py", line 280, incheck_developers
files = subprocess.check_output(cmd).strip().split("\n")
TypeError: a bytes-like object is required, not 'str'Signed-off-by Thomas Petazzoni <[email protected]>
Alternatively we could use universal_newlines=True, but Ok - Committed to 2021.02.x and 2021.08.x, thanks.
Signature · 5 lines
Bye, Peter Korsgaard _______________________________________________ buildroot mailing list [email protected] https://lists.buildroot.org/mailman/listinfo/buildroot
Quoted 15 lines · On Wed, 03 Nov 2021 22:15:42 +0100 Peter Korsgaard <[email protected]> wrote:
Quoted 14 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
"Thomas" == Thomas Petazzoni <[email protected]> writes:
In Python 3.x,
check_output()returns a "bytes" array, and not a string. Its result needs to be decoded to be turned into a string. Without this fix, "get-developers -c" bails out with:Traceback (most recent call last):
File "/home/thomas/projets/buildroot/./utils/get-developers", line 105, in <module>__main__()File "
/home/thomas/projets/buildroot/./utils/get-developers", line 53, in__main__
files =getdeveloperlib.check_developers(devs)
File "/home/thomas/projets/buildroot/utils/getdeveloperlib.py", line 280, incheck_developers
files = subprocess.check_output(cmd).strip().split("\n")
TypeError: a bytes-like object is required, not 'str'
Quoted 4 lines
Quoted 1 line
Signed-off-by Thomas Petazzoni <[email protected]>Alternatively we could use universal_newlines=True, but Ok - Committed to 2021.02.x and 2021.08.x, thanks.
But was this committed to master already? It seems not. Isn't it dangerous to start committing stuff to stable branches that are not in master? I thought you were only cherry-picking stuff from master.
Thomas
Signature · 7 lines
Thomas Petazzoni, co-owner and CEO, Bootlin Embedded Linux and Kernel engineering and training https://bootlin.com _______________________________________________ buildroot mailing list [email protected] https://lists.buildroot.org/mailman/listinfo/buildroot
Quoted 20 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
"Thomas" == Thomas Petazzoni <[email protected]> writes:
Quoted 15 lines · On Wed, 03 Nov 2021 22:15:42 +0100 Peter Korsgaard <[email protected]> wrote:
Quoted 14 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
"Thomas" == Thomas Petazzoni <[email protected]> writes:
In Python 3.x,
check_output()returns a "bytes" array, and not a string. Its result needs to be decoded to be turned into a string. Without this fix, "get-developers -c" bails out with:Traceback (most recent call last):
File "/home/thomas/projets/buildroot/./utils/get-developers", line 105, in <module>__main__()File "
/home/thomas/projets/buildroot/./utils/get-developers", line 53, in__main__
files =getdeveloperlib.check_developers(devs)
File "/home/thomas/projets/buildroot/utils/getdeveloperlib.py", line 280, incheck_developers
files = subprocess.check_output(cmd).strip().split("\n")
TypeError: a bytes-like object is required, not 'str'
Quoted 8 lines
Quoted 4 lines
Quoted 1 line
Signed-off-by Thomas Petazzoni <[email protected]>Alternatively we could use universal_newlines=True, but Ok - Committed to 2021.02.x and 2021.08.x, thanks.
But was this committed to master already? It seems not. Isn't it dangerous to start committing stuff to stable branches that are not in master? I thought you were only cherry-picking stuff from master.
I am, you applied it to master yesterday?
https://git.buildroot.net/buildroot/commit/?id=53da6a7c05f75af925d235f22db2142b5067806e
Signature · 5 lines
Bye, Peter Korsgaard _______________________________________________ buildroot mailing list [email protected] https://lists.buildroot.org/mailman/listinfo/buildroot
Quoted 7 lines · On Wed, 03 Nov 2021 23:10:29 +0100 Peter Korsgaard <[email protected]> wrote:
Quoted 3 lines
But was this committed to master already? It seems not. Isn't it dangerous to start committing stuff to stable branches that are not in master? I thought you were only cherry-picking stuff from master.
I am, you applied it to master yesterday?
https://git.buildroot.net/buildroot/commit/?id=53da6a7c05f75af925d235f22db2142b5067806e
Meh, applying them was not intentional :-/
Sorry for the mess.
Thomas
Signature · 7 lines
Thomas Petazzoni, co-owner and CEO, Bootlin Embedded Linux and Kernel engineering and training https://bootlin.com _______________________________________________ buildroot mailing list [email protected] https://lists.buildroot.org/mailman/listinfo/buildroot