зеркало из https://github.com/github/ruby.git
[ruby/irb] Avoid loading files' local variables [Bug #17623]
https://github.com/ruby/irb/commit/b12f0cb8e2
This commit is contained in:
Родитель
192147afd8
Коммит
3503c94af5
|
@ -57,6 +57,8 @@ EOF
|
|||
__FILE__,
|
||||
__LINE__ - 3)
|
||||
when 4 # binding is a copy of TOPLEVEL_BINDING (default)
|
||||
# Note that this will typically be IRB::TOPLEVEL_BINDING (see exe/irb)
|
||||
# This is to avoid RubyGems' local variables (see issue #17623)
|
||||
@binding = TOPLEVEL_BINDING.dup
|
||||
end
|
||||
end
|
||||
|
|
|
@ -8,4 +8,5 @@
|
|||
|
||||
require "irb"
|
||||
|
||||
IRB::TOPLEVEL_BINDING = binding
|
||||
IRB.start(__FILE__)
|
||||
|
|
|
@ -80,6 +80,16 @@ module TestIRB
|
|||
assert_equal(nil, workspace.code_around_binding)
|
||||
end
|
||||
|
||||
|
||||
def test_toplevel_binding_local_variables
|
||||
bug17623 = '[ruby-core:102468]'
|
||||
bundle_exec = ENV.key?('BUNDLE_GEMFILE') ? ['-rbundler/setup'] : []
|
||||
status = assert_in_out_err(bundle_exec + ['-W0', '-e', <<~RUBY , '--', '-f', '--'], 'binding.local_variables', /\[:_\]/, [], bug17623)
|
||||
version = 'xyz' # typical rubygems loading file
|
||||
load('./exe/irb')
|
||||
RUBY
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def with_script_lines
|
||||
|
|
Загрузка…
Ссылка в новой задаче