Python dis.show_code() Examples
The following are 6
code examples of dis.show_code().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
dis
, or try the search function
.
Example #1
Source File: snippet.py From YAPyPy with MIT License | 6 votes |
def case(code, ctx, debug=False, cpython_compat=True): stmt = parse(code).result code_obj = py_compile(stmt, is_entrypoint=False) if debug: with open('out_yapypy_bc.log', 'w') as yapypy_bc, open('out_yapypy_info.log', 'w') as yapypy_info: dis_code(code_obj, yapypy_bc) show_code(code_obj, yapypy_info) if cpython_compat: code_obj2 = compile(code, "", "exec") with open('out_cpy_bc.log', 'w') as cpy_bc, open('out_cpy_info.log', 'w') as cpy_info: dis_code(code_obj2, cpy_bc) show_code(code_obj2, cpy_info) print('python:') exec(Bytecode.from_code(code_obj2).to_code(), ctx or {}) print('yapypy') exec(Bytecode.from_code(code_obj).to_code(), ctx or {}) else: exec(code_obj, ctx)
Example #2
Source File: snippet.py From YAPyPy with MIT License | 5 votes |
def show_code(code: types.CodeType, f, contains=()): if code in contains: return f.write('\n\n\n') f.write(code.co_name) f.write(':\n\n') dis.show_code(code, file=f) for each in code.co_consts: if isinstance(each, types.CodeType): show_code(each, f, (*contains, code))
Example #3
Source File: test_dis.py From Fluid-Designer with GNU General Public License v3.0 | 5 votes |
def test_show_code(self): self.maxDiff = 1000 for x, expected in self.test_pairs: with captured_stdout() as output: dis.show_code(x) self.assertRegex(output.getvalue(), expected+"\n") output = io.StringIO() dis.show_code(x, file=output) self.assertRegex(output.getvalue(), expected)
Example #4
Source File: test_dis.py From ironpython3 with Apache License 2.0 | 5 votes |
def test_show_code(self): self.maxDiff = 1000 for x, expected in self.test_pairs: with captured_stdout() as output: dis.show_code(x) self.assertRegex(output.getvalue(), expected+"\n") output = io.StringIO() dis.show_code(x, file=output) self.assertRegex(output.getvalue(), expected)
Example #5
Source File: test_dis.py From Project-New-Reign---Nemesis-Main with GNU General Public License v3.0 | 5 votes |
def test_show_code(self): self.maxDiff = 1000 for x, expected in self.test_pairs: with captured_stdout() as output: dis.show_code(x) self.assertRegex(output.getvalue(), expected+"\n") output = io.StringIO() dis.show_code(x, file=output) self.assertRegex(output.getvalue(), expected)
Example #6
Source File: test_dis.py From android_universal with MIT License | 5 votes |
def test_show_code(self): self.maxDiff = 1000 for x, expected in self.test_pairs: with captured_stdout() as output: dis.show_code(x) self.assertRegex(output.getvalue(), expected+"\n") output = io.StringIO() dis.show_code(x, file=output) self.assertRegex(output.getvalue(), expected)