Skip to contentSkip to conversation

gen_compile_commands: fix missing 'sys' package

PATCH In review Kortan 4 participants 5 messages Sep 8, 2021 – Sep 9, 2021

Subsystems (2)
lore
Share & tools
lore

Kortan

author
#0 lore raw

PATCH v2 1/1 gen_compile_commands: fix missing 'sys' package

We need to import the 'sys' package since the script has called sys.exit() method.

---
Changes v1 -> v2:
* Fix commit title.
* Improve commit message.

 scripts/clang-tools/gen_compile_commands.py | 1 +
 1 file changed, 1 insertion(+)
scripts/clang-tools/gen_compile_commands.py +1 -0
index 0033eedce003..1d1bde1fd45e 100755
@@ -13,6 +13,7 @@ import logging
 import os
 import re
 import subprocess
+import sys
 
 _DEFAULT_OUTPUT = 'compile_commands.json'
 _DEFAULT_LOG_LEVEL = 'WARNING'
Signature · 1 line
2.33.0
maintainer Reviewed-by on v2 1/1
#1 lore raw
Quoted 4 lines · Kortan

We need to import the 'sys' package since the script has called sys.exit() method.

Thank you for making those changes!

I should have mentioned that this probably warrants a Fixes: tag, which can be generated by running:

$ git show -s --format='Fixes: %h ("%s")' 6ad7cbc01527223f3f92baac9b122f15651cf76b
Fixes: 6ad7cbc01527 ("Makefile: Add clang-tidy and static analyzer support to makefile")

as that was the patch that introduced this issue. I personally have a git alias for this as it comes up enough.

$ git config --get alias.fixes
show -s --format="Fixes: %h (\"%s\")"

I do not think this warrants a v3, just something to keep in mind for the future.

Fixes 6ad7cbc01527 ("Makefile: Add clang-tidy and static analyzer support to makefile")
Quoted 24 lines

---
Changes v1 -> v2:
* Fix commit title.
* Improve commit message.

 scripts/clang-tools/gen_compile_commands.py | 1 +
 1 file changed, 1 insertion(+)
scripts/clang-tools/gen_compile_commands.py +1 -0
index 0033eedce003..1d1bde1fd45e 100755
@@ -13,6 +13,7 @@ import logging
 import os
 import re
 import subprocess
+import sys
 
 _DEFAULT_OUTPUT = 'compile_commands.json'
 _DEFAULT_LOG_LEVEL = 'WARNING'
Signature · 1 line
2.33.0
#2 lore raw
Quoted 18 lines · Nathan Chancellor
Quoted 4 lines · Kortan

We need to import the 'sys' package since the script has called sys.exit() method.

Thank you for making those changes!

I should have mentioned that this probably warrants a Fixes: tag, which can be generated by running:

$ git show -s --format='Fixes: %h ("%s")' 6ad7cbc01527223f3f92baac9b122f15651cf76b
Fixes: 6ad7cbc01527 ("Makefile: Add clang-tidy and static analyzer support to makefile")

as that was the patch that introduced this issue. I personally have a git alias for this as it comes up enough.

Quoted 8 lines
$ git config --get alias.fixes
show -s --format="Fixes: %h (\"%s\")"

I do not think this warrants a v3, just something to keep in mind for the future.

Fixes 6ad7cbc01527 ("Makefile: Add clang-tidy and static analyzer support to makefile")

Applied to linux-kbuild
with Fixes and Nathan's Reviewed-by.
Thanks.

Quoted 24 lines
Quoted 24 lines

---
Changes v1 -> v2:
* Fix commit title.
* Improve commit message.

 scripts/clang-tools/gen_compile_commands.py | 1 +
 1 file changed, 1 insertion(+)
scripts/clang-tools/gen_compile_commands.py +1 -1
index 0033eedce003..1d1bde1fd45e 100755
@@ -13,6 +13,7 @@ import logging
 import os
 import re
 import subprocess
+import sys
 
 _DEFAULT_OUTPUT = 'compile_commands.json'
 _DEFAULT_LOG_LEVEL = 'WARNING'
--

2.33.0

Signature · 2 lines
Best Regards
Masahiro Yamada
#3 lore raw
In reply to Kortan
Quoted 5 lines · Kortan

We need to import the 'sys' package since the script has called sys.exit() method.

I'm quite sure I've run this script before; how have we not noticed such an issue before?

Quoted 27 lines

---
Changes v1 -> v2:
* Fix commit title.
* Improve commit message.

 scripts/clang-tools/gen_compile_commands.py | 1 +
 1 file changed, 1 insertion(+)
scripts/clang-tools/gen_compile_commands.py +1 -1
index 0033eedce003..1d1bde1fd45e 100755
@@ -13,6 +13,7 @@ import logging
 import os
 import re
 import subprocess
+import sys
 
 _DEFAULT_OUTPUT = 'compile_commands.json'
 _DEFAULT_LOG_LEVEL = 'WARNING'
--

2.33.0

--
You received this message because you are subscribed to the Google Groups "Clang Built Linux" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/clang-built-linux/20210908032847.18683-1-kortanzh%40gmail.com.

Signature · 2 lines
Thanks,
~Nick Desaulniers
#4 lore raw
Quoted 9 lines · Nick Desaulniers' via Clang Built Linux
Quoted 5 lines · Kortan

We need to import the 'sys' package since the script has called sys.exit() method.

I'm quite sure I've run this script before; how have we not noticed such an issue before?

Nobody hitting the error paths in this script?

$ cat test.py
import sys

if __name__ == '__main__':

    a = int(sys.argv[1])
    print("a = %d" % a)
    if a == 2:
        printf(os.uname())
$ python3 test.py 1
$ python3 test.py 2
a = 2
Traceback (most recent call last):
  File "/home/nathan/test.py", line 7, in <module>
    print(os.uname())
NameError: name 'os' is not defined
Quoted 23 lines
Quoted 23 lines

---
Changes v1 -> v2:
* Fix commit title.
* Improve commit message.

  scripts/clang-tools/gen_compile_commands.py | 1 +
  1 file changed, 1 insertion(+)
scripts/clang-tools/gen_compile_commands.py +1 -1
index 0033eedce003..1d1bde1fd45e 100755
@@ -13,6 +13,7 @@ import logging
  import os
  import re
  import subprocess
+import sys
 
  _DEFAULT_OUTPUT = 'compile_commands.json'
  _DEFAULT_LOG_LEVEL = 'WARNING'
--

2.33.0