ruby-core@ruby-lang.org archive (unofficial mirror)
 help / color / mirror / Atom feed
From: "Eregon (Benoit Daloze)" <noreply@ruby-lang.org>
To: ruby-core@ruby-lang.org
Subject: [ruby-core:105414] [Ruby master Bug#18170] Exception#inspect should not include newlines
Date: Fri, 24 Sep 2021 18:56:06 +0000 (UTC)	[thread overview]
Message-ID: <redmine.journal-93834.20210924185605.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).


The quotes around the message feel redundant to me and likely to cause much more incompatibility.
The message is the main attribute of an exception, I don't think we need to quote it.
I'm neutral regarding escaping \n and non-printable characters.

----------------------------------------
Bug #18170: Exception#inspect should not include newlines
https://bugs.ruby-lang.org/issues/18170#change-93834

* 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/

  parent reply	other threads:[~2021-09-24 18:56 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 ` Eregon (Benoit Daloze) [this message]
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 ` [ruby-core:106005] " Eregon (Benoit Daloze)
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-93834.20210924185605.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).