From: "Eregon (Benoit Daloze)" <noreply@ruby-lang.org>
To: ruby-core@ruby-lang.org
Subject: [ruby-core:106005] [Ruby master Bug#18170] Exception#inspect should not include newlines
Date: Wed, 10 Nov 2021 11:10:58 +0000 (UTC) [thread overview]
Message-ID: <redmine.journal-94553.20211110111058.18@ruby-lang.org> (raw)
In-Reply-To: redmine.issue-18170.20210916023406.18@ruby-lang.org
Issue #18170 has been updated by Eregon (Benoit Daloze).
BTW it seems `irb` disables `error_highlight` somehow:
```
$ ruby -ve 'self.instance_off'
ruby 3.1.0dev (2021-11-08T13:15:21Z master bd2674ad33) [x86_64-linux]
-e:1:in `<main>': undefined method `instance_off' for main:Object (NoMethodError)
self.instance_off
^^^^^^^^^^^^^
Did you mean? instance_of?
```
vs
```
$ irb
irb(main):001:0> self.instance_off
(irb):1:in `<main>': undefined method `instance_off' for main:Object (NoMethodError)
Did you mean? instance_of?
from /home/eregon/prefix/ruby-master/lib/ruby/gems/3.1.0/gems/irb-1.3.8.pre.11/exe/irb:11:in `<top (required)>'
from /home/eregon/.rubies/ruby-master/bin/irb:25:in `load'
from /home/eregon/.rubies/ruby-master/bin/irb:25:in `<main>'
```
----------------------------------------
Bug #18170: Exception#inspect should not include newlines
https://bugs.ruby-lang.org/issues/18170#change-94553
* Author: mame (Yusuke Endoh)
* Status: Assigned
* Priority: Normal
* Assignee: mame (Yusuke Endoh)
* Backport: 2.6: UNKNOWN, 2.7: UNKNOWN, 3.0: UNKNOWN
----------------------------------------
Is this intentional?
```
p StandardError.new("foo\nbar")
#=>
# #<StandardError: foo
# bar>
```
I expect `#inspect` returns a one-line string. How about returning `#<StandardError: "foo\nbar">` or something?
Recently, multi-line error messages have been increasing by the introduction of did_you_mean and error_highlight. Printing an object that contains such an exception leads to a tricky output:
```
class Foo
def initialize
@exception = begin; exampl; rescue Exception; $!; end
end
def example
end
end
p Foo.new
#=>
# #<Foo:0x00007f15aeb4ba48 @exception=#<NameError: undefined local variable or method `exampl' for #<Foo:0x00007f15aeb4ba48 ...>
#
# @exception = begin; exampl; rescue Exception; $!; end
# ^^^^^^
# Did you mean? example>>
```
This issue was originally found by @ioquatix
--
https://bugs.ruby-lang.org/
next prev parent reply other threads:[~2021-11-10 11:11 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-09-16 2:34 [ruby-core:105276] [Ruby master Bug#18170] Exception#inspect should not include newlines mame (Yusuke Endoh)
2021-09-16 8:42 ` [ruby-core:105291] " mame (Yusuke Endoh)
2021-09-16 10:16 ` [ruby-core:105295] " ioquatix (Samuel Williams)
2021-09-17 8:04 ` [ruby-core:105323] " mame (Yusuke Endoh)
2021-09-24 18:56 ` [ruby-core:105414] " Eregon (Benoit Daloze)
2021-09-25 16:58 ` [ruby-core:105418] " mame (Yusuke Endoh)
2021-09-26 12:07 ` [ruby-core:105424] " Eregon (Benoit Daloze)
2021-09-26 20:17 ` [ruby-core:105426] " ioquatix (Samuel Williams)
2021-09-26 20:18 ` [ruby-core:105427] " ioquatix (Samuel Williams)
2021-09-27 9:59 ` [ruby-core:105445] " Eregon (Benoit Daloze)
2021-09-27 10:02 ` [ruby-core:105446] " Eregon (Benoit Daloze)
2021-09-29 9:47 ` [ruby-core:105485] " ioquatix (Samuel Williams)
2021-10-21 5:09 ` [ruby-core:105711] " matz (Yukihiro Matsumoto)
2021-10-25 8:59 ` [ruby-core:105778] " mame (Yusuke Endoh)
2021-10-25 10:20 ` [ruby-core:105786] " ioquatix (Samuel Williams)
2021-10-25 15:07 ` [ruby-core:105790] " mame (Yusuke Endoh)
2021-10-26 8:59 ` [ruby-core:105804] " ioquatix (Samuel Williams)
2021-11-10 11:03 ` [ruby-core:106003] " Eregon (Benoit Daloze)
2021-11-10 11:10 ` [ruby-core:106004] " ioquatix (Samuel Williams)
2021-11-10 11:10 ` Eregon (Benoit Daloze) [this message]
2021-11-10 11:15 ` [ruby-core:106006] " Eregon (Benoit Daloze)
2021-11-11 13:52 ` [ruby-core:106029] " mame (Yusuke Endoh)
2021-11-30 7:32 ` [ruby-core:106333] " mame (Yusuke Endoh)
2022-06-07 9:25 ` [ruby-core:108791] " st0012 (Stan Lo)
2022-06-07 9:58 ` [ruby-core:108792] " ioquatix (Samuel Williams)
2022-06-07 20:19 ` [ruby-core:108797] " st0012 (Stan Lo)
2022-06-08 0:27 ` [ruby-core:108798] " ioquatix (Samuel Williams)
2022-09-23 7:11 ` [ruby-core:110034] " ioquatix (Samuel Williams)
2022-09-23 7:40 ` [ruby-core:110037] " mame (Yusuke Endoh)
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-list from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.ruby-lang.org/en/community/mailing-lists/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=redmine.journal-94553.20211110111058.18@ruby-lang.org \
--to=ruby-core@ruby-lang.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).