From f79876e194bb44a302a205ef5a91ad951a56e376 Mon Sep 17 00:00:00 2001 From: drbrain Date: Thu, 7 Feb 2013 23:58:42 +0000 Subject: [PATCH] * lib/rubygems/package/old.rb: Fix loading old format gems on ruby 1.8. This commit is only so trunk and rubygems master have the same code. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39145 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 6 ++++++ lib/rubygems/package/old.rb | 16 +++++++++++++--- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index 7300e10709..d331beaadc 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +Fri Feb 8 08:58:26 2013 Eric Hodel + + * lib/rubygems/package/old.rb: Fix loading old format gems on ruby + 1.8. This commit is only so trunk and rubygems master have the same + code. + Fri Feb 8 08:53:27 2013 Aaron Patterson * ext/psych/lib/psych/visitors/yaml_tree.rb: fixing string quotation diff --git a/lib/rubygems/package/old.rb b/lib/rubygems/package/old.rb index 6bf9ea0fe3..e0bdfbb3dc 100644 --- a/lib/rubygems/package/old.rb +++ b/lib/rubygems/package/old.rb @@ -142,9 +142,19 @@ class Gem::Package::Old < Gem::Package end end - @spec = Gem::Specification.from_yaml yaml - rescue YAML::SyntaxError => e - raise Gem::Exception, "Failed to parse gem specification out of gem file" + yaml_error = if RUBY_VERSION < '1.8' then + YAML::ParseError + elsif YAML::ENGINE.yamler == 'syck' then + YAML::ParseError + else + YAML::SyntaxError + end + + begin + @spec = Gem::Specification.from_yaml yaml + rescue yaml_error => e + raise Gem::Exception, "Failed to parse gem specification out of gem file" + end rescue ArgumentError => e raise Gem::Exception, "Failed to parse gem specification out of gem file" end