From: "Earlopain (Earlopain _) via ruby-core" Date: 2024-11-19T09:03:25+00:00 Subject: [ruby-core:119965] [Ruby master Bug#20900] Net.send(:remove_const, :HTTPSession) does not emit warnings 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 '
' from :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 '' from /home/yahonda/.rbenv/versions/trunk/bin/irb:25:in 'Kernel#load' from /home/yahonda/.rbenv/versions/trunk/bin/irb:25:in '
' 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/ ______________________________________________ ruby-core mailing list -- ruby-core@ml.ruby-lang.org To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org ruby-core info -- https://ml.ruby-lang.org/mailman3/lists/ruby-core.ml.ruby-lang.org/