* [Buildroot] [git commit branch/2022.02.x] utils/genrandconfig: dump traceback for unhandled exceptions
@ 2022-09-17 11:05 Peter Korsgaard
0 siblings, 0 replies; only message in thread
From: Peter Korsgaard @ 2022-09-17 11:05 UTC (permalink / raw)
To: buildroot
commit: https://git.buildroot.net/buildroot/commit/?id=f3eca5d7e073f9dc1f10dca3aa97bfe2089f88c8
branch: https://git.buildroot.net/buildroot/commit/?id=refs/heads/2022.02.x
In case of an unexpected error, we currently only print the exception as
an str(). For example, the recent issue with the glibc version check
only reported:
TypeError: cannot use a string pattern on a bytes-like object
That does not help in fixing the issue; the exception text is also not
usually very user-friendly either anyway.
We change the reporting to print the traceback, which in the glibc
version check mentioned above, the error is reported as:
Traceback (most recent call last):
File "./utils/genrandconfig", line 740, in <module>
ret = gen_config(args)
File "./utils/genrandconfig", line 676, in gen_config
if not is_toolchain_usable(configfile, toolchainconfig):
File "./utils/genrandconfig", line 186, in is_toolchain_usable
if StrictVersion('2.14') > StrictVersion(glibc_version):
File "/usr/lib/python3.8/distutils/version.py", line 40, in __init__
self.parse(vstring)
File "/usr/lib/python3.8/distutils/version.py", line 135, in parse
match = self.version_re.match(vstring)
TypeError: cannot use a string pattern on a bytes-like object
With this, the error is much easier to pinpoint (it's the last one that
is not in a system module).
Signed-off-by: Yann E. MORIN <yann.morin.1998@free.fr>
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
(cherry picked from commit b6bfa3f744d1dabd99ac74cf8008fb0cdfecdcb8)
Signed-off-by: Peter Korsgaard <peter@korsgaard.com>
---
utils/genrandconfig | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/utils/genrandconfig b/utils/genrandconfig
index fba2b0a009..629efbbfd9 100755
--- a/utils/genrandconfig
+++ b/utils/genrandconfig
@@ -24,6 +24,7 @@ import os
from random import randint
import subprocess
import sys
+import traceback
from distutils.version import StrictVersion
import platform
@@ -443,7 +444,7 @@ if __name__ == '__main__':
try:
ret = gen_config(args)
- except Exception as e:
- print(str(e), file=sys.stderr)
+ except Exception:
+ traceback.print_exc()
parser.exit(1)
parser.exit(ret)
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2022-09-17 11:07 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-17 11:05 [Buildroot] [git commit branch/2022.02.x] utils/genrandconfig: dump traceback for unhandled exceptions Peter Korsgaard
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.