Граф коммитов

13909 Коммитов

Автор SHA1 Сообщение Дата
Lars Kanis d403591b34
Add string encoding IBM720 alias CP720 (#3803)
The mapping table is generated from the ICU project:
  https://github.com/unicode-org/icu/blob/master/icu4c/source/data/mappings/ibm-720_P100-1997.ucm

Fixes bug 16233 : https://bugs.ruby-lang.org/issues/16233
2020-11-22 22:23:40 +09:00
Nobuhiro IMAI 5218f17737 [ruby/irb] support more body argument for oneliner method definition
https://github.com/ruby/irb/commit/2ff1295533
2020-11-22 21:00:11 +09:00
Jeremy Evans 58325daae3 Make String methods return String instances when called on a subclass instance
This modifies the following String methods to return String instances
instead of subclass instances:

* String#*
* String#capitalize
* String#center
* String#chomp
* String#chop
* String#delete
* String#delete_prefix
* String#delete_suffix
* String#downcase
* String#dump
* String#each/#each_line
* String#gsub
* String#ljust
* String#lstrip
* String#partition
* String#reverse
* String#rjust
* String#rpartition
* String#rstrip
* String#scrub
* String#slice!
* String#slice/#[]
* String#split
* String#squeeze
* String#strip
* String#sub
* String#succ/#next
* String#swapcase
* String#tr
* String#tr_s
* String#upcase

This also fixes a bug in String#swapcase where it would return the
receiver instead of a copy of the receiver if the receiver was the
empty string.

Some string methods were left to return subclass instances:

* String#+@
* String#-@

Both of these methods will return the receiver (subclass instance)
in some cases, so it is best to keep the returned class consistent.

Fixes [#10845]
2020-11-20 16:30:23 -08:00
Jeremy Evans 08686e71d5 Do not allow Module#include to insert modules before the origin in the lookup chain
Module#include should only be able to insert modules after the origin,
otherwise it ends up working like Module#prepend.

This fixes the case where one of the modules in the included module
chain is included in a module that is already prepended to the receiver.

Fixes [Bug #7844]
2020-11-20 15:26:43 -08:00
Nobuyoshi Nakada 1f7b557890
Update expected IRB result 2020-11-20 18:30:05 +09:00
Nobuyoshi Nakada fac2498e02 [Bug #11213] let defined?(super) call respond_to_missing? 2020-11-20 16:04:45 +09:00
Nobuhiro IMAI 1800f3fa5c
Ripper.{lex,tokenize} return full tokens even if syntax error
yet another implements [Feature #17276]
2020-11-20 11:44:57 +09:00
Nobuyoshi Nakada 44ad72fa21
Added assertions 2020-11-19 15:41:53 +09:00
Jeremy Evans 4a5c42db88 Make RubyVM::InstructionSequence.compile_file use same encoding as load
This switches the internal function from rb_parser_compile_file_path
to rb_parser_load_file, which is the same internal method that
Kernel#load uses.

Fixes [Bug #17308]
2020-11-19 07:12:50 +09:00
Jeremy Evans cd0877a93e
Support raise_errors keyword for Ripper.{lex,tokenize,sexp,sexp_raw}
Implements [Feature #17276]
2020-11-17 21:15:50 -08:00
Sutou Kouhei 5c7ef89db4 [ruby/fiddle] test: suppress shadowing outer local variable warning
https://github.com/ruby/fiddle/commit/cf168680a2
2020-11-18 09:05:13 +09:00
Aaron Patterson 307388ea19 [ruby/fiddle] Add a "pinning" reference (#44)
* Add a "pinning" reference

A `Fiddle::Pinned` objects will prevent the objects they point to from
moving.  This is useful in the case where you need to pass a reference
to a C extension that keeps the address in a global and needs the
address to be stable.

For example:

```ruby
class Foo
  A = "hi" # this is an embedded string

  some_c_function A # A might move!
end
```

If `A` moves, then the underlying string buffer may also move.
`Fiddle::Pinned` will prevent the object from moving:

```ruby
class Foo
  A = "hi" # this is an embedded string

  A_pinner = Fiddle::Pinned.new(A) # :nodoc:

  some_c_function A # A can't move because of `Fiddle::Pinned`
end
```

This is a similar strategy to what Graal uses:

  https://www.graalvm.org/sdk/javadoc/org/graalvm/nativeimage/PinnedObject.html#getObject--

* rename global to match exception name

* Introduce generic Fiddle::Error and rearrange error classes

Fiddle::Error is the generic exception base class for Fiddle exceptions.
This commit introduces the class and rearranges Fiddle exceptions to
inherit from it.

https://github.com/ruby/fiddle/commit/ac52d00223
2020-11-18 09:05:13 +09:00
Sutou Kouhei e2dfc0c26b [ruby/fiddle] Add support for specifying types by name as String or Symbol
For example, :voidp equals to Fiddle::TYPE_VOID_P.

https://github.com/ruby/fiddle/commit/3b4de54899
2020-11-18 09:05:13 +09:00
Sutou Kouhei ae7b53546c [ruby/fiddle] Add TYPE_CONST_STRING and SIZEOF_CONST_STRING for "const char *"
Add rb_fiddle_ prefix to conversion functions.h to keep backward
compatibility but value_to_generic() isn't safe for TYPE_CONST_STRING
and not String src. Use rb_fiddle_value_to_generic() instead.

https://github.com/ruby/fiddle/commit/0ffcaa39e5
2020-11-18 09:05:13 +09:00
MSP-Greg 64926d5007 test/net/smtp - use TCPSocket when UNIXSocket unavailable 2020-11-18 08:13:10 +09:00
Hiroshi SHIBATA 0683912db8 Skip tests related TLS with Windows platform. 2020-11-17 18:05:15 +09:00
Hiroshi SHIBATA cada6d85d0
Import net-smtp-0.2.0 from https://github.com/ruby/net-smtp 2020-11-17 14:17:45 +09:00
Alan Wu ebb96fa880 Fix singleton class cloning
Before this commit, `clone` gave different results depending on whether the original object
had an attached singleton class or not.

Consider the following setup:
```
class Foo; end
Foo.singleton_class.define_method(:foo) {}

obj = Foo.new

obj.singleton_class if $call_singleton

clone = obj.clone
```

When `$call_singleton = false`, neither `obj.singleton_class.singleton_class` nor
`clone.singleton_class.singleton_class` own any methods.

However, when `$call_singleton = true`, `clone.singleton_class.singleton_class` would own a copy of
`foo` from `Foo.singleton_class`, even though `obj.singleton_class.singleton_class` does not.

The latter case is unexpected and results in a visibly different clone, depending on if the original object
had an attached class or not.

Co-authored-by: Ufuk Kayserilioglu <ufuk.kayserilioglu@shopify.com>
2020-11-16 17:41:17 -05:00
Koichi Sasada 084e7e31b2 remain enabled and line specified trace points
If two or more tracepoints enabled with the same target and with
different target lines, the only last line is activated.
This patch fixes this issue by remaining existing trace instructions.
[Bug #17302]
2020-11-17 07:33:38 +09:00
Jeremy Evans 957efa95cc [ruby/webrick] Allow empty POST and PUT requests without content length
RFC 7230 section 3.3.3 allows for this.

Fixes #30

https://github.com/ruby/webrick/commit/069e9b1908
2020-11-13 11:35:10 +09:00
Hiroshi SHIBATA ff67aac193 Removed win32api 2020-11-11 09:27:36 +09:00
Hiroshi SHIBATA 4a03df4507 [ruby/racc] skip the failing test with JRuby
https://github.com/ruby/racc/commit/cf37713895
2020-11-10 21:21:07 +09:00
Yusuke Endoh 2fed5f0ad8 lib/racc/statetransitiontable.rb: Make the racc output stable
Racc calls `Array#sort!` to build a state transition table. As
`Array#sort!` is not a stable sort, the output may differ depending upon
the environment.

This changeset makes the sort stable manually, and updates all
expectation files.
2020-11-10 07:49:19 +09:00
Kazuhiro NISHIYAMA d14397bcc4
`fe80` should be case insensitive too 2020-11-09 16:16:30 +09:00
Benoit Daloze b8eb08e096 Fix TestFiberMutex#test_condition_variable assertion
* Now that it works correctly.
2020-11-08 16:49:33 +01:00
Yusuke Endoh fcf8b9ef72 test/resolv/test_dns.rb: suppress "assigned but unused variable" 2020-11-08 23:32:44 +09:00
Samuel Williams bed4848661 Urgent notification pipe has same lifetime as scheduler. 2020-11-08 20:40:52 +13:00
Samuel Williams 57b83dad4c Defer `kernel_sleep` to `block` to avoid exiting the event loop when duration is nil. 2020-11-08 20:40:52 +13:00
Jeremy Evans 2f12af42f7 Add support for IPv6 link local addresses to resolv
Now that it should work correctly, test that every address returned
by Socket.ip_address_list is resolvable.

Socket works with IPv6 link local addresses, and ipaddr now does
as well, so I think resolv should support them.

Fixes [Bug #17112]
2020-11-07 13:47:45 -08:00
Jeremy Evans 9682db0651 Remove sender/message_id pair after response received in resolv
Once a response for a given DNS request has been received (which
requires a matching message id), the [sender, message_id] pair
should be removed from the list of valid senders.  This makes it
so duplicate responses from the same sender are ignored.

Fixes [Bug #12838]
2020-11-07 13:12:27 -08:00
Samuel Williams a08ee8330d Rename to `Fiber#set_scheduler`. 2020-11-07 23:39:50 +13:00
Jeremy Evans 2a294d499b
Make Array methods return Array instances instead of subclass instances
This changes the following methods to return Array instances instead
of subclass instances:

* Array#drop
* Array#drop_while
* Array#flatten
* Array#slice!
* Array#slice/#[]
* Array#take
* Array#take_while
* Array#uniq
* Array#*

Fixes [Bug #6087]
2020-11-03 14:01:38 -08:00
Kazuki Tsujimoto 700637570f
Rightward assignment is replaced by one-line pattern matching 2020-11-04 00:51:44 +09:00
Yusuke Endoh c3e2dd072a test/ruby/test_gc_compact.rb: suppress "assigned but unused variable" 2020-11-03 23:32:40 +09:00
Aaron Patterson 67b2c21c32
Add `GC.auto_compact= true/false` and `GC.auto_compact`
* `GC.auto_compact=`, `GC.auto_compact` can be used to control when
  compaction runs.  Setting `auto_compact=` to true will cause
  compaction to occurr duing major collections.  At the moment,
  compaction adds significant overhead to major collections, so please
  test first!

[Feature #17176]
2020-11-02 14:42:48 -08:00
Nobuyoshi Nakada 79b242260b
ripper: Invalid pragma value warning 2020-11-02 22:49:42 +09:00
Kazuki Tsujimoto b601532411
Pattern matching is no longer experimental 2020-11-01 13:33:58 +09:00
Koichi Sasada 07c03bc309 check isolated Proc more strictly
Isolated Proc prohibit to access outer local variables, but it was
violated by binding and so on, so they should be error.
2020-10-29 23:42:55 +09:00
Jeremy Evans dfb3605bbe
Add Thread.ignore_deadlock accessor
Setting this to true disables the deadlock detector.  It should
only be used in cases where the deadlock could be broken via some
external means, such as via a signal.

Now that $SAFE is no longer used, replace the safe_level_ VM flag
with ignore_deadlock for storing the setting.

Fixes [Bug #13768]
2020-10-28 15:27:00 -07:00
Yusuke Endoh c1bebbb2ee test/ruby/test_rational.rb: Prevent "assigned but unused variable" 2020-10-28 00:27:56 +09:00
Nobuyoshi Nakada 8e06075442
Revert "Fixed typo"
This reverts commit 379a5ca539.
This "typo" is intentional to test the transposition detection by
did_you_mean.
2020-10-27 23:26:38 +09:00
Hiroshi SHIBATA 379a5ca539
Fixed typo 2020-10-27 22:59:43 +09:00
Nobuyoshi Nakada bdd1d17ac2
Allow non-argument endless-def with a space instead of parentheses 2020-10-26 21:15:16 +09:00
Kenta Murata 69837229d7
rational.c: convert a numerator to rational before calling fdiv in Kernel.Rational() (#3702)
This makes `Rational(BigDecimal(1), 60) == Rational(1, 60)`.
[Bug #16518]
2020-10-26 18:43:30 +09:00
Nobuyoshi Nakada 52c630da00
Assoc pattern matching (#3703)
[Feature #17260] One-line pattern matching using tASSOC

R-assignment is rejected instead.
2020-10-26 18:00:24 +09:00
Kenta Murata f754b42285
numeric.c, range.c: prohibit zero step
* numeric.c: prohibit zero step in Numeric#step

* range.c: prohibit zero step in Range#step

* Fix ruby-spec

[Feature #15573]
2020-10-23 15:26:51 +09:00
Kenta Murata d23d5c3130
rational.c: try converting by to_int in Rational() (#3684)
[Bug #12485]
2020-10-22 17:59:52 +09:00
Yusuke Endoh 762be87759 test/json/json_parser_test.rb: suppress warnings
http://rubyci.s3.amazonaws.com/ubuntu/ruby-master/log/20201021T123003Z.log.html.gz
```
/home/chkbuild/chkbuild/tmp/build/20201021T123003Z/ruby/test/json/json_parser_test.rb:227: warning: ambiguous first argument; put parentheses or a space even after `-' operator
/home/chkbuild/chkbuild/tmp/build/20201021T123003Z/ruby/test/json/json_parser_test.rb:228: warning: ambiguous first argument; put parentheses or a space even after `-' operator
```
2020-10-21 23:37:42 +09:00
Kenta Murata a6a8576e87
Feature #16812: Allow slicing arrays with ArithmeticSequence (#3241)
* Support ArithmeticSequence in Array#slice

* Extract rb_range_component_beg_len

* Use rb_range_values to check Range object

* Fix ary_make_partial_step

* Fix for negative step cases

* range.c: Describe the role of err argument in rb_range_component_beg_len

* Raise a RangeError when an arithmetic sequence refers the outside of an array

[Feature #16812]
2020-10-21 02:40:18 +09:00
Nobuyoshi Nakada d915e7ee00
strip trailing spaces [ci skip] 2020-10-20 23:52:19 +09:00
Chris Seaton 451836f582
Fix an issue with generate_pretty and empty objects in the Ruby and Java implementations 2020-10-20 21:46:54 +09:00
Jean Boussier 520e0916af
Implement a freeze: parser option
If set to true all parsed objects will be
immediately frozen, and strings will be
deduplicated if the Ruby implementation
allows it.
2020-10-20 21:40:25 +09:00
Kenta Murata 18cecda46e
range.c: Fix an exception message in rb_range_beg_len
[Bug #17271]
2020-10-20 16:01:57 +09:00
Takashi Kokubun 4a7dccf44f
Add a Ripper.lex test of :on_embexpr_end
This is a weird use case of Ripper.lex which I'm not sure is supposed to
be maintained, so I'm adding this test so that we can easily notice such
changes.

If we change the behavior, this will break the behavior of hamlit.gem v1
and code like https://github.com/haml/haml/pull/1043.
2020-10-19 20:56:09 -07:00
Yusuke Endoh 09dd9d8e5d Revert "test/rinda/test_rinda.rb: try debugging TestRingServer#test_do_reply"
This reverts commit de5e8d0e3b.

Remove the debugging code that is no longer needed
2020-10-17 15:32:40 +09:00
Yusuke Endoh 6a9e09824b Revert "test/rinda/test_rinda.rb: Add more debugging code"
This reverts commit ac803ab55d.

Remove debugging code that is no longer needed
2020-10-17 15:32:19 +09:00
Yusuke Endoh 5c003b4bcd test/rinda/test_rinda.rb: Prevent a callback Proc from being GC'ed
According to the log of ac803ab55d, I
found that a thread terminates silently due to "recycled object" of
id2ref:

```
"/home/chkbuild/chkbuild/tmp/build/20201017T033002Z/ruby/lib/drb/drb.rb:366:in `_id2ref'"
"/home/chkbuild/chkbuild/tmp/build/20201017T033002Z/ruby/lib/drb/drb.rb:366:in `to_obj'"
"/home/chkbuild/chkbuild/tmp/build/20201017T033002Z/ruby/lib/drb/drb.rb:1528:in `to_obj'"
"/home/chkbuild/chkbuild/tmp/build/20201017T033002Z/ruby/lib/drb/drb.rb:1847:in `to_obj'"
"/home/chkbuild/chkbuild/tmp/build/20201017T033002Z/ruby/lib/drb/drb.rb:1136:in `method_missing'"
"/home/chkbuild/chkbuild/tmp/build/20201017T033002Z/ruby/test/rinda/test_rinda.rb:652:in `block in do_reply'"
```
https://rubyci.org/logs/rubyci.s3.amazonaws.com/rhel8/ruby-master/log/20201017T033002Z.log.html.gz

I believe that this unintentional thread termination has caused
intermittent timeout failure of `TestRingServer#test_do_reply`.

The root cause of the "recycled object" issue is a bug of
`TestRingServer#test_do_reply`.  It creates a callback Proc object but
does not hold the reference to the object:

```
callback = DRb::DRbObject.new callback
```

The original "callback" object is GC'ed unintentionally.
I could consistently reproduce this issue on my machine by adding
`GC.stress = true` at the first of `_test_do_reply` method body.

This change uses another local variable name, "callback_orig", to keep
the original Proc object.
2020-10-17 15:17:55 +09:00
Aaron Patterson ff9dc10966
keep proc on the stack so it does not move 2020-10-16 11:28:52 -07:00
Yusuke Endoh ac803ab55d test/rinda/test_rinda.rb: Add more debugging code
in addition to de5e8d0e3b
2020-10-17 00:07:35 +09:00
Yusuke Endoh de5e8d0e3b test/rinda/test_rinda.rb: try debugging TestRingServer#test_do_reply
https://rubyci.org/logs/rubyci.s3.amazonaws.com/rhel8/ruby-master/log/20201016T063003Z.fail.html.gz
```
  1) Error:
Rinda::TestRingServer#test_do_reply:
Timeout::Error: timeout
    /home/chkbuild/chkbuild/tmp/build/20201016T063003Z/ruby/test/rinda/test_rinda.rb:837:in `sleep'
    /home/chkbuild/chkbuild/tmp/build/20201016T063003Z/ruby/test/rinda/test_rinda.rb:837:in `wait_for'
    /home/chkbuild/chkbuild/tmp/build/20201016T063003Z/ruby/test/rinda/test_rinda.rb:659:in `_test_do_reply'
    /home/chkbuild/chkbuild/tmp/build/20201016T063003Z/ruby/test/rinda/test_rinda.rb:643:in `block in test_do_reply'
    /home/chkbuild/chkbuild/tmp/build/20201016T063003Z/ruby/test/rinda/test_rinda.rb:807:in `with_timeout'
    /home/chkbuild/chkbuild/tmp/build/20201016T063003Z/ruby/test/rinda/test_rinda.rb:643:in `test_do_reply'
```
2020-10-16 16:51:33 +09:00
Yusuke Endoh 1cbb1f1720 test/ruby/test_syntax.rb: avoid "warning: assigned but unused variable" 2020-10-16 11:10:58 +09:00
wanabe 65ae7f347a Adjust sp for `if true or ...`/`if false and ...` 2020-10-16 08:37:04 +09:00
wanabe ce7a053475 Adjust sp for `x = false; y = (return until x unless x)` [Bug #16695] 2020-10-16 08:37:04 +09:00
Nobuyoshi Nakada 7ffd14a18c
Check encoding name to replicate
https://hackerone.com/reports/954433
2020-10-15 16:48:25 +09:00
Hiroshi SHIBATA ab6c4f8be3 Merge rubygems-3.2.0.rc.2 2020-10-15 14:12:02 +09:00
Koichi Sasada 2e8b5968e1 remove uneffective test
RubyVM.stat[:global_method_state] is no longer available so
this test doesn't check any more.
2020-10-14 23:15:21 +09:00
Koichi Sasada 278450de80 ruby_vm_global_method_state is no longer needed.
Now ruby_vm_global_method_state is not used so let's remove it.
2020-10-14 23:15:21 +09:00
Yusuke Endoh 76e09815ae test/ruby/test_fiber.rb: Suppress "assigned but unused variable" warnings 2020-10-13 13:40:44 +09:00
Koichi Sasada bf3b2a4374 relax Fiber#transfer's restriction
Using Fiber#transfer with Fiber#resume for a same Fiber is
limited (once Fiber#transfer is called for a fiber, the fiber
can not be resumed more). This restriction was introduced to
protect the resume/yield chain, but we realized that it is too much
to protect the chain. Instead of the current restriction, we
introduce some other protections.

(1) can not transfer to the resuming fiber.
(2) can not transfer to the yielding fiber.
(3) can not resume transferred fiber.
(4) can not yield from not-resumed fiber.

[Bug #17221]

Also at the end of a transferred fiber, it had continued on root fiber.
However, if the root fiber resumed a fiber (and that fiber can resumed
another fiber), this behavior also breaks the resume/yield chain.
So at the end of a transferred fiber, switch to the edge of resume
chain from root fiber.
For example, root fiber resumed f1 and f1 resumed f2, transferred to
f3 and f3 terminated, then continue from the fiber f2 (it was continued
from root fiber without this patch).
2020-10-12 22:58:41 +09:00
Yusuke Endoh 2fd71112fb Make the test suite pass on real Android/Termux environment
Attempting to create a hard link raises EACCES
2020-10-12 21:26:05 +09:00
Yusuke Endoh 8a39e6d653 bignum.c (rb_int_powm): Integer#pow(0, 1) should return 0
... instead of 1 because it requires "modulo 1".  [Bug #17257]
2020-10-12 13:42:48 +09:00
Nobuyoshi Nakada 4ed0c33d13
Prohibit setter method names in all kinds of endless methods
Also unwrap NODE_RIPPER to check the method name.
2020-10-12 00:40:55 +09:00
Nobuyoshi Nakada a79966743c [ruby/io-console] Fix timeout type error (#18)
Fixed TypeError when IO#getch timed out

`rb_io_wait` returns a bit-flags Integer representing available
events, or Qfalse if timed out.  Also the result of `NUM2INT` is
not a `VALUE`.

```
$ ./bin/ruby -v -rio/console -e "p IO.console.getch(intr: true, time: 0.1)"
ruby 3.0.0dev (2020-10-09T20:27:30Z master 5ea2ea74cc) [x64-mingw32]
-e:1:in `getch': no implicit conversion of false into Integer (TypeError)
        from -e:1:in `<main>'
```

https://github.com/ruby/io-console/commit/3bdfaf62df
2020-10-11 02:00:24 +09:00
Marc-Andre Lafortune 1486785a57 [lib/ostruct] Fix Marshal loading 2020-10-06 17:11:08 -04:00
aycabta 20ad101701 Remove system method for E2E testing because depends on ruby command 2020-10-05 19:50:31 +09:00
aycabta 9718ff62c1 Show stdout and stderr when history tests fail 2020-10-05 04:17:26 +09:00
Kazuhiro NISHIYAMA 873c8a14f0
Fix assert_ruby_status usage in 174ae0f577 2020-10-03 03:05:21 +09:00
Nobuyoshi Nakada 174ae0f577
Remove known use-after-poison bug
9eda654781 was fixed by
b9488accf9.
2020-10-03 00:45:06 +09:00
Kazuhiro NISHIYAMA d0a7189f26 Fix ObjectSpace.dump(obj, output: :stdout)
RDoc says `ObjectSpace.dump(obj, output: :stdout)   # => nil`,
but it returns STDOUT since fbba6bd4e3.

I think it is unintentional change.
2020-10-03 00:00:01 +09:00
Nobuyoshi Nakada 89ca842dcc
Ensure that the comparison succeeded [Bug #17205] 2020-10-02 11:02:45 +09:00
Nobuyoshi Nakada 1d3024da26
Refined assertions for better failure messages 2020-10-01 13:48:15 +09:00
Nobuyoshi Nakada eef12cdc06
strip trailing spaces [ci skip] 2020-10-01 13:47:57 +09:00
Samuel Williams dd2e95fb26 Remove `Thread.scheduler` from public interface.
It's implementation is equivalent to:

Thread.current.scheduler unless Thread.current.blocking?
2020-10-01 16:56:05 +13:00
Samuel Williams 7f29020590 Raise an exception if the scheduler was already closed. 2020-10-01 16:02:03 +13:00
Samuel Williams 13660105e2 Don't call `Scheduler#close` if it doesn't exist. 2020-10-01 16:02:03 +13:00
Koichi Sasada bc23216e5a stop Ractor test in test-all
Ractor changes the interpreter's running mode so now it should
not use in test-all process which running with many other tests.

Test with a separating process is one idea, but I'm not sure
the ruby/ostruct can use this trick.
2020-10-01 08:55:08 +09:00
Marc-Andre Lafortune b36a45c05c [ruby/ostruct] Improved YAML serialization.
Patch adapted from Pietro Monteiro [Fixes bug#8382]
2020-09-30 18:11:24 -04:00
Marc-Andre Lafortune 0977040133 [ruby/ostruct] Add test that frozen OpenStructs are Ractor-shareable 2020-09-30 18:11:24 -04:00
Marc-Andre Lafortune 083fa6e5d2 [ruby/ostruct] Protect subclass' methods and our bang methods.
Internally, use only bang methods
2020-09-30 18:11:24 -04:00
Marc-Andre Lafortune df4d08c44a [ruby/ostruct] Avoid calling initialize 2020-09-30 18:11:24 -04:00
Nobuyoshi Nakada 7b2bea42a2
Unfreeze string-literal-only interpolated string-literal
[Feature #17104]
2020-09-30 22:15:28 +09:00
Kazuhiro NISHIYAMA ce986b41ca
Remove unneeded `begin` and `end` 2020-09-30 15:55:07 +09:00
Kazuhiro NISHIYAMA 30bb040ea4
Fix `Leaked tempfile`s
http://rubyci.s3.amazonaws.com/debian10/ruby-master/log/20200930T033004Z.diff.html.gz
```
 [n/n] JSONCommonInterfaceTest#test_load = <elapsed> s
 [n/n] JSONCommonInterfaceTest#test_load_file = <elapsed> s
+Leaked tempfile: JSONCommonInterfaceTest#test_load_file: #<Tempfile:<build-dir>/tmp/20200930-7601-ptnv6i (closed)>
 [n/n] JSONCommonInterfaceTest#test_load_file! = <elapsed> s
+Leaked tempfile: JSONCommonInterfaceTest#test_load_file!: #<Tempfile:<build-dir>/tmp/20200930-7601-1la6m9 (closed)>
 [n/n] JSONCommonInterfaceTest#test_load_file_with_option = <elapsed> s
+Leaked tempfile: JSONCommonInterfaceTest#test_load_file_with_option: #<Tempfile:<build-dir>/tmp/20200930-7601-blf9hz (closed)>
 [n/n] JSONCommonInterfaceTest#test_load_file_with_option! = <elapsed> s
+Leaked tempfile: JSONCommonInterfaceTest#test_load_file_with_option!: #<Tempfile:<build-dir>/tmp/20200930-7601-b5gsdb (closed)>
```
2020-09-30 15:41:14 +09:00
Samuel Williams 388281c5c9 Fix order of operations during `rb_ec_finalize`. 2020-09-30 16:34:38 +13:00
Peter Zhu f7bd9f0750 Fix unsigned int overflow in error message for chr
The error message has an integer overflow because it treats an unsigned int as a signed int.

Before:
```
> 3_000_000_000.chr
-1294967296 out of char range (RangeError)
```

After:
```
> 3_000_000_000.chr
3000000000 out of char range (RangeError)
```

Redmine ticket: https://bugs.ruby-lang.org/issues/17186
2020-09-30 00:31:59 +09:00
Yusuke Endoh 40a499db65 test/racc/test_racc_command.rb: prevent a warning
http://rubyci.s3.amazonaws.com/ubuntu2004/ruby-master/log/20200929T003003Z.log.html.gz
```
warning: ambiguous first argument; put parentheses or a space even after `/' operator
```
2020-09-29 11:58:04 +09:00
Aaron Patterson 0767d387ec
Pass ASAN options to child environments
I want to work with ASAN, but some child environments are not inheriting
the ASAN options I'm using.  This commit passes them to child
environments if specified
2020-09-28 09:45:04 -07:00
Jeremy Evans 92c3ad9c27 Make Warning.warn accept only category keyword
In general accepting arbitrary keywords is a bad idea unless you are
delegating keywords or acting on arbitrary keywords.  In this case,
the category keyword is ignored, and it's less error prone to not
ignore all keywords.
2020-09-28 08:38:06 -07:00
Jeremy Evans 5d7953f86b Switch conflicting chdir warning to RuntimeError
The documentation already stated this was an error in one case
(when it was previously a warning).  Describe the other case,
where chdir without block is called inside block passed to chdir.

Fixes [Bug #15661]
2020-09-28 08:34:04 -07:00
Kazuhiro NISHIYAMA ac414139ec
Remove unnecessary executable bit [ci skip] 2020-09-28 23:07:43 +09:00
Marc-Andre Lafortune 97d1a381e1
[Fixes #137] Improve reporting 2020-09-28 18:07:24 +09:00
xndcn ac3f80a58e [rubygems/rubygems] Add writable check for cache dir
Sometimes "install_dir/cache" directory is not writable although "install_dir" is writable.

https://github.com/rubygems/rubygems/commit/665221cb69
2020-09-28 14:54:22 +09:00
Ellen Marie Dash e8274a7683 [rubygems/rubygems] Add test for "gem update --system --silent"
https://github.com/rubygems/rubygems/commit/c3fb0db930
2020-09-28 14:54:22 +09:00
David Rodríguez c6bdf75049 Disallow downgrades to too old versions
Consider the version original included with each ruby as the minimum
supported version.
2020-09-28 14:54:22 +09:00
bronzdoc be980dd9fa [rubygems/rubygems] Deprecate --dryrun
https://github.com/rubygems/rubygems/commit/1715610648
2020-09-28 14:54:22 +09:00
bronzdoc b83787b1ce [rubygems/rubygems] Make --dry-run flag consistent across rubygems commands
https://github.com/rubygems/rubygems/commit/addc644cad
2020-09-28 14:54:22 +09:00
Nobuyoshi Nakada 0629e695e3 Added `--platform` option to `build` command 2020-09-28 14:54:22 +09:00
Benoit Daloze 41eba95920 Revert the first diff of "Use Tempfile.create instead of Tempfile.open in test_io.rb"
* This partially reverts commit dead747874.
* Windows will not allow a file to be unlinked if any file handles exist,
  see https://github.com/ruby/ruby/pull/3597
2020-09-27 21:32:26 +02:00
Benoit Daloze dead747874 Use Tempfile.create instead of Tempfile.open in test_io.rb 2020-09-26 12:36:31 +02:00
Alan Wu 24820d508b Return nil when argument to ObjectSpace.internal_class_of is T_IMEMO
The added test case crashes the interpreter because it makes
ObjectSpace.internal_class_of return the second VALUE slot of an AST
imemo object. The second VALUE slot of `struct rb_ast_struct` is
not a VALUE and not a pointer to a Ruby object.
2020-09-25 09:27:49 -07:00
Yusuke Endoh b271bd73e0 test/net/smtp/test_smtp.rb: Stop io leaks
`make test-all` was very noisy by warnings like

```
Leaked file descriptor: Net::TestSMTP#test_start_with_position_argument: 6 : #<TCPSocket:fd 6, AF_INET, 127.0.0.1, 43770>
```
2020-09-26 00:20:06 +09:00
Yusuke Endoh abdd3c5616 test/ruby/test_enumerator.rb: check the deprecation warning
by explicitly setting `Warning[:deprecated] = true`.
I removed "capture_io" at 79063d8cbf, but
it printed the warning when `RUBYOPT=-w`.

This change makes the warnings enabled explicitly, capture and check the
warning.
2020-09-25 23:45:42 +09:00
Yusuke Endoh 0db5324e0d test/ruby/test_memory_view.rb: prevent "assigned but unused variable - members" 2020-09-25 23:39:35 +09:00
Yusuke Endoh 79063d8cbf test/ruby/test_enumerator.rb: remove capture_io that is no longer needed
The deprecation warning was disabled, and the code to check the warning
was removed at 996af2ce08, thus capture_io
is no longer needed.
2020-09-25 23:38:01 +09:00
Yusuke Endoh e4b2c4fca5 t/json/json_common_interface_test.rb: fix wrong indentation
to prevent:

```
test/json/json_common_interface_test.rb:182: warning: mismatched indentations at 'end' with 'def' at 169
```
2020-09-25 23:37:12 +09:00
Koichi Sasada 0096d2b895 freeze all Range objects.
Matz want to try to freeze all Range objects.
[Feature #15504]
2020-09-25 22:16:55 +09:00
Kenta Murata 890bc2cdde
Buffer protocol proposal (#3261)
* Add buffer protocol

* Modify for some review comments

* Per-object buffer availability

* Rename to MemoryView from Buffer and make compilable

* Support integral repeat count in memory view format

* Support 'x' for padding bytes

* Add rb_memory_view_parse_item_format

* Check type in rb_memory_view_register

* Update dependencies in common.mk

* Add test of MemoryView

* Add test of rb_memory_view_init_as_byte_array

* Add native size format test

* Add MemoryView test utilities

* Add test of rb_memory_view_fill_contiguous_strides

* Skip spaces in format string

* Support endianness specifiers

* Update documentation

* Support alignment

* Use RUBY_ALIGNOF

* Fix format parser to follow the pack format

* Support the _ modifier

* Parse count specifiers in get_format_size function.

* Use STRUCT_ALIGNOF

* Fix test

* Fix test

* Fix total size for the case with tail padding

* Fix rb_memory_view_get_item_pointer

* Fix rb_memory_view_parse_item_format again
2020-09-25 20:32:02 +09:00
Hiroshi SHIBATA 6eeacbbc36
Extract assert assertion to assert_include and assert_not_include. 2020-09-25 20:28:31 +09:00
Hiroshi SHIBATA 81dc37b1b4 assert_true is not provided by test-unit 2020-09-25 17:28:42 +09:00
Marc-Andre Lafortune e30d1b0923 Fix pure parser with unclosed arrays / objects [Fix #314] 2020-09-25 17:28:42 +09:00
Karol Bucek 0089854fc5 [test] properly 'skip' test on JRuby
an early return still caused ensure to execute,
setting JSON constant to `nil` for later tests!
2020-09-25 17:28:42 +09:00
Keith Bennett c3614877d2 [flori/json] Add `load_file` and `load_file!` methods, with tests. Fixes issue #386.
https://github.com/flori/json/commit/0be363c99b
2020-09-25 17:28:42 +09:00
Jean Boussier e1659af372 Add an option to escape forward slash character
Squashed commit of the following:

commit 26d181059989279a79c433cedcd893b4f52e42ee
Author: Francois Chagnon <francois.chagnon@jadedpixel.com>
Date:   Tue Sep 15 21:17:34 2015 +0000

    add config options for escape_slash

commit fa282334051b16df91ca097dd7304b46f3bc7719
Author: Francois Chagnon <francois.chagnon@jadedpixel.com>
Date:   Mon Feb 9 21:09:33 2015 +0000

    add forward slash to escape character
2020-09-25 17:28:42 +09:00
Masaki Matsushita 511fe23fa2 Add resolve_timeout to TCPSocket [Feature #17134] 2020-09-25 15:19:14 +09:00
Jean Boussier b72f9200ac
[ruby/psych] Forward keyword arguments in load_file and load_stream
https://github.com/ruby/psych/commit/4e1dd37f09
2020-09-25 13:11:33 +09:00
Charles Oliver Nutter 33641e00cd
Remove private_iv_get
The only remaining use of this function was to get the internal
message object from an exception's hidden `mesg` instance
variable to allow it to be dumped wiithout converting to a string.

As discussed in #103, this exposes internal implementation details
of CRuby, and ultimately does not provide any real utility to the
user since they can't directly inspect this hidden variable. The
test change here is to reflect CRuby behavior that denies equality
if the internal message objects do not match, as is the case after
the exception has been loaded and now has a simple String value.

The impact to users is that exceptions with special hidden message
objects will convert those objects to String during marshaling
through YAML. I believe this only affects NameError and its
descendants, since users can't set this field directly on their
own exception types.

Fixes #103.
2020-09-25 13:11:32 +09:00
Nobuyoshi Nakada 996af2ce08 Disable deprecation warning by the default [Feature #16345]
And `-w` option turns it on.
2020-09-25 09:50:33 +09:00
Hiroshi SHIBATA 53acf6686a
Revert "[ruby/webrick] Add test for shutdown_pipe"
This reverts commit c06eab1329.
2020-09-25 07:54:01 +09:00
Hiroshi SHIBATA c5960d51d1
Revert "[ruby/webrick] Fix shutdown_pipe test issue"
This reverts commit b8fdd38b2e.
2020-09-25 07:33:25 +09:00
Hiroshi SHIBATA 757e185cee
Revert "[ruby/webrick] Allow empty POST and PUT requests without content length"
This reverts commit ed12019ce6.

  https://github.com/ruby/ruby/runs/1160423667?check_suite_focus=true#step:14:752
2020-09-24 22:20:02 +09:00
Hiroshi SHIBATA 588ac990ff
[ruby/webrick] Manually pick commit from upstream repo
Fix test when run with US-ASCII encoding

  f402aafb36
2020-09-24 21:41:11 +09:00
Jeremy Evans c12c7fea70 [ruby/webrick] Only run test_big_bodies test on Ruby 2.5+
It was added after Ruby 2.5, and it looks like it never ran correctly
on Ruby <2.5.

https://github.com/ruby/webrick/commit/65fb03cb6a
2020-09-24 21:34:41 +09:00
Jeremy Evans ed12019ce6 [ruby/webrick] Allow empty POST and PUT requests without content length
RFC 7230 section 3.3.3 allows for this.

Fixes #30

https://github.com/ruby/webrick/commit/069e9b1908
2020-09-24 21:34:07 +09:00
Jeremy Evans 0fe6461148 [ruby/webrick] Allow EPROTOTYPE error when writing junk to a socket
MacOS seems to raise this error in some cases.

https://github.com/ruby/webrick/commit/0f0c9f1e61
2020-09-24 21:33:16 +09:00
John W Higgins b8fdd38b2e [ruby/webrick] Fix shutdown_pipe test issue
https://github.com/ruby/webrick/commit/9676704c60
2020-09-24 21:32:14 +09:00
John W Higgins 4715a24dd2 [ruby/webrick] Ensure server port numbers are numeric and ensure they are stored as integers
https://github.com/ruby/webrick/commit/86ed621e11
2020-09-24 21:31:55 +09:00
John W Higgins c06eab1329 [ruby/webrick] Add test for shutdown_pipe
https://github.com/ruby/webrick/commit/1daacc1849
2020-09-24 21:31:35 +09:00
Jeremy Evans d969cf6059 [ruby/webrick] Do not use ensure in a block without begin
This syntax is not supported until Ruby 2.5, and Webrick still
targets Ruby 2.3+.

https://github.com/ruby/webrick/commit/fbe85b885f
2020-09-24 21:30:34 +09:00
Charles Oliver Nutter 46ba416a1f [ruby/webrick] Skip env-locale-sensitive CGI test on the "java" platform
JRuby's environment variables are provided by the Java Development
Kit's (JDK's) classes, which present them as a map from string to
string. In order to do this, those environment variable names and
values must be decoded into characters, which breaks any variables
that are intended to be "raw" bytes not necessarily decodable with
the default system encoding.

This issue is detailed in jruby/jruby#6248. The only solution on
the JRuby side will be to bypass the JDK environment variable API
and go directly to the native getenv/setenv system calls. This is
not likely to happen in the near future, due to the complexity of
such a change and the rarity of undecodable environment values.

The exclude here was added due to the Windows platform also having
a similar sensitivity to character encodings when working with
environment variables. It seems appropriate to expand this skip
to the "java" platform, as the root issue is largely the same.

https://github.com/ruby/webrick/commit/dc453e5c3c
2020-09-24 21:21:38 +09:00
Yusuke Endoh 0c611d7f4f test/net/http/test_https.rb: The test logic was buggy
The expected certs must be `[CA_CERT, SERVER_CERT]` before 1.1.1g and
`[SERVER_CERT]` after 1.1.1h.
2020-09-24 19:39:51 +09:00
Yusuke Endoh 1917afa34b test/net/http/test_https.rb: the order of verify_callback seems to vary
... depending upon the environment.
2020-09-24 19:34:16 +09:00
Yusuke Endoh 4405423c87 test/ostruct/test_ostruct.rb: Prevent "method redefined; discarding old foo" 2020-09-24 19:30:22 +09:00
Yusuke Endoh 416bb11a5e test/fiber/scheduler.rb: Prevent "instance variable @urgent not initialized" 2020-09-24 19:29:54 +09:00
Yusuke Endoh 07786edd66 test/net/http/test_https.rb: Stop the error due to openssl 1.1.1h
On some environments that uses OpenSSL 1.1.1h, the two tests now fail.

http://rubyci.s3.amazonaws.com/android29-x86_64/ruby-master/log/20200924T062352Z.fail.html.gz
https://github.com/ruby/ruby/runs/1159288773?check_suite_focus=true

```
  1) Failure:
TestNetHTTPS#test_get [/data/data/com.termux/files/home/cb/tmp/build/20200924T062352Z/ruby/test/net/http/test_https.rb:47]:
<"0\x82\x03\xED0\x82\x02\xD5\xA0\x03..."> expected but was
<"0\x82\x03\xE30\x82\x02\xCB\xA0\x03...">.
```

Not sure why, but verify_callback now seems to receive only SERVER_CERT
but not CA_CERT.
It would be good to investigate the issue furthermore, but tentatively,
I want to stop the failures.
2020-09-24 19:20:17 +09:00
Hiroshi SHIBATA b717f73402
Revert "Manually merged from https://github.com/rubygems/rubygems/pull/2636"
31a6eaabc1 is obsoleted with
  https://github.com/rubygems/rubygems/pull/3820
2020-09-23 22:01:44 +09:00
Hiroshi SHIBATA 31a6eaabc1
Manually merged from https://github.com/rubygems/rubygems/pull/2636
Enable Style/EmptyLinesAroundClassBody rubocop cop.
2020-09-23 21:02:56 +09:00
Nobuyoshi Nakada b57c54679b
strip trailing spaces [ci skip] 2020-09-23 17:47:30 +09:00
Jeremy Evans ed27c2514c Update UnixSocket#recv_io tests to handle receiving a UnixSocket
Receiving UnixSocket works fine if you don't provide a mode, and
I think it is reasonable to expect that you should not provide
a mode if klass.for_fd would not accept a mode.

Fixes [Bug #11778]
2020-09-22 15:44:34 -07:00
Jeremy Evans 179384a668 Revert "Prevent SystemStackError when calling super in module with activated refinement"
This reverts commit eeef16e190.

This also reverts the spec change.

Preventing the SystemStackError would be nice, but there is valid
code that the fix breaks, and it is probably more common than cases
that cause the SystemStackError.

Fixes [Bug #17182]
2020-09-22 12:04:48 -07:00
Jeremy Evans df14c758fc Make hash returned by Hash#transform_values not have a default
This sets an explicit default of nil.  There is probably a better
approach of removing the default.

Fixes [Bug #17181]
2020-09-21 19:35:08 -07:00