Commit graph

87197 commits

Author SHA1 Message Date
Nobuyoshi Nakada
be84abffba
Gather code for builtin loading to miniinit.c 2024-09-08 23:16:46 +09:00
Nobuyoshi Nakada
d2179eeaac
Try to run goruby 2024-09-08 23:16:46 +09:00
otegami
903f3790ad [ruby/open-uri] Update error message for request_specific_fields option validation
Added `inspect` to the `request_specific_fields` value to provide
better visibility for users in the exception message.

f89ce5112d
2024-09-08 14:13:00 +00:00
otegami
76475bf5c0 [ruby/open-uri] Add documentation for request_specific_fields option
2e7734c061
2024-09-08 14:13:00 +00:00
otegami
0ac16215da [ruby/open-uri] Add test about request_specific_fields option
060886f312
2024-09-08 14:12:59 +00:00
otegami
6ea2b6f65f [ruby/open-uri] Add request_specific_fields option for customizing headers
This commit introduces the `request_specific_fields` option in OpenURI.
It provides two methods for customizing headers as follows.

1. Specify headers only for the initial request

Use a Hash to apply headers only to the first request.
These headers are automatically removed during redirects.

2. Specify headers dynamically for each request

Use a Proc to dynamically generate headers for each request,
including during redirects, based on the request URL.

This feature allows users to control headers flexibly,
ensuring that sensitive headers like "Authorization" are not unintentionally
transferred during redirects unless explicitly specified.

460f858e3c
2024-09-08 14:12:59 +00:00
Mads Ohm Larsen
ec5d5422ca [ruby/rdoc] Use pointer cursor for navigation toggle
(https://github.com/ruby/rdoc/pull/1175)

964a1982c8
2024-09-08 12:17:36 +00:00
Koichi ITO
4774284124 [ruby/prism] Fix a token incompatibility for Prism::Translation::Parser::Lexer
This PR fixes a token incompatibility between Parser gem and `Prism::Translation::Parser` for left parenthesis.

## Parser gem (Expected)

Returns `tLPAREN2` token:

```console
$ bundle exec ruby -Ilib -rparser/ruby33 \
-ve 'buf = Parser::Source::Buffer.new("example.rb"); buf.source = "foo(:bar)"; p Parser::Ruby33.new.tokenize(buf)[2]'
ruby 3.4.0dev (2024-09-01T11:00:13Z master eb144ef91e) [x86_64-darwin23]
[[:tIDENTIFIER, ["foo", #<Parser::Source::Range example.rb 0...3>]], [:tLPAREN2, ["(", #<Parser::Source::Range example.rb 3...4>]],
[:tSYMBOL, ["bar", #<Parser::Source::Range example.rb 4...8>]], [:tRPAREN, [")", #<Parser::Source::Range example.rb 8...9>]]]
```

## `Prism::Translation::Parser` (Actual)

Previously, the parser returned `tLPAREN` token when parsing the following:

```console
$ bundle exec ruby -Ilib -rprism -rprism/translation/parser33 -ve \
'buf = Parser::Source::Buffer.new("example.rb"); buf.source = "foo(:bar)"; p Prism::Translation::Parser33.new.tokenize(buf)[2]'
ruby 3.4.0dev (2024-09-01T11:00:13Z master eb144ef91e) [x86_64-darwin23]
[[:tIDENTIFIER, ["foo", #<Parser::Source::Range example.rb 0...3>]], [:tLPAREN, ["(", #<Parser::Source::Range example.rb 3...4>]],
[:tSYMBOL, ["bar", #<Parser::Source::Range example.rb 4...8>]], [:tRPAREN, [")", #<Parser::Source::Range example.rb 8...9>]]]
```

After the update, the parser now returns `tLPAREN2` token for the same input:

```console
$ bundle exec ruby -Ilib -rprism -rprism/translation/parser33 -ve \
'buf = Parser::Source::Buffer.new("example.rb"); buf.source = "foo(:bar)"; p Prism::Translation::Parser33.new.tokenize(buf)[2]'
ruby 3.4.0dev (2024-09-01T11:00:13Z master eb144ef91e) [x86_64-darwin23]
[[:tIDENTIFIER, ["foo", #<Parser::Source::Range example.rb 0...3>]], [:tLPAREN2, ["(", #<Parser::Source::Range example.rb 3...4>]],
[:tSYMBOL, ["bar", #<Parser::Source::Range example.rb 4...8>]], [:tRPAREN, [")", #<Parser::Source::Range example.rb 8...9>]]]
```

The `PARENTHESIS_LEFT` token in Prism is classified as either `tLPAREN` or `tLPAREN2` in the Parser gem.
The tokens that were previously all classified as `tLPAREN` are now also classified to `tLPAREN2`.

With this change, the following code could be removed from `test/prism/ruby/parser_test.rb`:

```diff
-          when :tLPAREN
-            actual_token[0] = expected_token[0] if expected_token[0] == :tLPAREN2
```

04d6f3478d
2024-09-07 22:36:38 +00:00
Nobuyoshi Nakada
f97332a3a3
Preserve encoding in exception message of Float 2024-09-07 16:34:28 +09:00
Nobuyoshi Nakada
c1862cbb89
[Bug #20719] Float argument must be ASCII compatible 2024-09-07 16:06:14 +09:00
Jonathan Calvert
c1a510a8df
[Bug #20718] Free non-RTypedData objects
Allow objects that are not of type `RTypedData` to use the default
free function, as `RTYPEDDATA_EMBEDDED_P` can return a false positive
when casting non-`RTypedData` objects.
2024-09-07 12:19:47 +09:00
Mads Ohm Larsen
6dc9384694 [ruby/rdoc] Add more space after magnifying glass
(https://github.com/ruby/rdoc/pull/1173)

6a9cad4c54
2024-09-06 21:26:17 +00:00
KJ Tsanaktsidis
731805ddde Add an explicit check for broken libunwind builds
Libunwind as packaged in MacOS cannot actually unwind code which has
pointer authentication on, because _LIBUNWIND_IS_NATIVE_ONLY is not
defined. Add a check for this, and prefer building with working
unwinding over pointer authentication if we must make a choice.
2024-09-06 16:51:19 -04:00
Peter Zhu
2865148a5a Revert "Check for both aarch64 and arm64 arch's for pac-ret"
This reverts commit 6a746e1bc9.

This patch breaks the C level backtrace on macOS ARM machines.
2024-09-06 16:51:19 -04:00
David Rodríguez
b0adae7fb2 [rubygems/rubygems] Remove unnecessary "./" when appending string to uri
732679306d
2024-09-06 18:44:38 +00:00
David Rodríguez
fe1bace43c [rubygems/rubygems] Fix gem install does-not-exist being super slow
Every time a gem is not found in the Compact Index API, RubyGems will
fallback to the full index, which is very slow. This is unnecessary
because both indexes should be providing the same gems, so if a gem
can't be found in the Compact Index API, it won't be found in the full
index.

We _do_ want a fallback to the full index, whenever the Compact Index
API is not implemented. To detect that, we check that the API responds
to the "/versions" endpoint, just like Bundler does.

Before:

```
$ time gem install fooasdsfafs
ERROR:  Could not find a valid gem 'fooasdsfafs' (>= 0) in any repository
gem  20,77s user 0,59s system 96% cpu 22,017 total
```

After:

```
$ time gem install fooasdsfafs
ERROR:  Could not find a valid gem 'fooasdsfafs' (>= 0) in any repository
gem  5,02s user 0,09s system 91% cpu 5,568 total
```

c0d6b9eea7
2024-09-06 18:44:37 +00:00
David Rodríguez
2a17b4f022 [rubygems/rubygems] Deprecate constant that has been unused for a long time
282dbb3d62
2024-09-06 18:44:37 +00:00
David Rodríguez
4478ca3113 [rubygems/rubygems] Remove incorrect documentation
This exception has not been raised for a long time.

a6271a0b21
2024-09-06 18:44:36 +00:00
David Rodríguez
53f784178a [rubygems/rubygems] Remove unreachable code
Nothing is actually raising this at the moment.

3b824ca7a6
2024-09-06 18:44:36 +00:00
Jun Aruga
ad742de79b [ruby/openssl] Fix test_provider.rb in FIPS.
7bdbc52100
2024-09-06 16:58:18 +00:00
Nobuyoshi Nakada
30176e3f23 [rubygems/rubygems] Ensure that the lock file will be removed
2706acb271
2024-09-06 14:46:43 +00:00
Nobuyoshi Nakada
6dd917bd01 [rubygems/rubygems] Workaround for TruffleRuby
b82e43fd54
2024-09-06 14:46:42 +00:00
Nobuyoshi Nakada
5afee4d795 [rubygems/rubygems] Remove the lock file for binstubs
https://github.com/rubygems/rubygems/pull/7806#issuecomment-2241662488

4f06ee234a
2024-09-06 14:46:42 +00:00
Peter Zhu
6bf519ba81 Remove unneeded rb_darray_append_impl 2024-09-06 09:56:59 -04:00
Nobuyoshi Nakada
37712c1ed6
Prefer constants for shutdown over magic numbers 2024-09-06 21:58:01 +09:00
Jean Boussier
bc85c8d852 Implement Array#fetch_values
[Feature #20702]

Works the same way than `Hash#fetch_values` for for array.
2024-09-06 12:40:32 +02:00
Nobuyoshi Nakada
214668fccb
[Feature #20707] Fix negative UTC offset conversion
In short, get rid of division and modulo of negative integers.
2024-09-06 15:53:46 +09:00
Nobuyoshi Nakada
7387a09791 [ruby/digest] Suppress md5 deprecation warnings by gcc as well as clang
76878e3201
2024-09-06 05:58:21 +00:00
Hiroshi SHIBATA
0e7b6e348f Merge GH-11492 2024-09-06 14:45:17 +09:00
Hiroshi SHIBATA
74c4e562e2 Warn missing irb cases 2024-09-06 14:45:17 +09:00
Hiroshi SHIBATA
1b4f394c52 Only provide force_activate. Because it's hard to determine require name. 2024-09-06 14:45:17 +09:00
Hiroshi SHIBATA
69d0e690bb Added force_require for binding.irb
When we make irb to bundled gems, binding.irb with bundle exec is not
working without irb declaration of Gemfile.

This force_require makes to load irb without Gemfile.
2024-09-06 14:45:17 +09:00
Hiroshi SHIBATA
e43d701f09 Warn irb, reline for Ruby 3.5 2024-09-06 14:45:17 +09:00
git
81b74c9fad Update default gems list at e17d91459c [ci skip] 2024-09-06 00:32:47 +00:00
Hiroshi SHIBATA
e17d91459c [ruby/time] Bump up v0.4.0
a14fa00ef7
2024-09-06 00:31:38 +00:00
Jean Boussier
72acd1c8b1 [ruby/time] Do not redefine Time#xmlschema if it already exists
[Feature #20707]

Ruby 3.4 will define this method natively, so the time gem shouldn't
redefine it with a slower version.

f05099ce38
2024-09-05 22:37:35 +00:00
Takashi Kokubun
f250296efa
YJIT: Speed up block_assumptions_free (#11556) 2024-09-05 12:39:57 -07:00
Peter Zhu
cf3b62b545 Fix check_tempfile_leak in leakchecker.rb
The instance variable @tmpfile was removed in ddcfc9f so check_tempfile_leak
did not work.
2024-09-05 14:03:39 -04:00
Jean Boussier
57e3fc32ea Move Time#xmlschema in core and optimize it
[Feature #20707]

Converting Time into RFC3339 / ISO8601 representation is an significant
hotspot for applications that serialize data in JSON, XML or other formats.

By moving it into core we can optimize it much further than what `strftime` will
allow.

```
compare-ruby: ruby 3.4.0dev (2024-08-29T13:11:40Z master 6b08a50a62) +YJIT [arm64-darwin23]
built-ruby: ruby 3.4.0dev (2024-08-30T13:17:32Z native-xmlschema 34041ff71f) +YJIT [arm64-darwin23]
warming up......

|                        |compare-ruby|built-ruby|
|:-----------------------|-----------:|---------:|
|time.xmlschema          |      1.087M|    5.190M|
|                        |           -|     4.78x|
|utc_time.xmlschema      |      1.464M|    6.848M|
|                        |           -|     4.68x|
|time.xmlschema(6)       |    859.960k|    4.646M|
|                        |           -|     5.40x|
|utc_time.xmlschema(6)   |      1.080M|    5.917M|
|                        |           -|     5.48x|
|time.xmlschema(9)       |    893.909k|    4.668M|
|                        |           -|     5.22x|
|utc_time.xmlschema(9)   |      1.056M|    5.707M|
|                        |           -|     5.40x|
```
2024-09-05 19:23:12 +02:00
mterada1228
d4de8aef37 rake install command is failed (#1170)
* `rake install` command is failed

\### Problems

Several file paths were changed by following PR.

- 4211292ffe
- d7bca12c13

Because rdoc.gemspec doesn't take in this changes,
the `rake install` command is permanently failed.

\### Test

\#### before

```console
❯ bundle exec rake install
Running RuboCop...
Inspecting 4 files
....

4 files inspected, no offenses detected

Tip: Based on detected gems, the following RuboCop extension libraries
might be helpful:
  * rubocop-rake (https://rubygems.org/gems/rubocop-rake)

You can opt out of this message by adding the following to your config
(see
https://docs.rubocop.org/rubocop/extensions.html#extension-suggestions
for more options):
  AllCops:
    SuggestExtensions: false
rake aborted!
Running `gem build -V
/Users/mterada/dev/redDataTools/remove_dependency/rdoc/rdoc.gemspec`
failed with the following output:

WARNING:  See https://guides.rubygems.org/specification-reference/ for
help
ERROR:  While executing gem ... (Gem::InvalidSpecificationException)
    ["RI.rdoc", "lib/rdoc/alias.rb", "lib/rdoc/anon_class.rb",
"lib/rdoc/any_method.rb", "lib/rdoc/attr.rb",
"lib/rdoc/class_module.rb", "lib/rdoc/constant.rb",
"lib/rdoc/context.rb", "lib/rdoc/context/section.rb",
"lib/rdoc/extend.rb", "lib/rdoc/ghost_method.rb", "lib/rdoc/include.rb",
"lib/rdoc/meta_method.rb", "lib/rdoc/method_attr.rb",
"lib/rdoc/mixin.rb", "lib/rdoc/normal_class.rb",
"lib/rdoc/normal_module.rb", "lib/rdoc/require.rb",
"lib/rdoc/single_class.rb", "lib/rdoc/top_level.rb"] are not files

/Users/mterada/.rbenv/versions/3.1.0/bin/bundle:25:in `load'
/Users/mterada/.rbenv/versions/3.1.0/bin/bundle:25:in `<main>'
Tasks: TOP => install => build
(See full trace by running task with --trace)
```

\#### after

```console
❯ bundle exec rake install
Running RuboCop...
Inspecting 4 files
....

4 files inspected, no offenses detected

Tip: Based on detected gems, the following RuboCop extension libraries might be helpful:
  * rubocop-rake (https://rubygems.org/gems/rubocop-rake)

You can opt out of this message by adding the following to your config (see https://docs.rubocop.org/rubocop/extensions.html#extension-suggestions for more options):
  AllCops:
    SuggestExtensions: false
rdoc 6.7.0 built to pkg/rdoc-6.7.0.gem.
rdoc (6.7.0) installed.
```

* Add a `bundle exec rake install` step to github workflow

* make intentionally CI failed

* Revert "make intentionally CI failed"

This reverts commit 9fc5dd9423a024594ad26d86a8a6af829e7017f8.
2024-09-05 16:53:31 +00:00
git
ffebc1c7c7 Update default gems list at 721a2ceecf [ci skip] 2024-09-05 12:49:01 +00:00
Mari Imaizumi
721a2ceecf [ruby/reline] Bump version to 0.5.10
(https://github.com/ruby/reline/pull/745)

0ebd54f675
2024-09-05 12:48:02 +00:00
Mari Imaizumi
be6d23646f [ruby/reline] Prevent a warning for `warning: literal string will be
frozen in the future`
(https://github.com/ruby/reline/pull/744)

69c95c8b6a
2024-09-05 12:22:34 +00:00
Étienne Barrié
bf9879791a Optimized instruction for Hash#freeze
If a Hash which is empty or only using literals is frozen, we detect
this as a peephole optimization and change the instructions to be
`opt_hash_freeze`.

[Feature #20684]

Co-authored-by: Jean Boussier <byroot@ruby-lang.org>
2024-09-05 12:46:02 +02:00
Étienne Barrié
a99707cd9c Optimized instruction for Array#freeze
If an Array which is empty or only using literals is frozen, we detect
this as a peephole optimization and change the instructions to be
`opt_ary_freeze`.

[Feature #20684]

Co-authored-by: Jean Boussier <byroot@ruby-lang.org>
2024-09-05 12:46:02 +02:00
Jean Boussier
63cbe3f6ac Proof of Concept: Allow to prevent fork from happening in known fork unsafe API
[Feature #20590]

For better of for worse, fork(2) remain the primary provider of
parallelism in Ruby programs. Even though it's frowned uppon in
many circles, and a lot of literature will simply state that only
async-signal safe APIs are safe to use after `fork()`, in practice
most APIs work well as long as you are careful about not forking
while another thread is holding a pthread mutex.

One of the APIs that is known cause fork safety issues is `getaddrinfo`.
If you fork while another thread is inside `getaddrinfo`, a mutex
may be left locked in the child, with no way to unlock it.

I think we could reduce the impact of these problem by preventing
in for the most notorious and common cases, by locking around
`fork(2)` and known unsafe APIs with a read-write lock.
2024-09-05 11:43:46 +02:00
Jun Aruga
2e5680d304 [ruby/openssl] Fix test_pkey_rsa.rb in FIPS.
* test_sign_verify
  I created the signature text (`signature_encoded.txt`), that is used as a
  text to create the `signature0` in the `test_sign_verify` by the following
  steps with the `openssl` CLI on FIPS module.
  ```
  $ OPENSSL_DIR="${HOME}/.local/openssl-3.4.0-dev-fips-debug-3c6e114959"
  $ export OPENSSL_CONF="${OPENSSL_DIR}/ssl/openssl_fips.cnf"

  $ echo -n "Sign me!" > data.txt
  $ "${OPENSSL_DIR}/bin/openssl" dgst -sha256 -sign test/openssl/fixtures/pkey/rsa2048.pem data.txt > signature.txt
  $ cat signature.txt | base64 > signature_encoded.txt
  ```

091f3eb421
2024-09-05 08:41:30 +00:00
Nobuyoshi Nakada
08e142b209 Refactor getlogin and getpw* functions
- Extract functions to check not-found conditions
- Set the length to the result of `rb_getlogin`
- Reentrant versions return an error numeber but not `errno`
- Check maybe-undefined macros with `defined`
2024-09-05 16:55:54 +09:00
git
630bfd36f9 Update bundled gems list as of 2024-09-04 2024-09-05 07:01:45 +00:00
ydah
32680f543c Implement AND/OR NODE operator locations 2024-09-05 13:03:28 +09:00