def execute_code_work_item(self):
_debug_write('Executing: ' + repr(self.current_code))
stripped_code = self.current_code.strip()
if stripped_code:
if sys.platform == 'cli':
code_to_send = ''
for line in stripped_code.split('\n'):
stripped = line.strip()
if (stripped.startswith('#') or not stripped) and not code_to_send:
continue
code_to_send += line + '\n'
code = python_context.CreateSnippet(code_to_send, None, SourceCodeKind.InteractiveCode)
dispatcher = clr.GetCurrentRuntime().GetLanguage(PythonContext).GetCommandDispatcher()
if dispatcher is not None:
dispatcher(self.python_executor(code))
else:
code.Execute(self.exec_mod)
else:
code = compile(self.current_code, '<stdin>', 'single', self.code_flags)
self.code_flags |= (code.co_flags & BasicReplBackend.future_bits)
exec(code, self.exec_mod.__dict__, self.exec_mod.__dict__)
self.current_code = None
评论列表
文章目录