Project

General

Profile

Bug #14846

Backport fixes for Kernel#warn(uplevel:)

Added by Eregon (Benoit Daloze) 3 months ago. Updated 3 months ago.

Status:
Closed
Priority:
Normal
Assignee:
-
Target version:
-
ruby -v:
ruby 2.5.1p57 (2018-03-29 revision 63029) [x86_64-linux]
[ruby-core:87487]

Description

-> { warn("foo", 100) }.should output(nil, "warning: foo\n")

It is missing the "warning: " prefix in 2.5.1.

-> { warn "", uplevel: -1 }.should raise_error(ArgumentError)

It doesn't raise in 2.5.1 even though warn "", uplevel: -2 does.

Both were fixed on trunk.
I believe it should be fixed in 2.5 as that is buggy behavior.

Then https://github.com/ruby/spec/commit/dea70b1c50f2cba7624b764fea639edfcff11ced can be reverted.

Associated revisions

Revision 61525
Added by nobu (Nobuyoshi Nakada) 9 months ago

error.c: negative uplevel

  • error.c (rb_warn_m): negative uplevel is not allowed. [Bug #14262]

Revision 61527
Added by nobu (Nobuyoshi Nakada) 9 months ago

error.c: limit depth

  • error.c (rb_warn_m): limit backtrace depth to reduce objects to be created but not used.

Revision 63062
Added by nobu (Nobuyoshi Nakada) 6 months ago

error.c: prepend "warning: " always

  • error.c (rb_warn_m): prepend the string "warning: " if uplevel keyword is given, even if caller file and line information are not available.

Revision 63650
Added by Eregon (Benoit Daloze) 3 months ago

Fix condition in Kernel#warn when using uplevel

Revision 905189b2
Added by nagachika (Tomoyuki Chikanaga) 3 months ago

merge revision(s) 61525,61527,63062,63650: [Backport #14846]

    error.c: negative uplevel

    * error.c (rb_warn_m): negative uplevel is not allowed.
       [Bug #14262]

    error.c: limit depth

    * error.c (rb_warn_m): limit backtrace depth to reduce objects to
      be created but not used.

    error.c: prepend "warning: " always

    * error.c (rb_warn_m): prepend the string "warning: " if uplevel
      keyword is given, even if caller file and line information are
      not available.

    Fix condition in Kernel#warn when using uplevel

    * It causes SEGV on `warn("foo", uplevel: 100)`.
    * Found in a ruby/spec added by @andrykonchin in
      https://github.com/ruby/spec/pull/605

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_5@63819 b2dd03c8-39d4-4d8f-98ff-823fe69b080e

Revision 63819
Added by nagachika (Tomoyuki Chikanaga) 3 months ago

merge revision(s) 61525,61527,63062,63650: [Backport #14846]

error.c: negative uplevel

* error.c (rb_warn_m): negative uplevel is not allowed.
   [Bug #14262]

error.c: limit depth

* error.c (rb_warn_m): limit backtrace depth to reduce objects to
  be created but not used.

error.c: prepend "warning: " always

* error.c (rb_warn_m): prepend the string "warning: " if uplevel
  keyword is given, even if caller file and line information are
  not available.

Fix condition in Kernel#warn when using uplevel

* It causes SEGV on `warn("foo", uplevel: 100)`.
* Found in a ruby/spec added by @andrykonchin in
  https://github.com/ruby/spec/pull/605

History

#1 [ruby-core:87520] Updated by nagachika (Tomoyuki Chikanaga) 3 months ago

  • Backport changed from 2.3: UNKNOWN, 2.4: UNKNOWN, 2.5: UNKNOWN to 2.3: DONTNEED, 2.4: DONTNEED, 2.5: REQUIRED
  • Status changed from Open to Closed

Thank you for your notice.
I will backport r63650.

#2 [ruby-core:87624] Updated by Eregon (Benoit Daloze) 3 months ago

I think those changes related to uplevel: should also be backported, unless they are already part of 2.5 of course:

r63062: error.c: prepend "warning: " always (fixes the first problem shown above)
r61527: error.c (rb_warn_m): limit backtrace depth to reduce objects to be created but not used.
r61525: error.c (rb_warn_m): negative uplevel is not allowed. [Bug #14262]. (I think that fixes the second problem shown above).

#3 [ruby-core:87735] Updated by nagachika (Tomoyuki Chikanaga) 3 months ago

  • Backport changed from 2.3: DONTNEED, 2.4: DONTNEED, 2.5: REQUIRED to 2.3: DONTNEED, 2.4: DONTNEED, 2.5: DONE

ruby_2_5 r63819 merged revision(s) 61525,61527,63062,63650.

Also available in: Atom PDF