diff --git a/lib/rubygems.rb b/lib/rubygems.rb index 2265f2143..2ed2f592c 100644 --- a/lib/rubygems.rb +++ b/lib/rubygems.rb @@ -671,6 +671,7 @@ def self.load_yaml YAML::ENGINE.yamler = "psych" end + require 'rubygems/psych_additions' require 'rubygems/psych_tree' end end diff --git a/lib/rubygems/psych_additions.rb b/lib/rubygems/psych_additions.rb new file mode 100644 index 000000000..08a5cb37e --- /dev/null +++ b/lib/rubygems/psych_additions.rb @@ -0,0 +1,9 @@ +# This exists just to satify bugs in marshal'd gemspecs that +# contain a reference to YAML::PrivateType. We prune these out +# in Specification._load, but if we don't have the constant, Marshal +# blows up. + +module Psych + class PrivateType + end +end diff --git a/lib/rubygems/specification.rb b/lib/rubygems/specification.rb index 330aaad37..2f49bfbff 100644 --- a/lib/rubygems/specification.rb +++ b/lib/rubygems/specification.rb @@ -666,6 +666,11 @@ def self._load(str) raise TypeError, "invalid Gem::Specification format #{array.inspect}" end + # Cleanup any YAML::PrivateType. They only show up for an old bug + # where nil => null, so just convert them to nil based on the type. + + array.map! { |e| e.kind_of?(YAML::PrivateType) ? nil : e } + spec.instance_variable_set :@rubygems_version, array[0] # spec version spec.instance_variable_set :@name, array[2]