Project

General

Profile

Actions

Bug #20900

closed

Net.send(:remove_const, :HTTPSession) does not emit warnings

Added by yahonda (Yasuo Honda) 15 days ago. Updated 15 days ago.

Status:
Closed
Assignee:
-
Target version:
-
ruby -v:
ruby 3.3.6 (2024-11-05 revision 75015d4c1f) [x86_64-linux]
[ruby-core:119958]

Description

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>
Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0