Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Delete or warn deprecated (rev.3) #3424

Open
wants to merge 16 commits into
base: master
Choose a base branch
from

Conversation

shyouhei
Copy link
Member

@shyouhei shyouhei commented Aug 17, 2020

Revised #3412

Feature Warned (without -w) since This pull request
Hash#index 1.9.0 Deletes it
IO#bytes 2.0.0 Deletes it
Enumerator.new without a block 2.0.0 Deletes it
Thread.exclusive 2.3.0 Deletes it
Data 2.5.0 Deletes it
Struct::Tms 2.6.0 Deletes it
Object#=~ 2.7.0 Deletes it
Dir.exists? 2.8.0 Knells for 3.2
FileTest.exists? 2.8.0 Knells for 3.1
$,,$/,$\,$; 2.8.0 Knells for 3.1
lambda(&variable) 2.8.0 Knells for 3.1

Suggest and removal can both be useful at the same time.
Has been deprecated since 22a9613.
Has been deprecated since 058d55a.
Has been deprecated since 0c97c8e.
Has been deprecated since 373282f.
This commit deletes
{IO,ARGF,StringIO,Zib::GZipReader}#{bytes,chars,lines,codepoints}, which
have been deprecated since c47c095.

Note that String also has those methods.  They are neither depreacted
nor deleted because they are not aliases of counterpart each_something.
Has been deprecated since ebff9dc.
Has been deprecated since 684bdf6.

Matz says in [ruby-core:83954] that Data should be an alias of Object.
Because rb_cData has not been deprecated, let us deprecate the constant
to make it a C-level synonym of rb_cObject.
Has been deprecated since 2069c9e.
Has been deprecated since 44c53ee.
Has been deprecated since c73b6bd.
[Feature #17116] [ruby-dev:50945]
Has been deprecated since 2188d6d.
Has been deprecated since 4d1f86a.
Proper annotation of when to remove a feature helps us a lot ("don't
delete it now" sign), but can rarely be useful to end users.  Let's just
use the info internally.
@@ -7641,7 +7587,7 @@ deprecated_str_setter(VALUE val, ID id, VALUE *var)
{
rb_str_setter(val, id, &val);
if (!NIL_P(val)) {
rb_warn_deprecated("`%s'", NULL, rb_id2name(id));
rb_warn_deprecated_to_remove("`%s'", "3.1", rb_id2name(id));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be rb_warn_deprecated_to_remove_use_this_one_instead

Copy link
Contributor

@jeremyevans jeremyevans left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like the bundled gems tests error because power_assert uses pry and pry relies on Object#=~, so that will have to be fixed before this can be merged.

The changes look fine to me. rb_warn_deprecated_to_remove_use_this_one_instead is quite long, and I'm not sure in which case it should be used instead of rb_warn_deprecated_to_remove.

@shyouhei
Copy link
Member Author

@jeremyevans Yes, the test-bundled-gems issue is pry/pry#2149 (merged). Am waiting for their release.

@sandstrom
Copy link

Awesome to see cleanups and deprecations for Ruby 3.0! 🎉

@marcandre
Copy link
Member

marcandre commented Dec 1, 2020

Aren't many of these methods still not warning (without -w)?

$ ruby -e 'puts({ok: 1}.index(1))'
ok
$ ruby -e 'Enumerator.new(42); p :ok'
:ok
$ ruby -e 'Object.new =~ 42; p :ok'
:ok

(with 2.7.2p137 or ruby-head)

@jeremyevans
Copy link
Contributor

Aren't many of these methods still not warning (without -w)?

$ ruby -e 'puts({ok: 1}.index(1))'
ok
$ ruby -e 'Enumerator.new(42); p :ok'
:ok
$ ruby -e 'Object.new =~ 42; p :ok'
:ok

(with 2.7.2p137 or ruby-head)

That's due to a different change in Ruby 2.7.2 to not display any deprecation warnings by default. The warnings show up with -W:deprecated:

$ ruby -W:deprecated -e 'puts({ok: 1}.index(1))'
-e:1: warning: Hash#index is deprecated; use Hash#key instead
ok
$ ruby -W:deprecated -e 'Enumerator.new(42); p :ok'
-e:1: warning: Enumerator.new without a block is deprecated; use Object#to_enum instead
:ok
$ ruby -W:deprecated -e 'Object.new =~ 42; p :ok'
-e:1: warning: deprecated Object#=~ is called on Object; it always returns nil
:ok

@marcandre
Copy link
Member

That's due to a different change in Ruby 2.7.2 to not display any deprecation warnings by default.

Ah, right, I forgot about this, thanks 🤦‍♂️

@nobu
Copy link
Member

nobu commented Dec 2, 2020

As now we suppress deprecation warnings by default, does non-verbose warning period really makes sense?

@@ -3345,7 +3345,7 @@ rb_file_directory_p(void)
static VALUE
rb_dir_exists_p(VALUE obj, VALUE fname)
{
rb_warn_deprecated("Dir.exists?", "Dir.exist?");
rb_warn_deprecated_to_remove_use_this_one_instead("Dir.exists?", "3.2", "Dir.exist?");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is only this 3.2?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nobu Read #3412 discussion.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I should have asked about FileTest.exists? in the table at this page.
As that method is to be removed at 3.2 in the code, just the table is outdated a little?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I missed that the table updated in rev. 2...

nobu
nobu approved these changes Dec 26, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
6 participants