[Lldb-commits] [lldb] 9f98949 - [lldb] Move the python module import workaround further up

Adrian Prantl via lldb-commits lldb-commits at lists.llvm.org
Fri Dec 6 17:02:10 PST 2024


Author: Adrian Prantl
Date: 2024-12-06T17:01:58-08:00
New Revision: 9f98949c9424addbc573fac7912cc164965b8994

URL: https://github.com/llvm/llvm-project/commit/9f98949c9424addbc573fac7912cc164965b8994
DIFF: https://github.com/llvm/llvm-project/commit/9f98949c9424addbc573fac7912cc164965b8994.diff

LOG: [lldb] Move the python module import workaround further up

Added: 
    

Modified: 
    lldb/examples/python/formatter_bytecode.py

Removed: 
    


################################################################################
diff  --git a/lldb/examples/python/formatter_bytecode.py b/lldb/examples/python/formatter_bytecode.py
index 0930d50013571e..ccd0c68a75483c 100644
--- a/lldb/examples/python/formatter_bytecode.py
+++ b/lldb/examples/python/formatter_bytecode.py
@@ -463,6 +463,12 @@ def next_byte():
 
 
 if __name__ == "__main__":
+    # Work around the fact that one of the local files is called
+    # types.py, which breaks some versions of python.
+    import os, sys
+
+    path = os.path.abspath(os.path.dirname(__file__))
+    sys.path.remove(path)
     import argparse
 
     parser = argparse.ArgumentParser(
@@ -487,12 +493,6 @@ def next_byte():
     # Tests.
     ############################################################################
     if args.test:
-        # Work around the fact that one of the local files is calles
-        # types.py, which breaks some versions of python.
-        import os, sys
-
-        path = os.path.abspath(os.path.dirname(__file__))
-        sys.path.remove(path)
         import unittest
 
         class TestCompiler(unittest.TestCase):


        


More information about the lldb-commits mailing list