Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -185,13 +185,13 @@ They are still available on rubygems.org and can be installed with
### The following default gems are updated.

* RubyGems 4.1.0.beta1
* 4.0.3 to [v4.0.4][RubyGems-v4.0.4], [v4.0.5][RubyGems-v4.0.5], [v4.0.6][RubyGems-v4.0.6], [v4.0.7][RubyGems-v4.0.7], [v4.0.8][RubyGems-v4.0.8], [v4.0.9][RubyGems-v4.0.9], [v4.0.10][RubyGems-v4.0.10], [v4.0.11][RubyGems-v4.0.11], [v4.0.12][RubyGems-v4.0.12], [v4.0.13][RubyGems-v4.0.13], [v4.0.14][RubyGems-v4.0.14], [v4.0.15][RubyGems-v4.0.15], [v4.0.16][RubyGems-v4.0.16], [v4.0.17][RubyGems-v4.0.17], [v4.0.18][RubyGems-v4.0.18], [v4.0.19][RubyGems-v4.0.19], [v4.0.20][RubyGems-v4.0.20], [v4.1.0.beta1][RubyGems-v4.1.0.beta1]
* 4.0.3 to [v4.0.4][RubyGems-v4.0.4], [v4.0.5][RubyGems-v4.0.5], [v4.0.6][RubyGems-v4.0.6], [v4.0.7][RubyGems-v4.0.7], [v4.0.8][RubyGems-v4.0.8], [v4.0.9][RubyGems-v4.0.9], [v4.0.10][RubyGems-v4.0.10], [v4.0.11][RubyGems-v4.0.11], [v4.0.12][RubyGems-v4.0.12], [v4.0.13][RubyGems-v4.0.13], [v4.0.14][RubyGems-v4.0.14], [v4.0.15][RubyGems-v4.0.15], [v4.0.16][RubyGems-v4.0.16], [v4.0.17][RubyGems-v4.0.17], [v4.0.18][RubyGems-v4.0.18], [v4.0.19][RubyGems-v4.0.19], [v4.0.20][RubyGems-v4.0.20], [v4.0.21][RubyGems-v4.0.21], [v4.1.0.beta1][RubyGems-v4.1.0.beta1]
* bundler 4.1.0.beta1
* 4.0.3 to [v4.0.4][bundler-v4.0.4], [v4.0.5][bundler-v4.0.5], [v4.0.6][bundler-v4.0.6], [v4.0.7][bundler-v4.0.7], [v4.0.8][bundler-v4.0.8], [v4.0.9][bundler-v4.0.9], [v4.0.10][bundler-v4.0.10], [v4.0.11][bundler-v4.0.11], [v4.0.12][bundler-v4.0.12], [v4.0.13][bundler-v4.0.13], [v4.0.14][bundler-v4.0.14], [v4.0.15][bundler-v4.0.15], [v4.0.16][bundler-v4.0.16], [v4.0.17][bundler-v4.0.17]
* erb 6.0.7
* 6.0.1 to [v6.0.1.1][erb-v6.0.1.1], [v6.0.2][erb-v6.0.2], [v6.0.3][erb-v6.0.3], [v6.0.4][erb-v6.0.4], [v6.0.5][erb-v6.0.5], [v6.0.6][erb-v6.0.6], [v6.0.7][erb-v6.0.7]
* error_highlight 0.7.2
* io-console 0.9.2
* io-console 0.9.3
* 0.8.2 to [v0.9.0][io-console-v0.9.0], [v0.9.1][io-console-v0.9.1], [v0.9.2][io-console-v0.9.2]
* io-wait 999.999.999
* ipaddr 1.2.9
Expand All @@ -208,7 +208,7 @@ They are still available on rubygems.org and can be installed with
* 1.7.0 to [v1.8.0][prism-v1.8.0], [v1.8.1][prism-v1.8.1], [v1.9.0][prism-v1.9.0]
* psych 5.5.0
* 5.3.1 to [v5.4.0][psych-v5.4.0], [v5.5.0][psych-v5.5.0]
* resolv 0.7.1
* resolv 0.7.2
* 0.7.0 to [v0.7.1][resolv-v0.7.1]
* stringio 3.2.1.dev
* strscan 3.1.9.dev
Expand Down Expand Up @@ -510,6 +510,7 @@ A lot of work has gone into making Ractors more stable, performant, and usable.
[RubyGems-v4.0.18]: https://github.com/rubygems/rubygems/releases/tag/v4.0.18
[RubyGems-v4.0.19]: https://github.com/rubygems/rubygems/releases/tag/v4.0.19
[RubyGems-v4.0.20]: https://github.com/rubygems/rubygems/releases/tag/v4.0.20
[RubyGems-v4.0.21]: https://github.com/rubygems/rubygems/releases/tag/v4.0.21
[RubyGems-v4.1.0.beta1]: https://github.com/rubygems/rubygems/releases/tag/v4.1.0.beta1
[bundler-v4.0.4]: https://github.com/rubygems/rubygems/releases/tag/bundler-v4.0.4
[bundler-v4.0.5]: https://github.com/rubygems/rubygems/releases/tag/bundler-v4.0.5
Expand Down
2 changes: 1 addition & 1 deletion array.c
Original file line number Diff line number Diff line change
Expand Up @@ -4844,7 +4844,7 @@ rb_ary_zip(int argc, VALUE *argv, VALUE ary)
else {
result = rb_ary_new_capa(len);

for (i=0; i<len; i++) {
for (i=0; i<RARRAY_LEN(ary); i++) {
VALUE tmp = rb_ary_new_capa(argc+1);

rb_ary_push(tmp, RARRAY_AREF(ary, i));
Expand Down
2 changes: 1 addition & 1 deletion doc/stringio/gets.rdoc
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ The position need not be at a character boundary:
<b>Special Record Separators</b>

Like some methods in class IO, method +gets+ honors two special record separators;
see {Special Line Separators}[https://docs.ruby-lang.org/en/master/IO.html#class-IO-label-Special+Line+Separator+Values]:
see {Special Line Separators}[rdoc-ref:IO@Special+Line+Separator+Values]:

strio = StringIO.new(TEXT)
strio.gets('') # Read "paragraph" (up to empty line).
Expand Down
2 changes: 1 addition & 1 deletion ext/io/console/console.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*/

static const char *const
IO_CONSOLE_VERSION = "0.9.2";
IO_CONSOLE_VERSION = "0.9.3";

#include "ruby.h"
#include "ruby/io.h"
Expand Down
4 changes: 2 additions & 2 deletions ext/io/console/extconf.rb
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,11 @@
console.#$OBJEXT: $(VK_HEADER)
MK
end
if vk_tool
if vk_tool and vk_mk = (File.read("#$srcdir/win32_vk.mk") rescue nil)
unless conf.any? {|c| /^ *top_srcdir *=/.match?(c)}
conf << "top_srcdir = $(srcdir)/../../..\n"
end
conf.concat(depend_rules(File.read("#$srcdir/win32_vk.mk")))
conf.concat(depend_rules(vk_mk))
end
conf
}
Expand Down
2 changes: 1 addition & 1 deletion lib/resolv.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
class Resolv

# The version string
VERSION = "0.7.1"
VERSION = "0.7.2"

##
# Looks up the first IP address for +name+.
Expand Down
3 changes: 3 additions & 0 deletions proc.c
Original file line number Diff line number Diff line change
Expand Up @@ -4090,6 +4090,9 @@ method_inspect(VALUE method)
}
else {
mklass = data->klass;
if (RB_TYPE_P(mklass, T_ICLASS)) {
mklass = RBASIC_CLASS(mklass);
}
if (RCLASS_SINGLETON_P(mklass)) {
VALUE v = RCLASS_ATTACHED_OBJECT(mklass);
if (!(RB_TYPE_P(v, T_CLASS) || RB_TYPE_P(v, T_MODULE))) {
Expand Down
3 changes: 1 addition & 2 deletions ruby.c
Original file line number Diff line number Diff line change
Expand Up @@ -898,7 +898,6 @@ moreswitches(const char *s, ruby_cmdline_options_t *opt, int envopt)
char **argv, *p;
const char *ap = 0;
VALUE argstr, argary;
void *ptr;

VALUE src_enc_name = opt->src.enc.name;
VALUE ext_enc_name = opt->ext.enc.name;
Expand Down Expand Up @@ -935,7 +934,7 @@ moreswitches(const char *s, ruby_cmdline_options_t *opt, int envopt)
rb_str_cat(argary, (char *)&ap, sizeof(ap));

VALUE ptr_obj;
argv = ptr = RB_ALLOCV_N(char *, ptr_obj, argc);
argv = RB_ALLOCV_N(char *, ptr_obj, argc);
MEMMOVE(argv, RSTRING_PTR(argary), char *, argc);

while ((i = proc_options(argc, argv, opt, envopt)) > 1 && envopt && (argc -= i) > 0) {
Expand Down
10 changes: 5 additions & 5 deletions spec/ruby/core/string/bit_clear_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,17 +34,17 @@
end

it "raises an IndexError for an out of range bit offset" do
-> { "\x00".bit_clear(8) }.should.raise(IndexError)
-> { "\x00".bit_clear(-1) }.should.raise(IndexError)
-> { (+"\x00").bit_clear(8) }.should.raise(IndexError)
-> { (+"\x00").bit_clear(-1) }.should.raise(IndexError)
end

it "raises an IndexError when a region extends past the end" do
-> { "\x00".bit_clear(0, 9) }.should.raise(IndexError)
-> { "\x00".bit_clear(0..8) }.should.raise(IndexError)
-> { (+"\x00").bit_clear(0, 9) }.should.raise(IndexError)
-> { (+"\x00").bit_clear(0..8) }.should.raise(IndexError)
end

it "raises an ArgumentError for a negative length" do
-> { "\x00".bit_clear(0, -1) }.should.raise(ArgumentError)
-> { (+"\x00").bit_clear(0, -1) }.should.raise(ArgumentError)
end

it "raises a FrozenError if self is frozen" do
Expand Down
10 changes: 5 additions & 5 deletions spec/ruby/core/string/bit_flip_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,17 +36,17 @@
end

it "raises an IndexError for an out of range bit offset" do
-> { "\x00".bit_flip(8) }.should.raise(IndexError)
-> { "\x00".bit_flip(-1) }.should.raise(IndexError)
-> { (+"\x00").bit_flip(8) }.should.raise(IndexError)
-> { (+"\x00").bit_flip(-1) }.should.raise(IndexError)
end

it "raises an IndexError when a region extends past the end" do
-> { "\x00".bit_flip(0, 9) }.should.raise(IndexError)
-> { "\x00".bit_flip(0..8) }.should.raise(IndexError)
-> { (+"\x00").bit_flip(0, 9) }.should.raise(IndexError)
-> { (+"\x00").bit_flip(0..8) }.should.raise(IndexError)
end

it "raises an ArgumentError for a negative length" do
-> { "\x00".bit_flip(0, -1) }.should.raise(ArgumentError)
-> { (+"\x00").bit_flip(0, -1) }.should.raise(ArgumentError)
end

it "raises a FrozenError if self is frozen" do
Expand Down
10 changes: 5 additions & 5 deletions spec/ruby/core/string/bit_set_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,17 +34,17 @@
end

it "raises an IndexError for an out of range bit offset" do
-> { "\x00".bit_set(8) }.should.raise(IndexError)
-> { "\x00".bit_set(-1) }.should.raise(IndexError)
-> { (+"\x00").bit_set(8) }.should.raise(IndexError)
-> { (+"\x00").bit_set(-1) }.should.raise(IndexError)
end

it "raises an IndexError when a region extends past the end" do
-> { "\x00".bit_set(0, 9) }.should.raise(IndexError)
-> { "\x00".bit_set(0..8) }.should.raise(IndexError)
-> { (+"\x00").bit_set(0, 9) }.should.raise(IndexError)
-> { (+"\x00").bit_set(0..8) }.should.raise(IndexError)
end

it "raises an ArgumentError for a negative length" do
-> { "\x00".bit_set(0, -1) }.should.raise(ArgumentError)
-> { (+"\x00").bit_set(0, -1) }.should.raise(ArgumentError)
end

it "raises a FrozenError if self is frozen" do
Expand Down
8 changes: 6 additions & 2 deletions string.c
Original file line number Diff line number Diff line change
Expand Up @@ -7156,6 +7156,8 @@ str_mutate_single_bit(VALUE str, VALUE index, bool lsb_first, enum str_bit_mutat
unsigned char *ptr;
unsigned char mask;

rb_check_frozen(str);

if (str_bit_offset_out_of_range(RSTRING_LEN(str), offset.value)) {
rb_raise(rb_eIndexError, "bit index out of range");
}
Expand Down Expand Up @@ -7204,6 +7206,9 @@ str_mutate_bit(int argc, VALUE *argv, VALUE str, enum str_bit_mutation mutation)
len = str_bit_length_from_index(length_v);
}

/* Even a zero-length write requires a mutable receiver. */
rb_check_frozen(str);

/*
* A region that begins past the end is out of range even when it is
* empty, and one that runs past the end is not allowed to silently
Expand All @@ -7222,8 +7227,7 @@ str_mutate_bit(int argc, VALUE *argv, VALUE str, enum str_bit_mutation mutation)
rb_raise(rb_eIndexError, "bit range out of range");
}
}
/* Even a zero-length write requires a mutable receiver. */
rb_check_frozen(str);

if (len == 0) return str;

rb_str_modify(str);
Expand Down
12 changes: 12 additions & 0 deletions test/ruby/test_array.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3125,6 +3125,18 @@ def test_zip_with_enumerator
assert_equal([["a", 6], ["b", 7], ["c", 8]], a.zip(e), bug17814)
end

def test_zip_modify_during_to_ary
# [Bug #22319]
a = (1..100_000).to_a
obj = Object.new
obj.define_singleton_method(:to_ary) do
a.clear
[1, 2, 3]
end
assert_nothing_raised { a.zip(obj) }
assert_equal([], a)
end

def test_transpose
assert_equal([[1, :a], [2, :b], [3, :c]],
[[1, 2, 3], [:a, :b, :c]].transpose)
Expand Down
14 changes: 14 additions & 0 deletions test/ruby/test_econv.rb
Original file line number Diff line number Diff line change
Expand Up @@ -856,6 +856,20 @@ def test_iso2022jp_invalid_replace
"\222\xA1x".encode("iso-2022-jp", "stateless-iso-2022-jp", :invalid => :replace))
end

def test_inspect_decorator_source_name
decorator_names = %w[
amp_escape xml_text_escape xml_attr_content_escape xml_attr_quote
universal_newline crlf_newline cr_newline lf_newline
]
all_assertions_foreach(nil, *decorator_names) do |decorator|
ec = Encoding::Converter.new('', decorator)
inspect = ec.inspect
10_000.times {"A"*100}
GC.start(full_mark: true, immediate_sweep: true)
assert_equal inspect, ec.inspect
end
end

def test_convpath
eucjp = Encoding::EUC_JP
utf8 = Encoding::UTF_8
Expand Down
6 changes: 6 additions & 0 deletions test/ruby/test_method.rb
Original file line number Diff line number Diff line change
Expand Up @@ -558,6 +558,12 @@ def o.foo; end; line_no = __LINE__
c5.extend(m)
c6 = Class.new(c5)
assert_equal("#<Method: #<Class:#{c6.inspect}>(#{m.inspect})#prep(prepend)() #{__FILE__}:#{line_no}>", c6.method(:prep).inspect, bug17428)

mod = Module.new { def foo; end }; line_no = __LINE__
cls = Class.new { include mod }
o = cls.new
assert_equal("#<Method: #{mod.inspect}#foo() #{__FILE__}:#{line_no}>",
o.method(:foo).unbind.bind(o).inspect, "[ruby-core:126737] [Bug #22321]")
end

def test_callee_top_level
Expand Down
75 changes: 74 additions & 1 deletion test/ruby/test_string.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1201,14 +1201,87 @@ def test_bit_set_clear_flip_region
assert_raise(FrozenError) { S("\x00").freeze.bit_set(0, 0) }
assert_raise(FrozenError) { S("\x00").freeze.bit_clear(0...0) }
assert_raise(FrozenError) { S("\x00").freeze.bit_flip(8..) }
assert_raise(IndexError) { S("\x00").freeze.bit_set(9, 0) }
assert_raise(FrozenError) { S("\x00").freeze.bit_set(9, 0) }

# Copy-on-write: mutating must not affect a shared sibling.
shared = S("fooXbar").split(S("X")).last
shared.bit_set(0..7)
assert_equal(S("\xFFar").b, shared.b)
end

def test_bit_set_single_chilled_string_warning
return unless @cls == String
assert_bit_op_chilled_string_warning(:bit_set, 7000 * 8)
end

def test_bit_clear_single_chilled_string_warning
return unless @cls == String
assert_bit_op_chilled_string_warning(:bit_clear, 7000 * 8)
end

def test_bit_flip_single_chilled_string_warning
return unless @cls == String
assert_bit_op_chilled_string_warning(:bit_flip, 7000 * 8)
end

def test_bit_set_region_chilled_string_warning
return unless @cls == String
assert_bit_op_chilled_string_warning(:bit_set, 7000 * 8, 2)
end

def test_bit_clear_region_chilled_string_warning
return unless @cls == String
assert_bit_op_chilled_string_warning(:bit_clear, 7000 * 8, 2)
end

def test_bit_flip_region_chilled_string_warning
return unless @cls == String
assert_bit_op_chilled_string_warning(:bit_flip, 7000 * 8, 2)
end

def test_bit_set_range_chilled_string_warning
return unless @cls == String
assert_bit_op_chilled_string_warning(:bit_set, (7000 * 8)..(7100 * 8))
end

def test_bit_clear_range_chilled_string_warning
return unless @cls == String
assert_bit_op_chilled_string_warning(:bit_clear, (7000 * 8)..(7100 * 8))
end

def test_bit_flip_range_chilled_string_warning
return unless @cls == String
assert_bit_op_chilled_string_warning(:bit_flip, (7000 * 8)..(7100 * 8))
end

def assert_bit_op_chilled_string_warning(op, *args)
assert_separately([], "#{<<-"{#"}\n#{<<-'};'}")
$target = <<~STR # chilled string
#{("A"*63+"\n")*128} # 64*128 = 8192
STR
END {
assert_raise(IndexError) {$target.#{op}(#{args.map(&:inspect).join(", ")})}
}
{#
$reentered = false

module ReallocateWarning
def warn(message, category: nil, **kwargs)
if category == :deprecated && !$reentered
$reentered = true
$target.clear
$target << ("B" * 1024)
return nil
end

super
end
end

Warning.extend(ReallocateWarning)
};
end

def test_bit_count
assert_equal(0, S("").bit_count)
assert_equal(0, S("\x00").bit_count)
Expand Down
Loading