Exemplo n.º 1
0
def test_simple_exec():
    result = get_restart_pycode('import sys', cmd='exec')
    disassembly_test(result, """\
  1           0 LOAD_CONST               0 (-1)
              3 LOAD_CONST               1 (None)
              6 IMPORT_NAME              0 (sys)
              9 STORE_NAME               0 (sys)
             12 LOAD_CONST               1 (None)
             15 RETURN_VALUE
""")
Exemplo n.º 2
0
    def restart_specific_frame(space, args_w):
        frame_w = args_w[0]
        source_w = args_w[1]
        filename_w = args_w[2]
        cmd_w = args_w[3]

        if not (isinstance(frame_w, W_PythonObject) and
                isinstance(source_w, W_BytesObject) and
                isinstance(filename_w, W_BytesObject) and
                isinstance(cmd_w, W_BytesObject)):
            return False
        frame = frame_w.wp_object
        source = space.unwrap_string(source_w)
        filename = space.unwrap_string(filename_w)
        cmd = space.unwrap_string(cmd_w)

        py_code = None
        if source:
            py_code = utils.get_restart_pycode(source, filename, cmd)
            if py_code is None:
                return False
        PythonPlugin.set_py_frame_restart_info(frame, py_code)
        return True
Exemplo n.º 3
0
def test_invalid_exec():
    result = get_restart_pycode('in valid syntax')
    assert result is None
Exemplo n.º 4
0
def test_invalid_eval():
    result = get_restart_pycode('import os', cmd='eval')
    assert result is None
Exemplo n.º 5
0
def test_nested_exec():
    result = get_restart_pycode('def func():\n  return 42', cmd='exec')
    disassembly_test(result, """\
  2           0 LOAD_CONST               1 (42)
              3 RETURN_VALUE
""")
Exemplo n.º 6
0
def test_simple_eval():
    result = get_restart_pycode('1', cmd='eval')
    disassembly_test(result, """\
  1           0 LOAD_CONST               0 (1)
              3 RETURN_VALUE
""")