Every line of 'compile python' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your Python code is secure.
22 def compile(source_path, compiler_id, exec_path): #print("[log] compile:") 23 #print(COMPILER_LIST[compiler_id]) 24 #print(source_path) 25 #print(COMPILER_OPTION_LIST[compiler_id]) 26 proc = subprocess.Popen([COMPILER_LIST[compiler_id], 27 source_path, 28 *COMPILER_OPTION_LIST[compiler_id]], 29 cwd = exec_path, 30 stdout = subprocess.PIPE, 31 stderr = subprocess.PIPE) 32 try: 33 outs, err = proc.communicate(timeout = COMPILE_TIME_LIMIT) 34 returncode = proc.returncode 35 except: 36 proc.kill() 37 out, err = proc.communicate() 38 returncode = proc.returncode 39 return (returncode, exec_path + "/a.out", err.decode('utf-8'))
Secure your code as it's written. Use Snyk Code to scan source code in minutes – no build needed – and fix issues immediately. Enable Snyk Code
51 def _exec_code(self, code): 52 if code: 53 code = compile(code, str(self.filename), 'exec', dont_inherit=True) 54 exec(code, vars(self.namespace))
113 def compile(self, display=0): 114 tree = self._get_tree() 115 gen = ModuleCodeGenerator(tree) 116 if display: 117 import pprint 118 print(pprint.pprint(tree)) 119 self.code = gen.getCode()
56 def get_code(module): 57 """ 58 Compile and return a Module's code object. 59 """ 60 fp = open(module.path, 'rb') 61 try: 62 return compile(fp.read(), str(module.name), 'exec') 63 finally: 64 fp.close()