Skip to contentSkip to conversation

lib: Replace codegen with ast.unparse()

PATCH New Richard Purdie 1 participant 1 message Apr 28 Library code

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 lib: Replace codegen with ast.unparse()

Since python 3.9, ast can generate code from an ast. We can therefore drop codegen.py and use python's internal functionality for this.

[YOCTO #16229]

---
 lib/bb/codeparser.py |   5 +-
 lib/codegen.py       | 564 -------------------------------------------
 2 files changed, 2 insertions(+), 567 deletions(-)
 delete mode 100644 lib/codegen.py
lib/bb/codeparser.py +2 -3
index 4f70cf7fe71..f906afab4c0 100644
@@ -25,7 +25,6 @@ recipe caches don't trigger "Taskhash mismatch" errors.
 
 import ast
 import sys
-import codegen
 import logging
 import inspect
 import bb.pysh as pysh
@@ -263,8 +262,8 @@ class PythonParser():
         """
 
         try:
-            funcstr = codegen.to_source(func)
-            argstr = codegen.to_source(arg)
+            funcstr = ast.unparse(func)
+            argstr = ast.unparse(arg)
         except TypeError:
             self.log.debug2('Failed to convert function and argument to source form')
         else:
lib/codegen.py deleted +0 -564

564 lines not on this page · raw message