示例#1
0
def customize_for_version(self, is_pypy, version):
    if is_pypy:
        ########################
        # PyPy changes
        #######################
        TABLE_DIRECT.update({
            'assert_pypy': ('%|assert %c\n', 1),
            'assert2_pypy': ('%|assert %c, %c\n', 1, 4),
            'try_except_pypy': ('%|try:\n%+%c%-%c\n\n', 1, 2),
            'tryfinallystmt_pypy':
            ('%|try:\n%+%c%-%|finally:\n%+%c%-\n\n', 1, 3),
            'assign3_pypy': ('%|%c, %c, %c = %c, %c, %c\n', 5, 4, 3, 0, 1, 2),
            'assign2_pypy': ('%|%c, %c = %c, %c\n', 3, 2, 0, 1),
        })
    else:
        ########################
        # Without PyPy
        #######################
        TABLE_DIRECT.update({
            'assert': ('%|assert %c\n', 0),
            'assert2': ('%|assert %c, %c\n', 0, 3),
            'try_except': ('%|try:\n%+%c%-%c\n\n', 1, 3),
            'assign2': ('%|%c, %c = %c, %c\n', 3, 4, 0, 1),
            'assign3': ('%|%c, %c, %c = %c, %c, %c\n', 5, 6, 7, 0, 1, 2),
        })

    if version >= 3.2:
        TABLE_DIRECT.update({
            'del_deref_stmt': ('%|del %c\n', 0),
            'DELETE_DEREF': ('%{pattr}', 0),
        })
    from decompyle3.semantics.customize3 import customize_for_version3
    customize_for_version3(self, version)

    return
示例#2
0
def customize_for_version(self, is_pypy, version):
    if is_pypy:
        ########################
        # PyPy changes
        #######################
        TABLE_DIRECT.update({
            "assert_pypy": ("%|assert %c\n", 1),
            "assert2_pypy": ("%|assert %c, %c\n", 1, 4),
            "try_except_pypy": ("%|try:\n%+%c%-%c\n\n", 1, 2),
            "tryfinallystmt_pypy":
            ("%|try:\n%+%c%-%|finally:\n%+%c%-\n\n", 1, 3),
            "assign3_pypy": ("%|%c, %c, %c = %c, %c, %c\n", 5, 4, 3, 0, 1, 2),
            "assign2_pypy": ("%|%c, %c = %c, %c\n", 3, 2, 0, 1),
        })
    else:
        ########################
        # Without PyPy
        #######################
        TABLE_DIRECT.update({
            # "assert" and "assert_expr" are added via transform rules.
            "assert": ("%|assert %c\n", 0),
            "assert2": ("%|assert %c, %c\n", 0, 3),
            # Created only via transformation
            "assertnot": ("%|assert not %p\n", (0, PRECEDENCE["unary_not"])),
            "assert2not": (
                "%|assert not %p, %c\n",
                (0, PRECEDENCE["unary_not"]),
                3,
            ),
            "assign2": ("%|%c, %c = %c, %c\n", 3, 4, 0, 1),
            "assign3": ("%|%c, %c, %c = %c, %c, %c\n", 5, 6, 7, 0, 1, 2),
            "try_except": ("%|try:\n%+%c%-%c\n\n", 1, 3),
        })

    if version >= 3.2:
        TABLE_DIRECT.update({
            "del_deref_stmt": ("%|del %c\n", 0),
            "DELETE_DEREF": ("%{pattr}", 0),
        })
    from decompyle3.semantics.customize3 import customize_for_version3

    customize_for_version3(self, version)

    return