From 1b538ff559d3fc847d2949dd8899c1b1d3c6909a Mon Sep 17 00:00:00 2001 From: Benoit Daloze Date: Tue, 28 Nov 2023 13:36:50 +0100 Subject: [PATCH] Check if RubyVM is defined before accessing it --- lib/debug/session.rb | 4 ++-- lib/debug/source_repository.rb | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/debug/session.rb b/lib/debug/session.rb index 3db2f45da..0a3174473 100644 --- a/lib/debug/session.rb +++ b/lib/debug/session.rb @@ -82,7 +82,7 @@ def last_line def first_line self.to_a[4][:code_location][0] end unless method_defined?(:first_line) -end +end if defined?(RubyVM::InstructionSequence) module DEBUGGER__ PresetCommands = Struct.new(:commands, :source, :auto_continue) @@ -133,7 +133,7 @@ def initialize @commands = {} @unsafe_context = false - @has_keep_script_lines = RubyVM.respond_to? :keep_script_lines + @has_keep_script_lines = defined?(RubyVM.keep_script_lines) @tp_load_script = TracePoint.new(:script_compiled){|tp| eval_script = tp.eval_script unless @has_keep_script_lines diff --git a/lib/debug/source_repository.rb b/lib/debug/source_repository.rb index ddcfd6e93..52e43cf7d 100644 --- a/lib/debug/source_repository.rb +++ b/lib/debug/source_repository.rb @@ -22,7 +22,7 @@ def get iseq end end - if RubyVM.respond_to? :keep_script_lines + if defined?(RubyVM.keep_script_lines) # Ruby 3.1 and later RubyVM.keep_script_lines = true require 'objspace'