зеркало из https://github.com/github/ruby.git
[rubygems/rubygems] Clear `YAML` constant if it was undefined previously
https://github.com/rubygems/rubygems/commit/31d0311258
This commit is contained in:
Родитель
84b5274143
Коммит
419fbc77e0
|
@ -1301,6 +1301,8 @@ class Gem::Specification < Gem::BasicSpecification
|
|||
def self._load(str)
|
||||
Gem.load_yaml
|
||||
|
||||
yaml_set = false
|
||||
|
||||
array = begin
|
||||
Marshal.load str
|
||||
rescue ArgumentError => e
|
||||
|
@ -1313,7 +1315,10 @@ class Gem::Specification < Gem::BasicSpecification
|
|||
message = e.message
|
||||
raise unless message.include?("YAML::")
|
||||
|
||||
Object.const_set "YAML", Psych unless Object.const_defined?(:YAML)
|
||||
unless Object.const_defined?(:YAML)
|
||||
Object.const_set "YAML", Psych
|
||||
yaml_set = true
|
||||
end
|
||||
|
||||
if message.include?("YAML::Syck::")
|
||||
YAML.const_set "Syck", YAML unless YAML.const_defined?(:Syck)
|
||||
|
@ -1324,6 +1329,8 @@ class Gem::Specification < Gem::BasicSpecification
|
|||
end
|
||||
|
||||
retry
|
||||
ensure
|
||||
Object.__send__(:remove_const, "YAML") if yaml_set
|
||||
end
|
||||
|
||||
spec = Gem::Specification.new
|
||||
|
|
|
@ -1071,19 +1071,27 @@ dependencies: []
|
|||
end
|
||||
|
||||
def test_handles_private_null_type
|
||||
yaml_defined = Object.const_defined?("YAML")
|
||||
|
||||
path = File.expand_path "data/pry-0.4.7.gemspec.rz", __dir__
|
||||
|
||||
data = Marshal.load Gem::Util.inflate(Gem.read_binary(path))
|
||||
|
||||
assert_instance_of Gem::Specification, data
|
||||
|
||||
assert_equal(yaml_defined, Object.const_defined?("YAML"))
|
||||
end
|
||||
|
||||
def test_handles_dependencies_with_syck_requirements_bug
|
||||
yaml_defined = Object.const_defined?("YAML")
|
||||
|
||||
path = File.expand_path "data/excon-0.7.7.gemspec.rz", __dir__
|
||||
|
||||
data = Marshal.load Gem::Util.inflate(Gem.read_binary(path))
|
||||
|
||||
assert_instance_of Gem::Specification, data
|
||||
|
||||
assert_equal(yaml_defined, Object.const_defined?("YAML"))
|
||||
end
|
||||
|
||||
def test_initialize
|
||||
|
|
Загрузка…
Ссылка в новой задаче