Ruby Issue Tracking System: Issueshttps://redmine.ruby-lang.org/https://redmine.ruby-lang.org/favicon.ico?17113305112017-12-21T04:36:02ZRuby Issue Tracking System
Redmine Ruby master - Bug #14212 (Closed): Logger uses Kernel.#open to open a file, so it can open someth...https://redmine.ruby-lang.org/issues/142122017-12-21T04:36:02Zsonots (Naotoshi Seo)sonots@gmail.com
<p>It is not intended behavior.</p> Ruby master - Misc #14037 (Open): Writing doxygen document comments to static functionshttps://redmine.ruby-lang.org/issues/140372017-10-21T07:46:19Zsonots (Naotoshi Seo)sonots@gmail.com
<p>I often feel that C API documents are lacked in C source codes, especially for <code>static</code> functions.</p>
<p>With <a href="https://bugs.ruby-lang.org/issues/904" class="external">https://bugs.ruby-lang.org/issues/904</a>, <code>make install-capi</code> target was introduced to generate c api documents using Doxygen.<br>
However, I feel that it is not utilized among C Ruby developers.</p>
<p>I propose to turn <code>EXTRACT_STATIC = YES</code> flag of Doxygen to YES, and write document comments for static functions as much as possible.</p> Ruby master - Feature #13849 (Closed): Show --dump options in helphttps://redmine.ruby-lang.org/issues/138492017-08-30T05:14:23Zsonots (Naotoshi Seo)sonots@gmail.com
<p>Current help does not show any helps for --dump options such as --dump=insns.<br>
I want to get them.</p>
<pre><code>$ ./ruby --help
Usage: ./ruby [switches] [--] [programfile] [arguments]
-0[octal] specify record separator (\0, if no argument)
-a autosplit mode with -n or -p (splits $_ into $F)
-c check syntax only
-Cdirectory cd to directory before executing your script
-d, --debug set debugging flags (set $DEBUG to true)
-e 'command' one line of script. Several -e's allowed. Omit [programfile]
-Eex[:in], --encoding=ex[:in]
specify the default external and internal character encodings
-Fpattern split() pattern for autosplit (-a)
-i[extension] edit ARGV files in place (make backup if extension supplied)
-Idirectory specify $LOAD_PATH directory (may be used more than once)
-l enable line ending processing
-n assume 'while gets(); ... end' loop around your script
-p assume loop like -n but print line also like sed
-rlibrary require the library before executing your script
-s enable some switch parsing for switches after script name
-S look for the script using PATH environment variable
-T[level=1] turn on tainting checks
-v, --verbose print version number, then turn on verbose mode
-w turn warnings on for your script
-W[level=2] set warning level; 0=silence, 1=medium, 2=verbose
-x[directory] strip off text before #!ruby line and perhaps cd to directory
--copyright print the copyright
--enable=feature[,...], --disable=feature[,...]
enable or disable features
--external-encoding=encoding, --internal-encoding=encoding
specify the default external or internal character encoding
--version print the version
--help show this message, -h for short message
Features:
gems rubygems (default: enabled)
did_you_mean did_you_mean (default: enabled)
rubyopt RUBYOPT environment variable (default: enabled)
frozen-string-literal
freeze all string literals (default: disabled)
</code></pre> Ruby master - Feature #13665 (Closed): String#delete_suffixhttps://redmine.ruby-lang.org/issues/136652017-06-16T14:30:16Zsonots (Naotoshi Seo)sonots@gmail.com
<p>In <a href="https://bugs.ruby-lang.org/issues/12694" class="external">https://bugs.ruby-lang.org/issues/12694</a>, we decided to have <code>String#delete_prefix</code>.<br>
It would be nice to have <code>String#delete_suffix</code> method to delete suffix from a string for symmetry although it can be achieved with <code>String#chomp</code> as:</p>
<pre><code class="ruby syntaxhl" data-language="ruby"><span class="k">class</span> <span class="nc">String</span>
<span class="k">def</span> <span class="nf">delete_suffix</span><span class="p">(</span><span class="n">substr</span><span class="p">)</span>
<span class="nb">chomp</span><span class="p">(</span><span class="n">substr</span><span class="p">)</span>
<span class="k">end</span>
<span class="k">def</span> <span class="nf">delete_suffix!</span><span class="p">(</span><span class="n">substr</span><span class="p">)</span>
<span class="nb">chomp!</span><span class="p">(</span><span class="n">substr</span><span class="p">)</span>
<span class="k">end</span>
<span class="k">end</span>
</code></pre>
<p>Any opinions?</p> Ruby master - Feature #13613 (Feedback): Prefer that require/require_relative/load to tell us per...https://redmine.ruby-lang.org/issues/136132017-05-30T11:25:33Zsonots (Naotoshi Seo)sonots@gmail.com
<a name="Background"></a>
<h3 >Background<a href="#Background" class="wiki-anchor">¶</a></h3>
<p><a href="https://github.com/google/google-api-ruby-client/issues/205" class="external">https://github.com/google/google-api-ruby-client/issues/205</a></p>
<p>We've ever met a situation that read-permissions of files in released google-api-client gem were lost as:</p>
<pre><code>$ ls -l ~/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/google-api-client-0.8.3/lib/google
-rw-r----- 1 sonots sonots 27249 March 24 18:32 2015 api_client.rb
</code></pre>
<p>The error message was</p>
<pre><code>in `require': cannot load such file -- api_client.rb (LoadError)
</code></pre>
<p>At that time, it took 30 minutes for me to find the reason why we get LoadError with the gem because the file exists.<br>
I looked the source codes load.c, and finally I found the reason as it is because of permission with my intuition.</p>
<a name="What-I-Want"></a>
<h3 >What I Want<a href="#What-I-Want" class="wiki-anchor">¶</a></h3>
<p>If <code>require</code> tells us PermissionError in addition to LoadError, I could figure out the reason soon.<br>
I think the additional information is helpful for finding such issues.</p> Ruby master - Feature #12694 (Closed): Want a String method to remove heading substrhttps://redmine.ruby-lang.org/issues/126942016-08-23T09:03:45Zsonots (Naotoshi Seo)sonots@gmail.com
<p>I often write codes like:</p>
<pre><code class="ruby syntaxhl" data-language="ruby"><span class="n">str</span> <span class="o">=</span> <span class="s1">'abcdef'</span>
<span class="n">substr</span> <span class="o">=</span> <span class="s1">'abc'</span>
<span class="n">str</span><span class="p">[</span><span class="n">substr</span><span class="p">.</span><span class="nf">size</span><span class="o">..-</span><span class="mi">1</span><span class="p">]</span> <span class="k">if</span> <span class="n">str</span><span class="p">.</span><span class="nf">start_with?</span><span class="p">(</span><span class="n">substr</span><span class="p">)</span> <span class="c1">#=> 'def'</span>
<span class="c1"># or</span>
<span class="n">str</span><span class="p">.</span><span class="nf">sub</span><span class="p">(</span><span class="sr">/\A</span><span class="si">#{</span><span class="no">Regexp</span><span class="p">.</span><span class="nf">escape</span><span class="p">(</span><span class="n">substr</span><span class="p">)</span><span class="si">}</span><span class="sr">/</span><span class="p">,</span> <span class="s1">''</span><span class="p">)</span> <span class="c1">#=> 'def'</span>
</code></pre>
<p>I want a short hand which is something like:</p>
<pre><code class="ruby syntaxhl" data-language="ruby"><span class="n">str</span> <span class="o">=</span> <span class="s1">'abcdef'</span>
<span class="n">substr</span> <span class="o">=</span> <span class="s1">'abc'</span>
<span class="n">str</span><span class="p">.</span><span class="nf">lstrip</span><span class="p">(</span><span class="n">substr</span><span class="p">)</span> <span class="c1">#=> 'def'</span>
</code></pre>
<p>Having similar argument for <code>String#rstrip</code> would be nice for symmetry although we already have <code>String#chomp(substr)</code></p>
<p>My frequent use-case is coming from fluentd. We have <code>remove_tag_prefix</code> option to remove a heading substring from a tag. We currently using <code>String#sub</code> with a regular expression, but I feel regular expression matching is too much just to remove a heading substring. <a href="https://github.com/fluent/fluentd/blob/75005f18d48ed3d416890413fa5f83982b264c71/lib/fluent/compat/handle_tag_name_mixin.rb#L45" class="external">https://github.com/fluent/fluentd/blob/75005f18d48ed3d416890413fa5f83982b264c71/lib/fluent/compat/handle_tag_name_mixin.rb#L45</a></p> Ruby master - Feature #12693 (Rejected): Want a way to receive EINTR on Process.waitpidhttps://redmine.ruby-lang.org/issues/126932016-08-23T01:32:29Zsonots (Naotoshi Seo)sonots@gmail.com
<p><a href="http://man7.org/linux/man-pages/man2/waitpid.2.html" class="external">http://man7.org/linux/man-pages/man2/waitpid.2.html</a> tells EINTR error if WNOHANG flag was not set and an unblocked signal or a SIGCHLD was caught.</p>
<p>However, ruby implementation of Process.waitpid does not raise EINTR <a href="https://github.com/ruby/ruby/blob/c2bf7e6f7d2fbe0b50da59aaa1374222f233aa71/process.c#L910-L911" class="external">https://github.com/ruby/ruby/blob/c2bf7e6f7d2fbe0b50da59aaa1374222f233aa71/process.c#L910-L911</a></p>
<p>test.rb</p>
<pre><code>puts Process.pid
trap(:CONT) do
puts 'CONT'
end
_pid = fork do
sleep 10
end
Process.waitpid(-1)
</code></pre>
<pre><code>$ ruby test.rb
</code></pre>
<pre><code>$ kill -CONT xxxx # waitpid does not raise EINTR
</code></pre>
<p>I want a way or an option to get EINTR error on sending signal so that I can release blocking of waitpid.<br>
It is same for wait, waitpid2, wait2, too.</p> Ruby master - Feature #12686 (Closed): Allowing a postposed rescue in a method argumenthttps://redmine.ruby-lang.org/issues/126862016-08-18T05:03:07Zsonots (Naotoshi Seo)sonots@gmail.com
<p>On defining my own DSL, I wanted to write a code like:</p>
<pre><code>foo (Integer(ENV['FOO']) rescue nil)
</code></pre>
<p>where <code>foo</code> is a method which receives one argument , but I got following error</p>
<pre><code>SyntaxError: (irb):1: syntax error, unexpected modifier_rescue, expecting ')'
</code></pre>
<p>In contrast, following codes were valid:</p>
<pre><code>foo ((Integer(ENV['FOO']) rescue nil))
</code></pre>
<p>or</p>
<pre><code>foo (begin; Integer(ENV['FOO']); rescue; nil; end)
</code></pre>
<p>This is a feature request to allow such a syntax, a postposed rescue in a method argument.</p> Ruby master - Bug #12259 (Rejected): DateTime.parse does not take into account the system timezonehttps://redmine.ruby-lang.org/issues/122592016-04-07T15:57:42Zsonots (Naotoshi Seo)sonots@gmail.com
<p>DateTime.parse does not take into account the system timezone although Time.parse does take into account the system timezone.</p>
<pre><code>irb(main):002:0> DateTime.parse('2011-10-10 10:00:00')
=> #<DateTime: 2011-10-10T10:00:00+00:00 ((2455845j,36000s,0n),+0s,2299161j)>
irb(main):005:0> Time.parse('2011-10-10 10:00:00')
=> 2011-10-10 10:00:00 +0900
</code></pre>
<p>Are there any reasons that <code>DateTime.parse</code> behaves like this?<br>
Can this behavior be changed, or do we have to keep this behavior for lower version compatibility?</p> Ruby master - Bug #12190 (Rejected): DateTime.strptime and Time.strptime does not have compatibil...https://redmine.ruby-lang.org/issues/121902016-03-17T13:43:54Zsonots (Naotoshi Seo)sonots@gmail.com
<p>For CET, only DateTime.strptime successfully parsed timezone</p>
<pre><code>irb(main):003:0> DateTime.strptime('2015-11-12 CET', '%Y-%m-%d %Z')
=> #<DateTime: 2015-11-12T00:00:00+01:00 ((2457338j,82800s,0n),+3600s,2299161j)>
irb(main):004:0> Time.strptime('2015-11-12 CET', '%Y-%m-%d %Z')
=> 2015-11-12 00:00:00 +0900
</code></pre>
<p>For JST also, only DateTime worked.</p>
<pre><code>irb(main):005:0> ENV['TZ'] = 'UTC'
=> "UTC"
irb(main):006:0> DateTime.strptime('2015-11-12 JST', '%Y-%m-%d %Z')
=> #<DateTime: 2015-11-12T00:00:00+09:00 ((2457338j,54000s,0n),+32400s,2299161j)>
irb(main):007:0> Time.strptime('2015-11-12 JST', '%Y-%m-%d %Z')
=> 2015-11-12 00:00:00 +0000
</code></pre>
<p>For PST, both worked.</p>
<pre><code>irb(main):004:0> DateTime.strptime('2015-11-12 PST', '%Y-%m-%d %Z')
=> #<DateTime: 2015-11-12T00:00:00-08:00 ((2457339j,28800s,0n),-28800s,2299161j)>
irb(main):003:0> Time.strptime('2015-11-12 PST', '%Y-%m-%d %Z')
=> 2015-11-12 00:00:00 -0800
</code></pre>
<p>I felt DateTime.strptime and Time.strptime should have compatibility.</p> Ruby master - Bug #12189 (Closed): DateTime#to_time removes timezone informationhttps://redmine.ruby-lang.org/issues/121892016-03-17T13:37:00Zsonots (Naotoshi Seo)sonots@gmail.com
<pre><code>irb(main):004:0> DateTime.strptime('2015-11-12 CET', '%Y-%m-%d %Z')
=> #<DateTime: 2015-11-12T00:00:00+01:00 ((2457338j,82800s,0n),+3600s,2299161j)>
irb(main):005:0> DateTime.strptime('2015-11-12 CET', '%Y-%m-%d %Z').to_time
=> 2015-11-12 08:00:00 +0900
</code></pre>
<p>I think it is better to preserve timezone information as <code>2015-11-12 00:00:00 +0100</code></p> Ruby master - Feature #11696 (Closed): Logger#reopenhttps://redmine.ruby-lang.org/issues/116962015-11-16T11:14:47Zsonots (Naotoshi Seo)sonots@gmail.com
<p>Added <code>Logger#reopen</code>as we talked at <a href="https://twitter.com/frsyuki/status/664862229490089984" class="external">https://twitter.com/frsyuki/status/664862229490089984</a>.</p>
<p>This enables to reopen another log file (or same log file) without creating a new Logger instance. This is useful when an application is passing a logger instance everywhere inside it, but want to change log file as <a href="https://github.com/fluent/serverengine" class="external">https://github.com/fluent/serverengine</a> does on config reloading.</p>
<p>The patch is available at <a href="https://github.com/ruby/ruby/pull/1102" class="external">https://github.com/ruby/ruby/pull/1102</a>.</p> Ruby master - Feature #11695 (Closed): Support symbol and string for Logger#level=https://redmine.ruby-lang.org/issues/116952015-11-16T06:53:33Zsonots (Naotoshi Seo)sonots@gmail.com
<p>Added Logger#level=:symbol and Logger#level=string as we talked at <a href="https://twitter.com/frsyuki/status/664862229490089984" class="external">https://twitter.com/frsyuki/status/664862229490089984</a>.</p>
<p>This is useful especially when we configure log_level with yaml (typically, on rails application) like</p>
<p>settings.yml</p>
<pre><code>log_level: DEBUG
</code></pre>
<p>and</p>
<pre><code> logger.level = Settings.log_level
</code></pre>
<p>The patch is available at <a href="https://github.com/ruby/ruby/pull/1101" class="external">https://github.com/ruby/ruby/pull/1101</a></p> Ruby master - Bug #9525 (Closed): Stuck with Socket.pack_sockaddr_inhttps://redmine.ruby-lang.org/issues/95252014-02-17T11:30:15Zsonots (Naotoshi Seo)sonots@gmail.com
<p>We met this trouble with Fluentd <a href="https://github.com/fluent/fluentd" class="external">https://github.com/fluent/fluentd</a>.</p>
<p>Fluentd is sometimes stuck at <code>Socket.pack_sockaddr_in</code> line on shutdown.<br>
Here is the gist <a href="https://gist.github.com/sonots/9047653" class="external">https://gist.github.com/sonots/9047653</a> to explain details.</p> Ruby master - Bug #9046 (Closed): [PATCH] Inter-process locking for log rotation is requiredhttps://redmine.ruby-lang.org/issues/90462013-10-23T15:44:35Zsonots (Naotoshi Seo)sonots@gmail.com
<p>I sent a pull request on <a href="https://github.com/ruby/ruby/pull/428" class="external">https://github.com/ruby/ruby/pull/428</a> . Please see details on it.</p>