Skip to content

The taint mechanism was deprecated in Ruby 2.7#7

Merged
kyrylo merged 3 commits intokyrylo:masterfrom
BrianHawley:fixes_6
Jan 21, 2020
Merged

The taint mechanism was deprecated in Ruby 2.7#7
kyrylo merged 3 commits intokyrylo:masterfrom
BrianHawley:fixes_6

Conversation

@BrianHawley
Copy link
Copy Markdown
Contributor

@BrianHawley BrianHawley commented Jan 19, 2020

The Ruby core team decided to deprecate the taint mechanism in Ruby 2.7
and will remove that in Ruby 3.

https://bugs.ruby-lang.org/issues/16131
ruby/ruby#2476

In Ruby 2.7, Object#{taint,untaint,trust,untrust} and related
functions in the C-API no longer have an effect (all objects are always
considered untainted), and are now warned with deprecation messages.

The format of Proc inspect has changed too. Adjusted the affected test.

[Fixes #6]

@BrianHawley BrianHawley requested a review from kyrylo January 19, 2020 03:22
@BrianHawley BrianHawley force-pushed the fixes_6 branch 2 times, most recently from 0b18b0a to bef1114 Compare January 19, 2020 21:42
@BrianHawley
Copy link
Copy Markdown
Contributor Author

You could drop the required Ruby version back to 1.8.7 if you liked, with these changes.

The Ruby core team decided to deprecate the taint mechanism in Ruby 2.7
and will remove that in Ruby 3.

https://bugs.ruby-lang.org/issues/16131
ruby/ruby#2476

In Ruby 2.7, `Object#{taint,untaint,trust,untrust}` and related
functions in the C-API no longer have an effect (all objects are always
considered untainted), and are now warned with deprecation messages.

The format of Proc inspect has changed too. Adjusted the affected test.

[Fixes kyrylo#6]
Restores the functionality removed in kyrylo#3 in a way that's compatible
with the newer Ruby versions.
- Newer Ruby is more picky about datatypes.
- Make RBTREE(rbtree) do the type conversion, like RARRAY and such do.
- Use Data_Make_Struct instead of doing the same thing that it used to
  do, because newer Ruby versions do things slightly differently and
  we want to be compatible with MJIT and compaction GC eventually.
- Don't make assumptions about the headers before checking.
- Fixed the one test that wasn't entirely 1.8.7 compatible.
Comment thread .circleci/config.yml
- <<: *unit
"ruby-2.7":
docker:
- image: circleci/ruby:2.7.0
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Not sure we want to specify exactly 2.7.0. We used to skip TEENY version, so that if Circle updates their image, we don't need to update the code to test against the latest version.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Circleci has no 2.7 tag. The only tag they have is 2.7.0. I checked.

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Thanks for checking!

@kyrylo
Copy link
Copy Markdown
Owner

kyrylo commented Jan 21, 2020

Woah, this is amazing! 💯
Thanks so much for handling all of these issues.
I didn't even know about them (taint deprecation).

P.S. I don't think Ruby 1.8 compatibility is important anymore but if it's nearly for free, then why not?

@BrianHawley
Copy link
Copy Markdown
Contributor Author

BrianHawley commented Jan 21, 2020

We have a tool that is still on 1.8.7, and won't be updated because it's in maintenance mode. If I can do 1.8.7 for free, I don't see why not. We don't need more encouragement to upgrade stuff than we have already. Our code was compatible with 2.7 within a week of release.

@kyrylo kyrylo merged commit dbdf6aa into kyrylo:master Jan 21, 2020
@kyrylo
Copy link
Copy Markdown
Owner

kyrylo commented Jan 21, 2020

Agreed 👍

@BrianHawley
Copy link
Copy Markdown
Contributor Author

For that matter, while this code restores the Hash compatibility, it's only compatible with the 1.8.7 Hash API. I'll look into increasing the API coverage later, especially for the 2.5+ compatible additions.

@kyrylo
Copy link
Copy Markdown
Owner

kyrylo commented Jan 21, 2020

Sorry, what kind of incompatibility are we talking about? The tests that you added pass on all Rubies. Are we talking about default_proc?

@BrianHawley
Copy link
Copy Markdown
Contributor Author

BrianHawley commented Jan 21, 2020

Yes, it restored that default_proc thing that you deleted in #3; I even copied the test from the previous version. But as for the rest, it's just missing methods that were added in Ruby versions since 2009 :)

@kyrylo
Copy link
Copy Markdown
Owner

kyrylo commented Jan 21, 2020

Ah, yeah, I understand now. Is this really a big deal, though? It'll always be a losing battle because we would need to keep an eye on the Hash class every time Ruby releases. As for me, I can guarantee that I will forget to check that when Ruby 2.8/3.0 gets released.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Ruby 2.7 warning in rbtree_modify

2 participants