codeop: Initial micropython support.

Oliver Robson 2022-06-21 09:12:41 +10:00 zatwierdzone przez Andrew Leech
rodzic ae19d103b3
commit 7444302ac6
1 zmienionych plików z 8 dodań i 6 usunięć

Wyświetl plik

@ -32,11 +32,12 @@ Compile():
but with 'memory' in the sense described above. but with 'memory' in the sense described above.
""" """
import __future__ # import __future__
import warnings import warnings
_features = [getattr(__future__, fname) ## MPY: Future flags arent set on compiled code so just remove the checks
for fname in __future__.all_feature_names] # _features = [getattr(__future__, fname)
# for fname in __future__.all_feature_names]
__all__ = ["compile_command", "Compile", "CommandCompiler"] __all__ = ["compile_command", "Compile", "CommandCompiler"]
@ -116,9 +117,10 @@ class Compile:
def __call__(self, source, filename, symbol): def __call__(self, source, filename, symbol):
codeob = compile(source, filename, symbol, self.flags, True) codeob = compile(source, filename, symbol, self.flags, True)
for feature in _features: ## MPY: Future flags arent set on compiled code so just remove the checks
if codeob.co_flags & feature.compiler_flag: # for feature in _features:
self.flags |= feature.compiler_flag # if codeob.co_flags & feature.compiler_flag:
# self.flags |= feature.compiler_flag
return codeob return codeob
class CommandCompiler: class CommandCompiler: