From 4bc87cb1fb9ecbd227720bd48836935996574166 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Rodr=C3=ADguez?= Date: Wed, 8 Jul 2020 23:26:28 +0200 Subject: [PATCH] [rubygems/rubygems] Remove `syck` traces from `bundler` Same reason as in the previous commit. https://github.com/rubygems/rubygems/commit/f00a6c8516 --- lib/bundler.rb | 4 +--- lib/bundler/endpoint_specification.rb | 8 ------- lib/bundler/psyched_yaml.rb | 14 +---------- lib/bundler/rubygems_integration.rb | 2 +- spec/bundler/bundler/bundler_spec.rb | 24 ------------------- .../bundler/endpoint_specification_spec.rb | 16 ------------- spec/bundler/bundler/psyched_yaml_spec.rb | 9 ------- 7 files changed, 3 insertions(+), 74 deletions(-) delete mode 100644 spec/bundler/bundler/psyched_yaml_spec.rb diff --git a/lib/bundler.rb b/lib/bundler.rb index dcbc3fdfb7..f2d874bdf3 100644 --- a/lib/bundler.rb +++ b/lib/bundler.rb @@ -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 diff --git a/lib/bundler/endpoint_specification.rb b/lib/bundler/endpoint_specification.rb index 476151ae56..6cf597b943 100644 --- a/lib/bundler/endpoint_specification.rb +++ b/lib/bundler/endpoint_specification.rb @@ -3,7 +3,6 @@ module Bundler # used for Creating Specifications from the Gemcutter Endpoint class EndpointSpecification < Gem::Specification - ILLFORMED_MESSAGE = 'Ill-formed requirement ["# 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 diff --git a/lib/bundler/psyched_yaml.rb b/lib/bundler/psyched_yaml.rb index 463d52dc4a..3d9893031f 100644 --- a/lib/bundler/psyched_yaml.rb +++ b/lib/bundler/psyched_yaml.rb @@ -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 diff --git a/lib/bundler/rubygems_integration.rb b/lib/bundler/rubygems_integration.rb index 98982b0f07..26cc4d85e5 100644 --- a/lib/bundler/rubygems_integration.rb +++ b/lib/bundler/rubygems_integration.rb @@ -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 diff --git a/spec/bundler/bundler/bundler_spec.rb b/spec/bundler/bundler/bundler_spec.rb index b8191fe20f..aeadcf9720 100644 --- a/spec/bundler/bundler/bundler_spec.rb +++ b/spec/bundler/bundler/bundler_spec.rb @@ -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 diff --git a/spec/bundler/bundler/endpoint_specification_spec.rb b/spec/bundler/bundler/endpoint_specification_spec.rb index a9371f6617..2e2c16ec44 100644 --- a/spec/bundler/bundler/endpoint_specification_spec.rb +++ b/spec/bundler/bundler/endpoint_specification_spec.rb @@ -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 [\"#