Skip to content

Commit

Permalink
[GR-45621] Remove C-functions related to the taint feature
Browse files Browse the repository at this point in the history
PullRequest: truffleruby/4256
  • Loading branch information
andrykonchin committed Apr 26, 2024
2 parents cc2d014 + d5782a1 commit 2651959
Show file tree
Hide file tree
Showing 8 changed files with 67 additions and 21 deletions.
2 changes: 1 addition & 1 deletion lib/cext/include/truffleruby/truffleruby-abi-version.h
Expand Up @@ -20,6 +20,6 @@
// $RUBY_VERSION must be the same as TruffleRuby.LANGUAGE_VERSION.
// $ABI_NUMBER starts at 1 and is incremented for every ABI-incompatible change.

#define TRUFFLERUBY_ABI_VERSION "3.2.2.12"
#define TRUFFLERUBY_ABI_VERSION "3.2.2.13"

#endif
28 changes: 28 additions & 0 deletions spec/ruby/core/module/include_spec.rb
Expand Up @@ -47,6 +47,34 @@ def self.append_features(mod)
-> { ModuleSpecs::SubclassSpec.include(ModuleSpecs::Subclass.new) }.should_not raise_error(TypeError)
end

ruby_version_is ""..."3.2" do
it "raises ArgumentError when the argument is a refinement" do
refinement = nil

Module.new do
refine String do
refinement = self
end
end

-> { ModuleSpecs::Basic.include(refinement) }.should raise_error(ArgumentError, "refinement module is not allowed")
end
end

ruby_version_is "3.2" do
it "raises a TypeError when the argument is a refinement" do
refinement = nil

Module.new do
refine String do
refinement = self
end
end

-> { ModuleSpecs::Basic.include(refinement) }.should raise_error(TypeError, "Cannot include refinement")
end
end

it "imports constants to modules and classes" do
ModuleSpecs::A.constants.should include(:CONSTANT_A)
ModuleSpecs::B.constants.should include(:CONSTANT_A, :CONSTANT_B)
Expand Down
28 changes: 28 additions & 0 deletions spec/ruby/core/module/prepend_spec.rb
Expand Up @@ -435,6 +435,34 @@ module M
-> { ModuleSpecs::SubclassSpec.prepend(ModuleSpecs::Subclass.new) }.should_not raise_error(TypeError)
end

ruby_version_is ""..."3.2" do
it "raises ArgumentError when the argument is a refinement" do
refinement = nil

Module.new do
refine String do
refinement = self
end
end

-> { ModuleSpecs::Basic.prepend(refinement) }.should raise_error(ArgumentError, "refinement module is not allowed")
end
end

ruby_version_is "3.2" do
it "raises a TypeError when the argument is a refinement" do
refinement = nil

Module.new do
refine String do
refinement = self
end
end

-> { ModuleSpecs::Basic.prepend(refinement) }.should raise_error(TypeError, "Cannot prepend refinement")
end
end

it "imports constants" do
m1 = Module.new
m1::MY_CONSTANT = 1
Expand Down
1 change: 0 additions & 1 deletion spec/tags/core/refinement/include_tags.txt

This file was deleted.

1 change: 0 additions & 1 deletion spec/tags/core/refinement/prepend_tags.txt

This file was deleted.

6 changes: 0 additions & 6 deletions src/main/c/cext/globals.c
Expand Up @@ -76,12 +76,6 @@ VALUE rb_gv_get(const char *name) {
return RUBY_CEXT_INVOKE("rb_gv_get", rb_str_new_cstr(name));
}

// $SAFE

void rb_check_trusted(VALUE obj) {
rb_warning("rb_check_trusted is deprecated and will be removed in Ruby 3.2.");
}

// $VERBOSE

VALUE rb_tr_ruby_verbose_ptr;
Expand Down
10 changes: 0 additions & 10 deletions src/main/c/cext/string.c
Expand Up @@ -72,11 +72,6 @@ VALUE rb_str_new_static(const char *string, long length) {
return rb_str_new(string, length);
}

VALUE rb_tainted_str_new(const char *ptr, long len) {
rb_warning("rb_tainted_str_new is deprecated and will be removed in Ruby 3.2.");
return rb_str_new(ptr, len);
}

VALUE rb_str_new_cstr(const char *string) {
// TODO CS 24-Oct-17 would be nice to read in one go rather than strlen followed by read
size_t len = strlen(string);
Expand All @@ -91,11 +86,6 @@ VALUE rb_str_new_with_class(VALUE str, const char *string, long len) {
return RUBY_INVOKE(RUBY_INVOKE(str, "class"), "new", rb_str_new(string, len));
}

VALUE rb_tainted_str_new_cstr(const char *ptr) {
rb_warning("rb_tainted_str_new_cstr is deprecated and will be removed in Ruby 3.2.");
return rb_str_new_cstr(ptr);
}

VALUE rb_str_dup(VALUE string) {
return rb_obj_dup(string);
}
Expand Down
12 changes: 10 additions & 2 deletions src/main/ruby/truffleruby/core/module.rb
Expand Up @@ -79,13 +79,17 @@ def include?(mod)
def include(*modules)
raise ArgumentError, 'wrong number of arguments (given 0, expected 1+)' if modules.empty?
if Primitive.is_a?(self, Refinement)
warn 'Refinement#include is deprecated and will be removed in Ruby 3.2', category: :deprecated, uplevel: 1
raise TypeError, 'Refinement#include has been removed'
end
modules.reverse_each do |mod|
if !Primitive.is_a?(mod, Module) or Primitive.is_a?(mod, Class)
raise TypeError, "wrong argument type #{Primitive.class(mod)} (expected Module)"
end

if Primitive.is_a?(mod, Refinement)
raise TypeError, 'Cannot include refinement'
end

mod.__send__ :append_features, self
mod.__send__ :included, self
end
Expand All @@ -95,13 +99,17 @@ def include(*modules)
def prepend(*modules)
raise ArgumentError, 'wrong number of arguments (given 0, expected 1+)' if modules.empty?
if Primitive.is_a?(self, Refinement)
warn 'Refinement#prepend is deprecated and will be removed in Ruby 3.2', category: :deprecated, uplevel: 1
raise TypeError, 'Refinement#prepend has been removed'
end
modules.reverse_each do |mod|
if !Primitive.is_a?(mod, Module) or Primitive.is_a?(mod, Class)
raise TypeError, "wrong argument type #{Primitive.class(mod)} (expected Module)"
end

if Primitive.is_a?(mod, Refinement)
raise TypeError, 'Cannot prepend refinement'
end

mod.__send__ :prepend_features, self
mod.__send__ :prepended, self
end
Expand Down

0 comments on commit 2651959

Please sign in to comment.