mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
[rubygems/rubygems] Remove syck
traces from bundler
Same reason as in the previous commit. https://github.com/rubygems/rubygems/commit/f00a6c8516
This commit is contained in:
parent
1e290c31f4
commit
4bc87cb1fb
Notes:
git
2021-08-31 19:06:52 +09:00
7 changed files with 3 additions and 74 deletions
|
@ -647,10 +647,8 @@ EOF
|
|||
def eval_yaml_gemspec(path, contents)
|
||||
require_relative "bundler/psyched_yaml"
|
||||
|
||||
# If the YAML is invalid, Syck raises an ArgumentError, and Psych
|
||||
# raises a Psych::SyntaxError. See psyched_yaml.rb for more info.
|
||||
Gem::Specification.from_yaml(contents)
|
||||
rescue YamlLibrarySyntaxError, ArgumentError, Gem::EndOfYAMLException, Gem::Exception
|
||||
rescue ::Psych::SyntaxError, ArgumentError, Gem::EndOfYAMLException, Gem::Exception
|
||||
eval_gemspec(path, contents)
|
||||
end
|
||||
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
module Bundler
|
||||
# used for Creating Specifications from the Gemcutter Endpoint
|
||||
class EndpointSpecification < Gem::Specification
|
||||
ILLFORMED_MESSAGE = 'Ill-formed requirement ["#<YAML::Syck::DefaultKey'.freeze
|
||||
include MatchPlatform
|
||||
|
||||
attr_reader :name, :version, :platform, :required_rubygems_version, :required_ruby_version, :checksum
|
||||
|
@ -129,13 +128,6 @@ module Bundler
|
|||
|
||||
def build_dependency(name, requirements)
|
||||
Gem::Dependency.new(name, requirements)
|
||||
rescue ArgumentError => e
|
||||
raise unless e.message.include?(ILLFORMED_MESSAGE)
|
||||
puts # we shouldn't print the error message on the "fetching info" status line
|
||||
raise GemspecError,
|
||||
"Unfortunately, the gem #{name} (#{version}) has an invalid " \
|
||||
"gemspec.\nPlease ask the gem author to yank the bad version to fix " \
|
||||
"this issue. For more information, see http://bit.ly/syck-defaultkey."
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,22 +1,10 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
# Psych could be in the stdlib
|
||||
# but it's too late if Syck is already loaded
|
||||
begin
|
||||
require "psych" unless defined?(Syck)
|
||||
require "psych"
|
||||
rescue LoadError
|
||||
# Apparently Psych wasn't available. Oh well.
|
||||
end
|
||||
|
||||
# At least load the YAML stdlib, whatever that may be
|
||||
require "yaml" unless defined?(YAML.dump)
|
||||
|
||||
module Bundler
|
||||
# On encountering invalid YAML,
|
||||
# Psych raises Psych::SyntaxError
|
||||
if defined?(::Psych::SyntaxError)
|
||||
YamlLibrarySyntaxError = ::Psych::SyntaxError
|
||||
else # Syck raises ArgumentError
|
||||
YamlLibrarySyntaxError = ::ArgumentError
|
||||
end
|
||||
end
|
||||
|
|
|
@ -119,7 +119,7 @@ module Bundler
|
|||
Bundler.ui.error "#{e.class}: #{e.message}"
|
||||
Bundler.ui.trace e
|
||||
raise
|
||||
rescue YamlLibrarySyntaxError => e
|
||||
rescue ::Psych::SyntaxError => e
|
||||
raise YamlSyntaxError.new(e, "Your RubyGems configuration, which is " \
|
||||
"usually located in ~/.gemrc, contains invalid YAML syntax.")
|
||||
end
|
||||
|
|
|
@ -21,30 +21,6 @@ RSpec.describe Bundler do
|
|||
it "catches YAML syntax errors" do
|
||||
expect { subject }.to raise_error(Bundler::GemspecError, /error while loading `test.gemspec`/)
|
||||
end
|
||||
|
||||
context "on Rubies with a settable YAML engine", :if => defined?(YAML::ENGINE) do
|
||||
context "with Syck as YAML::Engine" do
|
||||
it "raises a GemspecError after YAML load throws ArgumentError" do
|
||||
orig_yamler = YAML::ENGINE.yamler
|
||||
YAML::ENGINE.yamler = "syck"
|
||||
|
||||
expect { subject }.to raise_error(Bundler::GemspecError)
|
||||
|
||||
YAML::ENGINE.yamler = orig_yamler
|
||||
end
|
||||
end
|
||||
|
||||
context "with Psych as YAML::Engine" do
|
||||
it "raises a GemspecError after YAML load throws Psych::SyntaxError" do
|
||||
orig_yamler = YAML::ENGINE.yamler
|
||||
YAML::ENGINE.yamler = "psych"
|
||||
|
||||
expect { subject }.to raise_error(Bundler::GemspecError)
|
||||
|
||||
YAML::ENGINE.yamler = orig_yamler
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context "with correct YAML file", :if => defined?(Encoding) do
|
||||
|
|
|
@ -32,22 +32,6 @@ RSpec.describe Bundler::EndpointSpecification do
|
|||
)
|
||||
end
|
||||
end
|
||||
|
||||
context "when there is an ill formed requirement" do
|
||||
before do
|
||||
allow(Gem::Dependency).to receive(:new).with(name, [requirement1, requirement2]) {
|
||||
raise ArgumentError.new("Ill-formed requirement [\"#<YAML::Syck::DefaultKey")
|
||||
}
|
||||
# Eliminate extra line break in rspec output due to `puts` in `#build_dependency`
|
||||
allow(subject).to receive(:puts) {}
|
||||
end
|
||||
|
||||
it "should raise a Bundler::GemspecError with invalid gemspec message" do
|
||||
expect { subject.send(:build_dependency, name, [requirement1, requirement2]) }.to raise_error(
|
||||
Bundler::GemspecError, /Unfortunately, the gem foo \(1\.0\.0\) has an invalid gemspec/
|
||||
)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "#parse_metadata" do
|
||||
|
|
|
@ -1,9 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require "bundler/psyched_yaml"
|
||||
|
||||
RSpec.describe "Bundler::YamlLibrarySyntaxError" do
|
||||
it "is raised on YAML parse errors" do
|
||||
expect { YAML.parse "{foo" }.to raise_error(Bundler::YamlLibrarySyntaxError)
|
||||
end
|
||||
end
|
Loading…
Reference in a new issue