From 2cf1123d2f262a8086b6a1f659a4733b6730f2fe Mon Sep 17 00:00:00 2001 From: usa Date: Wed, 9 Sep 2015 09:18:47 +0000 Subject: * lib/rubygems/stub_specification.rb (Gem::StubSpecification#data): should not change the value of $. when `require`ing gems. this fixed test failures introduced by r51813. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51814 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 6 ++++++ lib/rubygems/stub_specification.rb | 25 +++++++++++++++---------- 2 files changed, 21 insertions(+), 10 deletions(-) diff --git a/ChangeLog b/ChangeLog index fe6ae86e3c..7ffd2b8a42 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +Wed Sep 9 18:16:14 2015 NAKAMURA Usaku + + * lib/rubygems/stub_specification.rb (Gem::StubSpecification#data): + should not change the value of $. when `require`ing gems. + this fixed test failures introduced by r51813. + Wed Sep 9 16:55:45 2015 NAKAMURA Usaku * ruby.c (usage, enable_option, disable_option, process_options): new diff --git a/lib/rubygems/stub_specification.rb b/lib/rubygems/stub_specification.rb index ed07e8011f..bb59077ca2 100644 --- a/lib/rubygems/stub_specification.rb +++ b/lib/rubygems/stub_specification.rb @@ -73,18 +73,23 @@ class Gem::StubSpecification < Gem::BasicSpecification unless @data @extensions = [] - open loaded_from, OPEN_MODE do |file| - begin - file.readline # discard encoding line - stubline = file.readline.chomp - if stubline.start_with?(PREFIX) then - @data = StubLine.new stubline - - @extensions = $'.split "\0" if - /\A#{PREFIX}/ =~ file.readline.chomp + begin + saved_lineno = $. + open loaded_from, OPEN_MODE do |file| + begin + file.readline # discard encoding line + stubline = file.readline.chomp + if stubline.start_with?(PREFIX) then + @data = StubLine.new stubline + + @extensions = $'.split "\0" if + /\A#{PREFIX}/ =~ file.readline.chomp + end + rescue EOFError end - rescue EOFError end + ensure + $. = saved_lineno end end -- cgit v1.2.3