Bug #7940

Mistaken use of inline rescues in stdlib

Added by Mon ouïe over 2 years ago. Updated over 1 year ago.

[ruby-core:52813]
Status:Closed
Priority:Normal
Assignee:David Black
ruby -v:ruby 1.9.3p392 (2013-02-22 revision 39386) [x86_64-linux] Backport:

Description

Hey,

There are two uses of inline rescues in stdlib that look dubious. They are unlikely to ever cause any harm, but still. They've been there for a while now, and are still in trunk. I attached a patch that changes both of them.

In cgi/session.rb:

  def delete
    File::unlink @path+".lock" rescue nil
    File::unlink @path+".new" rescue nil
    File::unlink @path rescue Errno::ENOENT
  end

The rescue part should be on the next line (this has been introduced in a commit that changed indentation).

In scanf.rb:660:

seek(start_position + matched_so_far, IO::SEEK_SET) rescue Errno::ESPIPE

was more likely meant to just silence Errno::ESPIPE exceptions.

inline_rescue.patch Magnifier (929 Bytes) Mon ouïe, 02/24/2013 09:22 PM


Related issues

Related to Ruby trunk - Feature #7688: Error hiding with rb_rescue() on Comparable#==, #coerce and others Open 01/12/2013

Associated revisions

Revision 40367
Added by Takeyuki FUJIOKA about 2 years ago

  • lib/cgi/session.rb: update rescue in delete session file only Errno::ENOENT.[Bug #7940]

Revision 40367
Added by Takeyuki FUJIOKA about 2 years ago

  • lib/cgi/session.rb: update rescue in delete session file only Errno::ENOENT.[Bug #7940]

Revision 44196
Added by Nobuyoshi Nakada over 1 year ago

scanf.rb: fix rescue modifier

  • lib/scanf.rb (IO#scanf): fix mistaken use of rescue modifier. a patch by Mon_Ouie at . [Bug #7940]

Revision 44196
Added by Nobuyoshi Nakada over 1 year ago

scanf.rb: fix rescue modifier

  • lib/scanf.rb (IO#scanf): fix mistaken use of rescue modifier. a patch by Mon_Ouie at . [Bug #7940]

History

#1 Updated by Eric Hodel over 2 years ago

  • Assignee set to Takeyuki FUJIOKA
  • Priority changed from Low to Normal
  • Target version set to 2.1.0

#2 Updated by Eric Hodel over 2 years ago

  • Status changed from Open to Assigned

#3 Updated by Takeyuki FUJIOKA about 2 years ago

I am maintainer of cgi* but not maintainer of lib/scanf.rb

May I commit with lib/scanf.rb ?

#4 Updated by Yui NARUSE about 2 years ago

xibbar (Takeyuki FUJIOKA) wrote:

I am maintainer of cgi* but not maintainer of lib/scanf.rb

May I commit with lib/scanf.rb ?

Commit your part and assign this to dblack.

#5 Updated by Takeyuki FUJIOKA about 2 years ago

Sorry I was misunderstanding that lib/scanf.rb does not have a maintainer.

#6 Updated by Takeyuki FUJIOKA about 2 years ago

  • Status changed from Assigned to Closed
  • % Done changed from 0 to 100

This issue was solved with changeset r40367.
Mon, thank you for reporting this issue.
Your contribution to Ruby is greatly appreciated.
May Ruby be with you.


  • lib/cgi/session.rb: update rescue in delete session file only Errno::ENOENT.[Bug #7940]

#7 Updated by Takeyuki FUJIOKA about 2 years ago

  • Assignee changed from Takeyuki FUJIOKA to David Black
  • Status changed from Closed to Assigned

update only my part.
please consider your part > dblack.

#8 Updated by Takeyuki FUJIOKA about 2 years ago

  • % Done changed from 100 to 50

#9 Updated by Benoit Daloze about 2 years ago

Related issue for the C counterpart: #7688.

#10 Updated by Zachary Scott about 2 years ago

I've tweeted @david_a_black asking him to check this ticket.

He has been inactive for a long time, though.

#11 Updated by Charlie Somerville over 1 year ago

Bump.

Should dblack be discharged under the 3 month rule? He has not been active for quite some time.

#12 Updated by Nobuyoshi Nakada over 1 year ago

  • Status changed from Assigned to Closed
  • % Done changed from 50 to 100

This issue was solved with changeset r44196.
Mon, thank you for reporting this issue.
Your contribution to Ruby is greatly appreciated.
May Ruby be with you.


scanf.rb: fix rescue modifier

  • lib/scanf.rb (IO#scanf): fix mistaken use of rescue modifier. a patch by Mon_Ouie at . [Bug #7940]

Also available in: Atom PDF