Beispiel #1
0
 def run_exit_handlers(self):
     while self.exit_handlers_w:
         w_proc = self.exit_handlers_w.pop()
         try:
             self.send(w_proc, self.newsymbol("call"))
         except RubyError as e:
             print_traceback(self, e.w_value)
Beispiel #2
0
 def run_exit_handlers(self):
     status = -1
     while self.exit_handlers_w:
         w_proc = self.exit_handlers_w.pop()
         try:
             self.send(w_proc, self.newsymbol("call"))
         except RubyError as e:
             w_exc = e.w_value
             if isinstance(w_exc, W_SystemExit):
                 status = w_exc.status
             else:
                 print_traceback(self, e.w_value)
     return status
Beispiel #3
0
 def run_exit_handlers(self):
     status = -1
     while self.exit_handlers_w:
         w_proc = self.exit_handlers_w.pop()
         try:
             self.send(w_proc, "call")
         except RubyError as e:
             w_exc = e.w_value
             if isinstance(w_exc, W_SystemExit):
                 status = w_exc.status
             else:
                 print_traceback(self, e.w_value)
     return status
Beispiel #4
0
 def send(self):
     st_to_rb = utils.smalltalk_to_ruby
     wr_rcvr = st_to_rb(self.space(), self.w_rcvr)
     args_rw = [st_to_rb(self.space(), w_arg) for w_arg in self.args_w]
     try:
         wr_result = ruby_space.send(
             wr_rcvr, self.method_name, args_w=args_rw)
         self.set_result(W_RubyObject(wr_result))
     except RubyError as e:
         print_traceback(ruby_space, e.w_value)
         error = W_RubyObject(e.w_value)
         self.set_error(error)
         self.set_result(error)
     except Exception as e:
         # import pdb; pdb.set_trace()
         self.fail(
             'No result in send prim (wr_rcvr: %s, methodname: %s, "%s")'
             % (wr_rcvr, self.method_name, e))
Beispiel #5
0
 def send(self):
     st_to_rb = utils.smalltalk_to_ruby
     wr_rcvr = st_to_rb(self.space(), self.w_rcvr)
     args_rw = [st_to_rb(self.space(), w_arg) for w_arg in self.args_w]
     try:
         wr_result = ruby_space.send(wr_rcvr,
                                     self.method_name,
                                     args_w=args_rw)
         self.set_result(W_RubyObject(wr_result))
     except RubyError as e:
         print_traceback(ruby_space, e.w_value)
         error = W_RubyObject(e.w_value)
         self.set_error(error)
         self.set_result(error)
     except Exception as e:
         # import pdb; pdb.set_trace()
         self.fail(
             'No result in send prim (wr_rcvr: %s, methodname: %s, "%s")' %
             (wr_rcvr, self.method_name, e))
Beispiel #6
0
def send(interp, s_frame, argcount, w_method):
    args_w = s_frame.peek_n(argcount)
    w_literal2 = w_method.literalat0(interp.space, 2)
    methodname = ""
    if isinstance(w_literal2, W_BytesObject):
        wr_rcvr = unwrap(interp, s_frame.peek(argcount))
        methodname = interp.space.unwrap_string(w_literal2)
    elif argcount == 3:
        methodname = interp.space.unwrap_string(args_w[0])
        wr_rcvr = unwrap(interp, args_w[1])
        args_w = interp.space.unwrap_array(args_w[2])
    else:
        raise PrimitiveFailedError
    idx = methodname.find(":")
    if idx > 0:
        methodname = methodname[0:idx]
    args_rw = [unwrap(interp, w_arg) for w_arg in args_w]
    try:
        return wrap(interp, ruby_space.send(wr_rcvr, methodname, args_w=args_rw))
    except RubyError as e:
        print_traceback(ruby_space, e.w_value)
        raise PrimitiveFailedError
Beispiel #7
0
def _entry_point(space, argv):
    system, _, _, _, cpu = os.uname()
    platform = "%s-%s" % (cpu, system.lower())
    engine = "topaz"
    version = "1.9.3"
    patchlevel = 125
    description = "%s (ruby-%sp%d) [%s]" % (engine, version, patchlevel, platform)
    space.set_const(space.w_object, "RUBY_ENGINE", space.newstr_fromstr(engine))
    space.set_const(space.w_object, "RUBY_VERSION", space.newstr_fromstr(version))
    space.set_const(space.w_object, "RUBY_PATCHLEVEL", space.newint(patchlevel))
    space.set_const(space.w_object, "RUBY_PLATFORM", space.newstr_fromstr(platform))
    space.set_const(space.w_object, "RUBY_DESCRIPTION", space.newstr_fromstr(description))

    try:
        (
            flag_globals_w,
            do_loop,
            path,
            search_path,
            globalized_switches,
            exprs,
            reqs,
            load_path_entries,
            argv_w
        ) = _parse_argv(space, argv)
    except ShortCircuitError as e:
        os.write(1, e.message)
        return 0
    except CommandLineError as e:
        os.write(2, e.message)
        return 1

    for path_entry in load_path_entries:
        space.send(
            space.w_load_path,
            space.newsymbol("<<"),
            [space.newstr_fromstr(path_entry)]
        )
    for required_lib in reqs:
        space.send(
            space.w_kernel,
            space.newsymbol("require"),
            [space.newstr_fromstr(required_lib)]
        )

    space.set_const(space.w_object, "ARGV", space.newarray(argv_w))
    explicitly_verbose = space.is_true(flag_globals_w["$-v"])
    if explicitly_verbose:
        os.write(1, "%s\n" % description)
    for varname, w_value in flag_globals_w.iteritems():
        space.globals.set(space, varname, w_value)

    if exprs:
        source = "\n".join(exprs)
        path = "-e"
    elif path is not None:
        if search_path:
            for dirname in os.environ["PATH"].split(os.pathsep):
                candidate_path = os.sep.join([dirname, path])
                if os.access(candidate_path, os.R_OK):
                    path = candidate_path
                    break
        try:
            f = open_file_as_stream(path)
        except OSError as e:
            os.write(2, "%s -- %s (LoadError)\n" % (os.strerror(e.errno), path))
            return 1
        try:
            source = f.readall()
        finally:
            f.close()
    elif explicitly_verbose:
        return 0
    else:
        source = fdopen_as_stream(0, "r").readall()
        path = "-"

    for globalized_switch in globalized_switches:
        value = None
        if "=" in globalized_switch:
            globalized_switch, value = globalized_switch.split("=", 1)

        switch_global_var = "$%s" % globalized_switch[1:].replace("-", "_")
        if value is None:
            space.globals.set(space, switch_global_var, space.w_true)
        else:
            space.globals.set(space, switch_global_var, space.newstr_fromstr(value))

    w_program_name = space.newstr_fromstr(path)
    space.globals.set(space, "$0", w_program_name)
    space.globals.set(space, "$PROGRAM_NAME", w_program_name)
    status = 0
    w_exit_error = None
    explicit_status = False
    try:
        if do_loop:
            bc = space.compile(source, path)
            frame = space.create_frame(bc)
            while True:
                w_line = space.send(space.w_kernel, space.newsymbol("gets"))
                if w_line is space.w_nil:
                    break
                with space.getexecutioncontext().visit_frame(frame):
                    space.execute_frame(frame, bc)
        else:
            space.execute(source, filepath=path)
    except RubyError as e:
        explicit_status = True
        w_exc = e.w_value
        if isinstance(w_exc, W_SystemExit):
            status = w_exc.status
        else:
            w_exit_error = w_exc
            status = 1
    exit_handler_status = space.run_exit_handlers()
    if not explicit_status and exit_handler_status != -1:
        status = exit_handler_status
    if w_exit_error is not None:
        print_traceback(space, w_exit_error, path)

    return status
Beispiel #8
0
def _entry_point(space, argv):
    if IS_WINDOWS:
        system = "Windows"
        cpu = "x86_64" if IS_64BIT else "i686"
    else:
        system, _, _, _, cpu = os.uname()
    platform = "%s-%s" % (cpu, system.lower())
    engine = "topaz"
    version = "1.9.3"
    patchlevel = 125
    description = "%s (ruby-%sp%d) (git rev %s) [%s]" % (
        engine, version, patchlevel, RUBY_REVISION, platform)
    space.set_const(space.w_object, "RUBY_ENGINE",
                    space.newstr_fromstr(engine))
    space.set_const(space.w_object, "RUBY_VERSION",
                    space.newstr_fromstr(version))
    space.set_const(space.w_object, "RUBY_PATCHLEVEL",
                    space.newint(patchlevel))
    space.set_const(space.w_object, "RUBY_PLATFORM",
                    space.newstr_fromstr(platform))
    space.set_const(space.w_object, "RUBY_DESCRIPTION",
                    space.newstr_fromstr(description))
    space.set_const(space.w_object, "RUBY_REVISION",
                    space.newstr_fromstr(RUBY_REVISION))

    try:
        (flag_globals_w, do_loop, path, search_path, globalized_switches,
         exprs, reqs, load_path_entries, argv_w) = _parse_argv(space, argv)
    except ShortCircuitError as e:
        os.write(1, e.message)
        return 0
    except CommandLineError as e:
        os.write(2, e.message)
        return 1

    for path_entry in load_path_entries:
        space.send(space.w_load_path, "<<", [space.newstr_fromstr(path_entry)])
    for required_lib in reqs:
        space.send(space.w_kernel, "require",
                   [space.newstr_fromstr(required_lib)])

    space.set_const(space.w_object, "ARGV", space.newarray(argv_w))
    explicitly_verbose = space.is_true(flag_globals_w["$-v"])
    if explicitly_verbose:
        os.write(1, "%s\n" % description)
    for varname, w_value in flag_globals_w.iteritems():
        space.globals.set(space, varname, w_value)

    if exprs:
        source = "\n".join(exprs)
        path = "-e"
    elif path is not None:
        if search_path:
            for dirname in os.environ["PATH"].split(os.pathsep):
                candidate_path = os.sep.join([dirname, path])
                if os.access(candidate_path, os.R_OK):
                    path = candidate_path
                    break
        try:
            f = open_file_as_stream(path, buffering=0)
        except OSError as e:
            os.write(2,
                     "%s -- %s (LoadError)\n" % (os.strerror(e.errno), path))
            return 1
        try:
            source = f.readall()
        finally:
            f.close()
    elif explicitly_verbose:
        return 0
    else:
        if IS_WINDOWS:
            raise NotImplementedError("executing from stdin on Windows")
        else:
            source = fdopen_as_stream(0, "r").readall()
            path = "-"

    for globalized_switch in globalized_switches:
        value = None
        if "=" in globalized_switch:
            globalized_switch, value = globalized_switch.split("=", 1)

        switch_global_var = "$%s" % globalized_switch[1:].replace("-", "_")
        if value is None:
            space.globals.set(space, switch_global_var, space.w_true)
        else:
            space.globals.set(space, switch_global_var,
                              space.newstr_fromstr(value))

    w_program_name = space.newstr_fromstr(path)
    space.globals.set(space, "$0", w_program_name)
    space.globals.set(space, "$PROGRAM_NAME", w_program_name)
    status = 0
    w_exit_error = None
    explicit_status = False
    jit.set_param(None, "trace_limit", 10000)
    try:
        if do_loop:
            print_after = space.is_true(flag_globals_w["$-p"])
            bc = space.compile(source, path)
            frame = space.create_frame(bc)
            while True:
                w_line = space.send(space.w_kernel, "gets")
                if w_line is space.w_nil:
                    break
                with space.getexecutioncontext().visit_frame(frame):
                    w_res = space.execute_frame(frame, bc)
                    if print_after:
                        space.send(space.w_kernel, "print", [w_res])
        else:
            space.execute(source, filepath=path)
    except RubyError as e:
        explicit_status = True
        w_exc = e.w_value
        if isinstance(w_exc, W_SystemExit):
            status = w_exc.status
        else:
            w_exit_error = w_exc
            status = 1
    exit_handler_status = space.run_exit_handlers()
    if not explicit_status and exit_handler_status != -1:
        status = exit_handler_status
    if w_exit_error is not None:
        print_traceback(space, w_exit_error, path)

    return status
Beispiel #9
0
def _entry_point(space, argv):
    verbose = False
    path = None
    exprs = []
    idx = 1
    while idx < len(argv):
        arg = argv[idx]
        if arg == "-v":
            verbose = True
        elif arg == "-e":
            idx += 1
            exprs.append(argv[idx])
        else:
            break
        idx += 1
    if idx < len(argv) and not exprs:
        path = argv[idx]
        idx += 1
    argv_w = []
    while idx < len(argv):
        argv_w.append(space.newstr_fromstr(argv[idx]))
        idx += 1
    space.set_const(space.w_object, "ARGV", space.newarray(argv_w))

    system, _, _, _, cpu = os.uname()
    platform = "%s-%s" % (cpu, system.lower())
    engine = "topaz"
    version = "1.9.3"
    patchlevel = 125
    description = "%s (ruby-%sp%d) [%s]" % (engine, version, patchlevel, platform)
    space.set_const(space.w_object, "RUBY_ENGINE", space.newstr_fromstr(engine))
    space.set_const(space.w_object, "RUBY_VERSION", space.newstr_fromstr(version))
    space.set_const(space.w_object, "RUBY_PATCHLEVEL", space.newint(patchlevel))
    space.set_const(space.w_object, "RUBY_PLATFORM", space.newstr_fromstr(platform))
    space.set_const(space.w_object, "RUBY_DESCRIPTION", space.newstr_fromstr(description))

    if verbose:
        os.write(1, "%s\n" % description)

    if exprs:
        source = "\n".join(exprs)
        path = "-e"
    elif path is not None:
        try:
            f = open_file_as_stream(path)
        except OSError as e:
            os.write(2, "%s -- %s (LoadError)\n" % (os.strerror(e.errno), path))
            return 1
        try:
            source = f.readall()
        finally:
            f.close()
    elif verbose:
        return 0
    else:
        raise NotImplementedError("reading script from stdin")

    space.globals.set(space, "$0", space.newstr_fromstr(path))
    status = 0
    w_exit_error = None
    try:
        space.execute(source, filepath=path)
    except RubyError as e:
        w_exc = e.w_value
        if isinstance(w_exc, W_SystemExit):
            status = w_exc.status
        else:
            w_exit_error = w_exc
            status = 1
    space.run_exit_handlers()
    if w_exit_error is not None:
        print_traceback(space, w_exit_error, path)

    return status
Beispiel #10
0
def _entry_point(space, argv):
    try:
        (
            flag_globals_w,
            do_loop,
            path,
            search_path,
            globalized_switches,
            exprs,
            reqs,
            load_path_entries,
            jit_params,
            syntax_check,
            argv_w
        ) = _parse_argv(space, argv)
    except ShortCircuitError as e:
        os.write(1, e.message)
        return 0
    except CommandLineError as e:
        os.write(2, e.message)
        return 1

    for path_entry in load_path_entries:
        space.send(
            space.w_load_path,
            "<<",
            [space.newstr_fromstr(path_entry)]
        )
    for required_lib in reqs:
        space.send(
            space.w_kernel,
            "require",
            [space.newstr_fromstr(required_lib)]
        )

    space.set_const(space.w_object, "ARGV", space.newarray(argv_w))
    explicitly_verbose = space.is_true(flag_globals_w["$-v"])
    if explicitly_verbose:
        os.write(1, "%s\n" % RUBY_DESCRIPTION)
    for varname, w_value in flag_globals_w.iteritems():
        space.globals.set(space, varname, w_value)

    if exprs:
        source = "\n".join(exprs)
        path = "-e"
    elif path is not None:
        if search_path:
            for dirname in os.environ["PATH"].split(os.pathsep):
                candidate_path = os.sep.join([dirname, path])
                if os.access(candidate_path, os.R_OK):
                    path = candidate_path
                    break
        try:
            f = open_file_as_stream(path, buffering=0)
        except OSError as e:
            os.write(2, "%s -- %s (LoadError)\n" % (os.strerror(e.errno), path))
            return 1
        try:
            source = f.readall()
        finally:
            f.close()
    elif explicitly_verbose:
        return 0
    else:
        if IS_WINDOWS:
            source = WinStdinStream().readall()
        else:
            source = fdopen_as_stream(0, "r").readall()
        path = "-"

    for globalized_switch in globalized_switches:
        value = None
        if "=" in globalized_switch:
            globalized_switch, value = globalized_switch.split("=", 1)

        switch_global_var = "$%s" % globalized_switch[1:].replace("-", "_")
        if value is None:
            space.globals.set(space, switch_global_var, space.w_true)
        else:
            space.globals.set(space, switch_global_var, space.newstr_fromstr(value))

    w_program_name = space.newstr_fromstr(path)
    space.globals.set(space, "$0", w_program_name)
    space.globals.set(space, "$PROGRAM_NAME", w_program_name)
    status = 0
    w_exit_error = None
    explicit_status = False
    jit.set_param(None, "trace_limit", 16000)
    if jit_params:
        # Work around TraceLimitTooHigh by setting any trace_limit explicitly
        parts = jit_params.split(",")
        limitidx = -1
        for i, s in enumerate(parts):
            if "trace_limit" in s:
                limitidx = i
                break
        if limitidx >= 0:
            limit = parts.pop(limitidx)
            jit.set_param(None, "trace_limit", int(limit.split("=")[1]))
        if len(parts) > 0:
            jit.set_user_param(None, ",".join(parts))
    try:
        if do_loop:
            print_after = space.is_true(flag_globals_w["$-p"])
            bc = space.compile(source, path)
            frame = space.create_frame(bc)
            while True:
                w_line = space.send(space.w_kernel, "gets")
                if w_line is space.w_nil:
                    break
                with space.getexecutioncontext().visit_frame(frame):
                    w_res = space.execute_frame(frame, bc)
                    if print_after:
                        space.send(space.w_kernel, "print", [w_res])
        elif syntax_check:
            space.compile(source, path)
        else:
            space.execute(source, filepath=path)
    except RubyError as e:
        explicit_status = True
        w_exc = e.w_value
        if isinstance(w_exc, W_SystemExit):
            status = w_exc.status
        else:
            w_exit_error = w_exc
            status = 1
    exit_handler_status = space.run_exit_handlers()
    if not explicit_status and exit_handler_status != -1:
        status = exit_handler_status
    if w_exit_error is not None:
        print_traceback(space, w_exit_error, path)

    return status
Beispiel #11
0
def eval(interp, s_frame, w_rcvr, source):
    try:
        return wrap(interp, ruby_space.execute(source))
    except RubyError as e:
        print_traceback(ruby_space, e.w_value)
        raise PrimitiveFailedError
Beispiel #12
0
def _entry_point(space, argv):
    try:
        (
            flag_globals_w,
            do_loop,
            path,
            search_path,
            globalized_switches,
            exprs,
            reqs,
            load_path_entries,
            jit_params,
            syntax_check,
            argv_w
        ) = _parse_argv(space, argv)
    except ShortCircuitError as e:
        os.write(1, e.message)
        return 0
    except CommandLineError as e:
        os.write(2, e.message)
        return 1

    for path_entry in load_path_entries:
        space.send(
            space.w_load_path,
            "<<",
            [space.newstr_fromstr(path_entry)]
        )
    for required_lib in reqs:
        space.send(
            space.w_kernel,
            "require",
            [space.newstr_fromstr(required_lib)]
        )

    space.set_const(space.w_object, "ARGV", space.newarray(argv_w))
    explicitly_verbose = space.is_true(flag_globals_w["$-v"])
    if explicitly_verbose:
        os.write(1, "%s\n" % RUBY_DESCRIPTION)
    for varname, w_value in flag_globals_w.iteritems():
        space.globals.set(space, varname, w_value)

    if exprs:
        source = "\n".join(exprs)
        path = "-e"
    elif path is not None:
        if search_path:
            for dirname in os.environ["PATH"].split(os.pathsep):
                candidate_path = os.sep.join([dirname, path])
                if os.access(candidate_path, os.R_OK):
                    path = candidate_path
                    break
        try:
            f = open_file_as_stream(path, buffering=0)
        except OSError as e:
            os.write(2, "%s -- %s (LoadError)\n" % (os.strerror(e.errno), path))
            return 1
        try:
            source = f.readall()
        finally:
            f.close()
    elif explicitly_verbose:
        return 0
    else:
        if IS_WINDOWS:
            source = WinStdinStream().readall()
        else:
            source = fdopen_as_stream(0, "r").readall()
        path = "-"

    for globalized_switch in globalized_switches:
        value = None
        if "=" in globalized_switch:
            globalized_switch, value = globalized_switch.split("=", 1)

        switch_global_var = "$%s" % globalized_switch[1:].replace("-", "_")
        if value is None:
            space.globals.set(space, switch_global_var, space.w_true)
        else:
            space.globals.set(space, switch_global_var, space.newstr_fromstr(value))

    w_program_name = space.newstr_fromstr(path)
    space.globals.set(space, "$0", w_program_name)
    space.globals.set(space, "$PROGRAM_NAME", w_program_name)
    status = 0
    w_exit_error = None
    explicit_status = False
    jit.set_param(None, "trace_limit", 16000)
    if jit_params:
        # Work around TraceLimitTooHigh by setting any trace_limit explicitly
        parts = jit_params.split(",")
        limitidx = -1
        for i, s in enumerate(parts):
            if "trace_limit" in s:
                limitidx = i
                break
        if limitidx >= 0:
            limit = parts.pop(limitidx)
            jit.set_param(None, "trace_limit", int(limit.split("=")[1]))
        if len(parts) > 0:
            jit.set_user_param(None, ",".join(parts))
    try:
        if do_loop:
            print_after = space.is_true(flag_globals_w["$-p"])
            bc = space.compile(source, path)
            frame = space.create_frame(bc)
            while True:
                w_line = space.send(space.w_kernel, "gets")
                if w_line is space.w_nil:
                    break
                with space.getexecutioncontext().visit_frame(frame):
                    w_res = space.execute_frame(frame, bc)
                    if print_after:
                        space.send(space.w_kernel, "print", [w_res])
        elif syntax_check:
            space.compile(source, path)
        else:
            space.execute(source, filepath=path)
    except RubyError as e:
        explicit_status = True
        w_exc = e.w_value
        if isinstance(w_exc, W_SystemExit):
            status = w_exc.status
        else:
            w_exit_error = w_exc
            status = 1
    exit_handler_status = space.run_exit_handlers()
    if not explicit_status and exit_handler_status != -1:
        status = exit_handler_status
    if w_exit_error is not None:
        print_traceback(space, w_exit_error, path)

    return status
Beispiel #13
0
def _entry_point(space, argv):
    system, _, _, _, cpu = os.uname()
    platform = "%s-%s" % (cpu, system.lower())
    engine = "topaz"
    version = "1.9.3"
    patchlevel = 125
    description = "%s (ruby-%sp%d) [%s]" % (engine, version, patchlevel, platform)
    space.set_const(space.w_object, "RUBY_ENGINE", space.newstr_fromstr(engine))
    space.set_const(space.w_object, "RUBY_VERSION", space.newstr_fromstr(version))
    space.set_const(space.w_object, "RUBY_PATCHLEVEL", space.newint(patchlevel))
    space.set_const(space.w_object, "RUBY_PLATFORM", space.newstr_fromstr(platform))
    space.set_const(space.w_object, "RUBY_DESCRIPTION", space.newstr_fromstr(description))

    try:
        verbose, path, search_path, exprs, reqs, load_path_entries, argv_w = _parse_argv(space, argv)
    except ShortCircuitError as e:
        os.write(1, e.message)
        return 0
    except CommandLineError as e:
        os.write(2, e.message)
        return 1

    for path_entry in load_path_entries:
        space.send(
            space.w_load_path,
            space.newsymbol("<<"),
            [space.newstr_fromstr(path_entry)]
        )
    for required_lib in reqs:
        space.send(
            space.w_kernel,
            space.newsymbol("require"),
            [space.newstr_fromstr(required_lib)]
        )

    space.set_const(space.w_object, "ARGV", space.newarray(argv_w))

    if verbose:
        os.write(1, "%s\n" % description)

    if exprs:
        source = "\n".join(exprs)
        path = "-e"
    elif path is not None:
        if search_path:
            for dirname in os.environ["PATH"].split(os.pathsep):
                candidate_path = os.sep.join([dirname, path])
                if os.access(candidate_path, os.R_OK):
                    path = candidate_path
                    break
        try:
            f = open_file_as_stream(path)
        except OSError as e:
            os.write(2, "%s -- %s (LoadError)\n" % (os.strerror(e.errno), path))
            return 1
        try:
            source = f.readall()
        finally:
            f.close()
    elif verbose:
        return 0
    else:
        source = fdopen_as_stream(0, "r").readall()
        path = "-"

    space.globals.set(space, "$0", space.newstr_fromstr(path))
    status = 0
    w_exit_error = None
    try:
        space.execute(source, filepath=path)
    except RubyError as e:
        w_exc = e.w_value
        if isinstance(w_exc, W_SystemExit):
            status = w_exc.status
        else:
            w_exit_error = w_exc
            status = 1
    space.run_exit_handlers()
    if w_exit_error is not None:
        print_traceback(space, w_exit_error, path)

    return status