Skip to contentSkip to conversation

xen/tools: Fix gen-cpuid.py's ability to report errors

PATCH In review Andrew Cooper 3 participants 3 messages Nov 26, 2018

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 xen/tools: Fix gen-cpuid.py's ability to report errors

c/s 18596903 "xen/tools: support Python 2 and Python 3" unfortunately introduced a TypeError when changing how Fail exceptions were printed:

/local/xen.git/xen/../xen/tools/gen-cpuid.py:Traceback (most recent call last):

    File "/local/xen.git/xen/../xen/tools/gen-cpuid.py", line 483, in <module>
        sys.stderr.write(e)

TypeError: expected a character buffer object

Coerce e to a string before printing. While changing this, fold the three write() calls making up the line into a single one, and take the opportunity to neaten the output.

A sample error is:

/local/xen.git/xen/tools/gen-cpuid.py: Fail: Aliased value between FOO and BAR

---
CC: Jan Beulich <[email protected]>
CC: Wei Liu <[email protected]>
CC: Roger Pau Monné <[email protected]>

---
 xen/tools/gen-cpuid.py | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
xen/tools/gen-cpuid.py +2 -3
index 31fdee9..27569bd 100755
@@ -479,9 +479,8 @@ if __name__ == "__main__":
         sys.exit(main())
     except Fail:
         e = sys.exc_info()[1]
-        sys.stderr.write("%s:" % (sys.argv[0],))
-        sys.stderr.write(e)
-        sys.stderr.write("\n")
+        sys.stderr.write("%s: Fail: %s\n" %
+                         (os.path.abspath(sys.argv[0]), str(e)))
         sys.exit(1)
     except SystemExit:
         e = sys.exc_info()[1]
Signature · 7 lines
2.1.4


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Acked-by on v1 1/1
#1 lore raw
Quoted 12 lines · Andrew Cooper

c/s 18596903 "xen/tools: support Python 2 and Python 3" unfortunately introduced a TypeError when changing how Fail exceptions were printed:

/local/xen.git/xen/../xen/tools/gen-cpuid.py:Traceback (most recent call last):

    File "/local/xen.git/xen/../xen/tools/gen-cpuid.py", line 483, in <module>
        sys.stderr.write(e)

TypeError: expected a character buffer object

Coerce e to a string before printing. While changing this, fold the three write() calls making up the line into a single one, and take the opportunity to neaten the output.

Quoted 5 lines

A sample error is:

/local/xen.git/xen/tools/gen-cpuid.py: Fail: Aliased value between FOO and BAR

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

Acked-by
#2 lore raw
Quoted 14 lines
Quoted 1 line
Quoted 1 line · On 26.11.18 at 13:17, <[email protected]> wrote:
Quoted 12 lines · Andrew Cooper

c/s 18596903 "xen/tools: support Python 2 and Python 3" unfortunately introduced a TypeError when changing how Fail exceptions were printed:

/local/xen.git/xen/../xen/tools/gen-cpuid.py:Traceback (most recent call last):

    File "/local/xen.git/xen/../xen/tools/gen-cpuid.py", line 483, in <module>
        sys.stderr.write(e)

TypeError: expected a character buffer object

Coerce e to a string before printing. While changing this, fold the three write() calls making up the line into a single one, and take the opportunity to neaten the output.

Quoted 7 lines
Quoted 5 lines

A sample error is:

/local/xen.git/xen/tools/gen-cpuid.py: Fail: Aliased value between FOO and BAR

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel