Project

General

Profile

Actions

Feature #16101

closed

Proc#to_s returns "... file:line" instead of "...@file:line"

Added by ko1 (Koichi Sasada) about 5 years ago. Updated over 4 years ago.

Status:
Closed
Target version:
-
[ruby-core:94341]

Description

In [Feature #14145],
https://bugs.ruby-lang.org/issues/14145#note-25

I think (a space) is better, and it's what we use for Method#inspect in TruffleRuby.
My motivation is that selection by double-clicking in the terminal just works with a space,
but fails with @ and results in 0x00007f850b8f9458@-e when double-clicking on the filename (-e here).
I find it also easier to read.

I tried to introduce this change (@ -> ).

Compatibility issue

Some code may be dependent on this string format. In fact, rubygems requires this patch:

diff --git a/lib/rubygems/installer.rb b/lib/rubygems/installer.rb
index b230ce7bed..554cfc4509 100644
--- a/lib/rubygems/installer.rb
+++ b/lib/rubygems/installer.rb
@@ -370,7 +370,7 @@ def run_post_build_hooks # :nodoc:
       if hook.call(self) == false
         FileUtils.rm_rf gem_dir

-        location = " at #{$1}" if hook.inspect =~ /@(.*:\d+)/
+        location = " at #{$1}" if hook.inspect =~ / (.*:\d+)/

         message = "post-build hook#{location} failed for #{spec.full_name}"
         raise Gem::InstallError, message

I think we shouldn't use this string, but use source_location method.

I'll commit. If you have an issue, please re-open it.


Related issues 2 (0 open2 closed)

Related to Ruby master - Feature #14145: Proposal: Better Method#inspectClosedActions
Related to Ruby master - Feature #16412: Thread#to_s to return "... file:line" instead of "...@file:line"Closedko1 (Koichi Sasada)Actions
Actions #1

Updated by ko1 (Koichi Sasada) about 5 years ago

Actions #2

Updated by ko1 (Koichi Sasada) about 5 years ago

  • Status changed from Open to Closed

Applied in changeset git|182a408c2c4113eb316c2a87e35880144afb4498.


change Proc#to_s format ('@...' -> ' ...') (#2362)

Now Proc#to_s returns
"#Proc:0x00000237a0f5f170@t.rb:1".
However, it is convenient to select a file name by (double-)clicking
on some terminals by separating ' ' instead of '@' like
"#<Proc:0x00000237a0f5f170 t.rb:1>"
[Feature #16101]

Updated by hsbt (Hiroshi SHIBATA) about 5 years ago

  • Status changed from Closed to Assigned

Updated by znz (Kazuhiro NISHIYAMA) almost 5 years ago

  • Status changed from Assigned to Closed
Actions #5

Updated by znz (Kazuhiro NISHIYAMA) almost 5 years ago

  • Related to Feature #16412: Thread#to_s to return "... file:line" instead of "...@file:line" added
Actions #6

Updated by sawa (Tsuyoshi Sawada) over 4 years ago

  • Description updated (diff)
Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0