Mesa (main): vulkan: Rework mako error handling in python generators

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Fri Oct 29 23:37:09 UTC 2021


Module: Mesa
Branch: main
Commit: a208b849f337a60f87216575bc148d8de20517b6
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=a208b849f337a60f87216575bc148d8de20517b6

Author: Jason Ekstrand <jason at jlekstrand.net>
Date:   Fri Oct 29 12:23:45 2021 -0500

vulkan: Rework mako error handling in python generators

Suggested-by: Dylan Baker <dylan at pnwbakers.com>
Reviewed-by: Dylan Baker <dylan at pnwbakers.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13156>

---

 src/vulkan/util/vk_cmd_queue_gen.py            | 10 ++++------
 src/vulkan/util/vk_commands_gen.py             | 10 ++++------
 src/vulkan/util/vk_dispatch_table_gen.py       | 10 ++++------
 src/vulkan/util/vk_entrypoints_gen.py          | 10 ++++------
 src/vulkan/util/vk_physical_device_features.py | 10 ++++------
 5 files changed, 20 insertions(+), 30 deletions(-)

diff --git a/src/vulkan/util/vk_cmd_queue_gen.py b/src/vulkan/util/vk_cmd_queue_gen.py
index 539392a3101..3c0d7e6ef72 100644
--- a/src/vulkan/util/vk_cmd_queue_gen.py
+++ b/src/vulkan/util/vk_cmd_queue_gen.py
@@ -435,12 +435,10 @@ def main():
         # to print a useful stack trace and prints it, then exits with
         # status 1, if python is run with debug; otherwise it just raises
         # the exception
-        if __debug__:
-            import sys
-            from mako import exceptions
-            sys.stderr.write(exceptions.text_error_template().render() + '\n')
-            sys.exit(1)
-        raise
+        import sys
+        from mako import exceptions
+        print(exceptions.text_error_template().render(), file=sys.stderr)
+        sys.exit(1)
 
 if __name__ == '__main__':
     main()
diff --git a/src/vulkan/util/vk_commands_gen.py b/src/vulkan/util/vk_commands_gen.py
index 610c835ffc3..004e18cfbb8 100644
--- a/src/vulkan/util/vk_commands_gen.py
+++ b/src/vulkan/util/vk_commands_gen.py
@@ -132,12 +132,10 @@ def main():
         # to print a useful stack trace and prints it, then exits with
         # status 1, if python is run with debug; otherwise it just raises
         # the exception
-        if __debug__:
-            import sys
-            from mako import exceptions
-            sys.stderr.write(exceptions.text_error_template().render() + '\n')
-            sys.exit(1)
-        raise
+        import sys
+        from mako import exceptions
+        print(exceptions.text_error_template().render(), file=sys.stderr)
+        sys.exit(1)
 
 if __name__ == '__main__':
     main()
diff --git a/src/vulkan/util/vk_dispatch_table_gen.py b/src/vulkan/util/vk_dispatch_table_gen.py
index eb6b0cd28e2..abfa63bfe62 100644
--- a/src/vulkan/util/vk_dispatch_table_gen.py
+++ b/src/vulkan/util/vk_dispatch_table_gen.py
@@ -963,12 +963,10 @@ def main():
         # to print a useful stack trace and prints it, then exits with
         # status 1, if python is run with debug; otherwise it just raises
         # the exception
-        if __debug__:
-            import sys
-            from mako import exceptions
-            sys.stderr.write(exceptions.text_error_template().render() + '\n')
-            sys.exit(1)
-        raise
+        import sys
+        from mako import exceptions
+        print(exceptions.text_error_template().render(), file=sys.stderr)
+        sys.exit(1)
 
 
 if __name__ == '__main__':
diff --git a/src/vulkan/util/vk_entrypoints_gen.py b/src/vulkan/util/vk_entrypoints_gen.py
index 078b6daec0b..4c911d63b05 100644
--- a/src/vulkan/util/vk_entrypoints_gen.py
+++ b/src/vulkan/util/vk_entrypoints_gen.py
@@ -248,12 +248,10 @@ def main():
         # to print a useful stack trace and prints it, then exits with
         # status 1, if python is run with debug; otherwise it just raises
         # the exception
-        if __debug__:
-            import sys
-            from mako import exceptions
-            sys.stderr.write(exceptions.text_error_template().render() + '\n')
-            sys.exit(1)
-        raise
+        import sys
+        from mako import exceptions
+        print(exceptions.text_error_template().render(), file=sys.stderr)
+        sys.exit(1)
 
 if __name__ == '__main__':
     main()
diff --git a/src/vulkan/util/vk_physical_device_features.py b/src/vulkan/util/vk_physical_device_features.py
index b9665e56417..57282acf93a 100644
--- a/src/vulkan/util/vk_physical_device_features.py
+++ b/src/vulkan/util/vk_physical_device_features.py
@@ -239,12 +239,10 @@ def main():
         # to print a useful stack trace and prints it, then exits with
         # status 1, if python is run with debug; otherwise it just raises
         # the exception
-        if __debug__:
-            import sys
-            from mako import exceptions
-            sys.stderr.write(exceptions.text_error_template().render() + '\n')
-            sys.exit(1)
-        raise
+        import sys
+        from mako import exceptions
+        print(exceptions.text_error_template().render(), file=sys.stderr)
+        sys.exit(1)
 
 if __name__ == '__main__':
     main()



More information about the mesa-commit mailing list