[#83773] [Ruby trunk Bug#14108] Seg Fault with MinGW on svn 60769 — usa@...
Issue #14108 has been updated by usa (Usaku NAKAMURA).
9 messages
2017/11/15
[#83774] Re: [Ruby trunk Bug#14108] Seg Fault with MinGW on svn 60769
— Eric Wong <normalperson@...>
2017/11/15
usa@garbagecollect.jp wrote:
[#83775] Re: [Ruby trunk Bug#14108] Seg Fault with MinGW on svn 60769
— "U.NAKAMURA" <usa@...>
2017/11/15
Hi, Eric
[#83779] Re: [Ruby trunk Bug#14108] Seg Fault with MinGW on svn 60769
— Eric Wong <normalperson@...>
2017/11/15
"U.NAKAMURA" <usa@garbagecollect.jp> wrote:
[#83781] Re: [Ruby trunk Bug#14108] Seg Fault with MinGW on svn 60769
— "U.NAKAMURA" <usa@...>
2017/11/15
Hi, Eric,
[#83782] Re: [Ruby trunk Bug#14108] Seg Fault with MinGW on svn 60769
— Eric Wong <normalperson@...>
2017/11/15
IlUuTkFLQU1VUkEiIDx1c2FAZ2FyYmFnZWNvbGxlY3QuanA+IHdyb3RlOgo+IEhpLCBFcmljLAo+
[ruby-core:83857] [Ruby trunk Feature#14123] Kernel#pp by default
From:
merch-redmine@...
Date:
2017-11-21 17:11:27 UTC
List:
ruby-core #83857
Issue #14123 has been updated by jeremyevans0 (Jeremy Evans).
Eregon (Benoit Daloze) wrote:
> The thread safety problem is due to `undef`, right?
Correct. The `pp` library defines `Kernel#pp`, so in verbose mode if you don't undef or remove the method first, this causes a warning in verbose mode. I think a verbose mode warning is preferable to thread-unsafe code. Here's a possible alternative implementation:
~~~ruby
module Kernel
def pp(*a)
require 'pp'
rescue LoadError
p(*a)
else
pp(*a)
end
end
~~~
To avoid the verbose mode warning, we could have `pp` include a different module in `Object` instead of modifying `Kernel` directly, and then use `Kernel.send(:remove_method, :pp)` to remove the method, but we'd need to rescue `NameError` raised by the `remove_method` call to ensure thread safety in that case.
Note that in all of these cases, `Kernel#pp` will break if `Kernel` is frozen.
----------------------------------------
Feature #14123: Kernel#pp by default
https://bugs.ruby-lang.org/issues/14123#change-67886
* Author: mame (Yusuke Endoh)
* Status: Open
* Priority: Normal
* Assignee: matz (Yukihiro Matsumoto)
* Target version: 2.5
----------------------------------------
Matz, may I commit this? I really want this.
```
diff --git a/prelude.rb b/prelude.rb
index 7b98e28285..87f49ac9fb 100644
--- a/prelude.rb
+++ b/prelude.rb
@@ -141,3 +141,11 @@ def irb
irb
end
end
+
+module Kernel
+ def pp(*objs)
+ undef :pp
+ require 'pp'
+ pp(*objs)
+ end
+end
```
--
https://bugs.ruby-lang.org/
Unsubscribe: <mailto:ruby-core-request@ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>