[ruby-core:119958] [Ruby master Bug#20900] Net.send(:remove_const, :HTTPSession) does not emit warnings

Issue #20900 has been reported by yahonda (Yasuo Honda). ---------------------------------------- Bug #20900: Net.send(:remove_const, :HTTPSession) does not emit warnings https://bugs.ruby-lang.org/issues/20900 * Author: yahonda (Yasuo Honda) * Status: Open * ruby -v: ruby 3.3.6 (2024-11-05 revision 75015d4c1f) [x86_64-linux] * Backport: 3.1: UNKNOWN, 3.2: UNKNOWN, 3.3: UNKNOWN ---------------------------------------- After https://github.com/ruby/net-http/pull/189 has been merged and cherry-picked to Ruby master branch, `Net.send(:remove_const, :HTTPSession)` gets the NameError. This code should emit warnings against Ruby 3.3 or earlier versions of Ruby but actually it does not. ``` $ ruby -v ruby 3.4.0dev (2024-11-18T15:04:50Z :detached: 4a7ac694e5) +PRISM [x86_64-linux] $ irb -w ... snip ... irb(main):001> require 'net/http' => true irb(main):002> Net.send(:remove_const, :HTTPSession) (irb):2:in 'Module#remove_const': constant Net::HTTPSession not defined (NameError) from (irb):2:in '<main>' from <internal:kernel>:168:in 'Kernel#loop' from /home/yahonda/.rbenv/versions/trunk/lib/ruby/gems/3.4.0+1/gems/irb-1.14.1/exe/irb:9:in '<top (required)>' from /home/yahonda/.rbenv/versions/trunk/bin/irb:25:in 'Kernel#load' from /home/yahonda/.rbenv/versions/trunk/bin/irb:25:in '<main>' irb(main):003> ``` ### Steps to reproduce Here are the steps to see if the warnings are emitted against Ruby 3.3. $ ruby -v ruby 3.3.6 (2024-11-05 revision 75015d4c1f) [x86_64-linux] $ irb -w ``` require 'net/http' Net::HTTPSession Net.send(:remove_const, :HTTPSession) ``` ### Expected behavior Both of `Net::HTTPSession` and `Net.send(:remove_const, :HTTPSession)` should emit the `warning: constant Net::HTTPSession is deprecated` . ### Actual behavior Only `Net::HTTPSession` emits the warnings. `Net.send(:remove_const, :HTTPSession)` does not emit any warnings. ``` $ irb -w irb(main):001> require 'net/http' irb(main):002> => true irb(main):003> Net::HTTPSession (irb):3: warning: constant Net::HTTPSession is deprecated => Net::HTTP irb(main):004> Net.send(:remove_const, :HTTPSession) => Net::HTTP irb(main):005> ``` -- https://bugs.ruby-lang.org/

Issue #20900 has been updated by yahonda (Yasuo Honda). I wish the `:remove_const` should also emit the warnings so that at least WebMock users can be aware of this change. ---------------------------------------- Bug #20900: Net.send(:remove_const, :HTTPSession) does not emit warnings https://bugs.ruby-lang.org/issues/20900#change-110690 * Author: yahonda (Yasuo Honda) * Status: Open * ruby -v: ruby 3.3.6 (2024-11-05 revision 75015d4c1f) [x86_64-linux] * Backport: 3.1: UNKNOWN, 3.2: UNKNOWN, 3.3: UNKNOWN ---------------------------------------- After https://github.com/ruby/net-http/pull/189 has been merged and cherry-picked to Ruby master branch, `Net.send(:remove_const, :HTTPSession)` gets the NameError. This code should emit warnings against Ruby 3.3 or earlier versions of Ruby but actually it does not. ``` $ ruby -v ruby 3.4.0dev (2024-11-18T15:04:50Z :detached: 4a7ac694e5) +PRISM [x86_64-linux] $ irb -w ... snip ... irb(main):001> require 'net/http' => true irb(main):002> Net.send(:remove_const, :HTTPSession) (irb):2:in 'Module#remove_const': constant Net::HTTPSession not defined (NameError) from (irb):2:in '<main>' from <internal:kernel>:168:in 'Kernel#loop' from /home/yahonda/.rbenv/versions/trunk/lib/ruby/gems/3.4.0+1/gems/irb-1.14.1/exe/irb:9:in '<top (required)>' from /home/yahonda/.rbenv/versions/trunk/bin/irb:25:in 'Kernel#load' from /home/yahonda/.rbenv/versions/trunk/bin/irb:25:in '<main>' irb(main):003> ``` ### Steps to reproduce Here are the steps to see if the warnings are emitted against Ruby 3.3. $ ruby -v ruby 3.3.6 (2024-11-05 revision 75015d4c1f) [x86_64-linux] $ irb -w ``` require 'net/http' Net::HTTPSession Net.send(:remove_const, :HTTPSession) ``` ### Expected behavior Both of `Net::HTTPSession` and `Net.send(:remove_const, :HTTPSession)` should emit the `warning: constant Net::HTTPSession is deprecated` . ### Actual behavior Only `Net::HTTPSession` emits the warnings. `Net.send(:remove_const, :HTTPSession)` does not emit any warnings. ``` $ irb -w irb(main):001> require 'net/http' irb(main):002> => true irb(main):003> Net::HTTPSession (irb):3: warning: constant Net::HTTPSession is deprecated => Net::HTTP irb(main):004> Net.send(:remove_const, :HTTPSession) => Net::HTTP irb(main):005> ``` -- https://bugs.ruby-lang.org/

Issue #20900 has been updated by hsbt (Hiroshi SHIBATA). I restore `HTTPSession` at https://github.com/ruby/net-http/pull/191 ---------------------------------------- Bug #20900: Net.send(:remove_const, :HTTPSession) does not emit warnings https://bugs.ruby-lang.org/issues/20900#change-110691 * Author: yahonda (Yasuo Honda) * Status: Open * ruby -v: ruby 3.3.6 (2024-11-05 revision 75015d4c1f) [x86_64-linux] * Backport: 3.1: UNKNOWN, 3.2: UNKNOWN, 3.3: UNKNOWN ---------------------------------------- After https://github.com/ruby/net-http/pull/189 has been merged and cherry-picked to Ruby master branch, `Net.send(:remove_const, :HTTPSession)` gets the NameError. This code should emit warnings against Ruby 3.3 or earlier versions of Ruby but actually it does not. ``` $ ruby -v ruby 3.4.0dev (2024-11-18T15:04:50Z :detached: 4a7ac694e5) +PRISM [x86_64-linux] $ irb -w ... snip ... irb(main):001> require 'net/http' => true irb(main):002> Net.send(:remove_const, :HTTPSession) (irb):2:in 'Module#remove_const': constant Net::HTTPSession not defined (NameError) from (irb):2:in '<main>' from <internal:kernel>:168:in 'Kernel#loop' from /home/yahonda/.rbenv/versions/trunk/lib/ruby/gems/3.4.0+1/gems/irb-1.14.1/exe/irb:9:in '<top (required)>' from /home/yahonda/.rbenv/versions/trunk/bin/irb:25:in 'Kernel#load' from /home/yahonda/.rbenv/versions/trunk/bin/irb:25:in '<main>' irb(main):003> ``` ### Steps to reproduce Here are the steps to see if the warnings are emitted against Ruby 3.3. $ ruby -v ruby 3.3.6 (2024-11-05 revision 75015d4c1f) [x86_64-linux] $ irb -w ``` require 'net/http' Net::HTTPSession Net.send(:remove_const, :HTTPSession) ``` ### Expected behavior Both of `Net::HTTPSession` and `Net.send(:remove_const, :HTTPSession)` should emit the `warning: constant Net::HTTPSession is deprecated` . ### Actual behavior Only `Net::HTTPSession` emits the warnings. `Net.send(:remove_const, :HTTPSession)` does not emit any warnings. ``` $ irb -w irb(main):001> require 'net/http' irb(main):002> => true irb(main):003> Net::HTTPSession (irb):3: warning: constant Net::HTTPSession is deprecated => Net::HTTP irb(main):004> Net.send(:remove_const, :HTTPSession) => Net::HTTP irb(main):005> ``` -- https://bugs.ruby-lang.org/

Issue #20900 has been updated by Earlopain (Earlopain _). I think warning on removal is a good thing. It makes compatibility code in webmock a bit more involved but that's totally fine. hsbt (Hiroshi SHIBATA) wrote in #note-2:
I restore `HTTPSession` at https://github.com/ruby/net-http/pull/191
You added it as `Net::HTTP::HTTPSession`, it used to be just `Net::HTTPSession`. ---------------------------------------- Bug #20900: Net.send(:remove_const, :HTTPSession) does not emit warnings https://bugs.ruby-lang.org/issues/20900#change-110701 * Author: yahonda (Yasuo Honda) * Status: Closed * ruby -v: ruby 3.3.6 (2024-11-05 revision 75015d4c1f) [x86_64-linux] * Backport: 3.1: UNKNOWN, 3.2: UNKNOWN, 3.3: UNKNOWN ---------------------------------------- After https://github.com/ruby/net-http/pull/189 has been merged and cherry-picked to Ruby master branch, `Net.send(:remove_const, :HTTPSession)` gets the NameError. This code should emit warnings against Ruby 3.3 or earlier versions of Ruby but actually it does not. ``` $ ruby -v ruby 3.4.0dev (2024-11-18T15:04:50Z :detached: 4a7ac694e5) +PRISM [x86_64-linux] $ irb -w ... snip ... irb(main):001> require 'net/http' => true irb(main):002> Net.send(:remove_const, :HTTPSession) (irb):2:in 'Module#remove_const': constant Net::HTTPSession not defined (NameError) from (irb):2:in '<main>' from <internal:kernel>:168:in 'Kernel#loop' from /home/yahonda/.rbenv/versions/trunk/lib/ruby/gems/3.4.0+1/gems/irb-1.14.1/exe/irb:9:in '<top (required)>' from /home/yahonda/.rbenv/versions/trunk/bin/irb:25:in 'Kernel#load' from /home/yahonda/.rbenv/versions/trunk/bin/irb:25:in '<main>' irb(main):003> ``` ### Steps to reproduce Here are the steps to see if the warnings are emitted against Ruby 3.3. $ ruby -v ruby 3.3.6 (2024-11-05 revision 75015d4c1f) [x86_64-linux] $ irb -w ``` require 'net/http' Net::HTTPSession Net.send(:remove_const, :HTTPSession) ``` ### Expected behavior Both of `Net::HTTPSession` and `Net.send(:remove_const, :HTTPSession)` should emit the `warning: constant Net::HTTPSession is deprecated` . ### Actual behavior Only `Net::HTTPSession` emits the warnings. `Net.send(:remove_const, :HTTPSession)` does not emit any warnings. ``` $ irb -w irb(main):001> require 'net/http' irb(main):002> => true irb(main):003> Net::HTTPSession (irb):3: warning: constant Net::HTTPSession is deprecated => Net::HTTP irb(main):004> Net.send(:remove_const, :HTTPSession) => Net::HTTP irb(main):005> ``` -- https://bugs.ruby-lang.org/

Issue #20900 has been updated by hsbt (Hiroshi SHIBATA).
You added it as Net::HTTP::HTTPSession, it used to be just Net::HTTPSession.
I fixed that at https://github.com/ruby/ruby/commit/716ea630dbd6cea62049a7a438d7d4f4f84d4aae ---------------------------------------- Bug #20900: Net.send(:remove_const, :HTTPSession) does not emit warnings https://bugs.ruby-lang.org/issues/20900#change-110702 * Author: yahonda (Yasuo Honda) * Status: Closed * ruby -v: ruby 3.3.6 (2024-11-05 revision 75015d4c1f) [x86_64-linux] * Backport: 3.1: UNKNOWN, 3.2: UNKNOWN, 3.3: UNKNOWN ---------------------------------------- After https://github.com/ruby/net-http/pull/189 has been merged and cherry-picked to Ruby master branch, `Net.send(:remove_const, :HTTPSession)` gets the NameError. This code should emit warnings against Ruby 3.3 or earlier versions of Ruby but actually it does not. ``` $ ruby -v ruby 3.4.0dev (2024-11-18T15:04:50Z :detached: 4a7ac694e5) +PRISM [x86_64-linux] $ irb -w ... snip ... irb(main):001> require 'net/http' => true irb(main):002> Net.send(:remove_const, :HTTPSession) (irb):2:in 'Module#remove_const': constant Net::HTTPSession not defined (NameError) from (irb):2:in '<main>' from <internal:kernel>:168:in 'Kernel#loop' from /home/yahonda/.rbenv/versions/trunk/lib/ruby/gems/3.4.0+1/gems/irb-1.14.1/exe/irb:9:in '<top (required)>' from /home/yahonda/.rbenv/versions/trunk/bin/irb:25:in 'Kernel#load' from /home/yahonda/.rbenv/versions/trunk/bin/irb:25:in '<main>' irb(main):003> ``` ### Steps to reproduce Here are the steps to see if the warnings are emitted against Ruby 3.3. $ ruby -v ruby 3.3.6 (2024-11-05 revision 75015d4c1f) [x86_64-linux] $ irb -w ``` require 'net/http' Net::HTTPSession Net.send(:remove_const, :HTTPSession) ``` ### Expected behavior Both of `Net::HTTPSession` and `Net.send(:remove_const, :HTTPSession)` should emit the `warning: constant Net::HTTPSession is deprecated` . ### Actual behavior Only `Net::HTTPSession` emits the warnings. `Net.send(:remove_const, :HTTPSession)` does not emit any warnings. ``` $ irb -w irb(main):001> require 'net/http' irb(main):002> => true irb(main):003> Net::HTTPSession (irb):3: warning: constant Net::HTTPSession is deprecated => Net::HTTP irb(main):004> Net.send(:remove_const, :HTTPSession) => Net::HTTP irb(main):005> ``` -- https://bugs.ruby-lang.org/

Issue #20900 has been updated by Earlopain (Earlopain _). hsbt (Hiroshi SHIBATA) wrote in #note-5:
You added it as Net::HTTP::HTTPSession, it used to be just Net::HTTPSession.
I fixed that at https://github.com/ruby/ruby/commit/716ea630dbd6cea62049a7a438d7d4f4f84d4aae
Thanks! ---------------------------------------- Bug #20900: Net.send(:remove_const, :HTTPSession) does not emit warnings https://bugs.ruby-lang.org/issues/20900#change-110703 * Author: yahonda (Yasuo Honda) * Status: Closed * ruby -v: ruby 3.3.6 (2024-11-05 revision 75015d4c1f) [x86_64-linux] * Backport: 3.1: UNKNOWN, 3.2: UNKNOWN, 3.3: UNKNOWN ---------------------------------------- After https://github.com/ruby/net-http/pull/189 has been merged and cherry-picked to Ruby master branch, `Net.send(:remove_const, :HTTPSession)` gets the NameError. This code should emit warnings against Ruby 3.3 or earlier versions of Ruby but actually it does not. ``` $ ruby -v ruby 3.4.0dev (2024-11-18T15:04:50Z :detached: 4a7ac694e5) +PRISM [x86_64-linux] $ irb -w ... snip ... irb(main):001> require 'net/http' => true irb(main):002> Net.send(:remove_const, :HTTPSession) (irb):2:in 'Module#remove_const': constant Net::HTTPSession not defined (NameError) from (irb):2:in '<main>' from <internal:kernel>:168:in 'Kernel#loop' from /home/yahonda/.rbenv/versions/trunk/lib/ruby/gems/3.4.0+1/gems/irb-1.14.1/exe/irb:9:in '<top (required)>' from /home/yahonda/.rbenv/versions/trunk/bin/irb:25:in 'Kernel#load' from /home/yahonda/.rbenv/versions/trunk/bin/irb:25:in '<main>' irb(main):003> ``` ### Steps to reproduce Here are the steps to see if the warnings are emitted against Ruby 3.3. $ ruby -v ruby 3.3.6 (2024-11-05 revision 75015d4c1f) [x86_64-linux] $ irb -w ``` require 'net/http' Net::HTTPSession Net.send(:remove_const, :HTTPSession) ``` ### Expected behavior Both of `Net::HTTPSession` and `Net.send(:remove_const, :HTTPSession)` should emit the `warning: constant Net::HTTPSession is deprecated` . ### Actual behavior Only `Net::HTTPSession` emits the warnings. `Net.send(:remove_const, :HTTPSession)` does not emit any warnings. ``` $ irb -w irb(main):001> require 'net/http' irb(main):002> => true irb(main):003> Net::HTTPSession (irb):3: warning: constant Net::HTTPSession is deprecated => Net::HTTP irb(main):004> Net.send(:remove_const, :HTTPSession) => Net::HTTP irb(main):005> ``` -- https://bugs.ruby-lang.org/
participants (3)
-
Earlopain (Earlopain _)
-
hsbt (Hiroshi SHIBATA)
-
yahonda (Yasuo Honda)