How to use the xdis.std function in xdis

To help you get started, we’ve selected a few xdis examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github rocky / python-xdis / test_unit / test_dis34.py View on Github external
def get_disassembly(self, func, lasti=-1, wrapper=True):
            output = io.StringIO()
            if wrapper:
                dis.dis(func, file=output)
            else:
                dis.disassemble(func, lasti, file=output)
            return output.getvalue()
github rocky / python-xdis / test_unit / test_dis33.py View on Github external
def test_boundaries(self):
            self.assertEqual(dis.opmap["EXTENDED_ARG"], dis.EXTENDED_ARG)
            self.assertEqual(dis.opmap["STORE_NAME"], dis.HAVE_ARGUMENT)
github rocky / python-xdis / pytest / test_std.py View on Github external
def test_make_std_api():
        api24_tup = dis.make_std_api((2, 4, 6, 'final', 0))
        api24_float = dis.make_std_api(2.4)
        assert api24_tup.opmap == api24_float.opmap, \
            "Can get std_api using a floating-point number"
github rocky / python-xdis / test_unit / test_dis33.py View on Github external
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")
github rocky / python-xdis / pytest / test_std.py View on Github external
def bytecode_fixture():
        return dis.Bytecode(TEST_SOURCE_CODE)
github rocky / python-xdis / test_unit / test_dis27.py View on Github external
def test_boundaries(self):
            opmap = dis.opmap
            self.assertEqual(opmap["EXTENDED_ARG"], dis.EXTENDED_ARG)
            self.assertEqual(opmap["STORE_NAME"], dis.HAVE_ARGUMENT)
github rocky / python-xdis / test_unit / test_dis33.py View on Github external
def test_pretty_flags_no_flags(self):
            self.assertEqual(dis.pretty_flags(0), '0x00000000 (0x0)')
github rocky / python-xdis / test_unit / test_dis34.py View on Github external
def test_opname(self):
            self.assertEqual(dis.opname[dis.opmap["LOAD_FAST"]], "LOAD_FAST")
github rocky / python-xdis / test_unit / test_dis24.py View on Github external
def test_opname(self):
        self.assertEqual(dis.opname[dis.opmap["LOAD_FAST"]], "LOAD_FAST")
github rocky / python-uncompyle6 / uncompyle6 / verify.py View on Github external
JUMP_OPS = list(scan.JUMP_OPS) + ['JUMP_BACK']

            # use changed Token class
            # We (re)set this here to save exception handling,
            # which would get confusing.
            scanner.setTokenClass(Token)
            try:
                # ingest both code-objects
                tokens1, customize = scanner.ingest(code_obj1)
                del customize # save memory
                tokens2, customize = scanner.ingest(code_obj2)
                del customize # save memory
            finally:
                scanner.resetTokenClass() # restore Token class

            targets1 = dis.findlabels(code_obj1.co_code)
            tokens1 = [t for t in tokens1 if t.kind != 'COME_FROM']
            tokens2 = [t for t in tokens2 if t.kind != 'COME_FROM']

            i1 = 0; i2 = 0
            offset_map = {}; check_jumps = {}
            while i1 < len(tokens1):
                if i2 >= len(tokens2):
                    if len(tokens1) == len(tokens2) + 2 \
                          and tokens1[-1].kind == 'RETURN_VALUE' \
                          and tokens1[-2].kind == 'LOAD_CONST' \
                          and tokens1[-2].pattr is None \
                          and tokens1[-3].kind == 'RETURN_VALUE':
                        break
                    else:
                        raise CmpErrorCodeLen(name, tokens1, tokens2)