Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Always issue deprecation warning when calling Regexp.new with 3rd positional argument #6976

Merged

Conversation

jeremyevans
Copy link
Contributor

Previously, only certain values of the 3rd argument triggered a deprecation warning.

First step for fix for bug #18797. Support for the 3rd argument will be removed after the release of Ruby 3.2.

Fix minor fallout discovered by the tests.

lib/optparse.rb Outdated Show resolved Hide resolved
lib/optparse.rb Outdated Show resolved Hide resolved
re.c Outdated Show resolved Hide resolved
@jeremyevans jeremyevans force-pushed the regexp.new-3rd-argument-deprecation-18797 branch 2 times, most recently from 7d74d43 to 5de4cce Compare December 21, 2022 19:55
assert_equal(Encoding.find("US-ASCII"), Regexp.new("b..", nil, "n").encoding)
assert_equal("bar", "foobarbaz"[Regexp.new("b..", nil, "n")])
assert_equal(//n, Regexp.new("", nil, "n"))

arg_encoding_none = 32 # ARG_ENCODING_NONE is implementation defined value
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
arg_encoding_none = 32 # ARG_ENCODING_NONE is implementation defined value
arg_encoding_none = //n.options # ARG_ENCODING_NONE is implementation defined value

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks, I committed this suggestion when I rebased.

…itional argument

Previously, only certain values of the 3rd argument triggered a
deprecation warning.

First step for fix for bug #18797.  Support for the 3rd argument
will be removed after the release of Ruby 3.2.

Fix minor fallout discovered by the tests.

Co-authored-by: Nobuyoshi Nakada <nobu@ruby-lang.org>
@jeremyevans jeremyevans force-pushed the regexp.new-3rd-argument-deprecation-18797 branch from 5de4cce to f225cb4 Compare December 22, 2022 18:47
@jeremyevans jeremyevans merged commit 7e8fa06 into ruby:master Dec 22, 2022
koic added a commit to koic/cookiejar that referenced this pull request Feb 18, 2023
Follow up ruby/ruby#6976.

This PR suppresses the following deprecation warning.

```console
% ruby -v
ruby 3.2.1 (2023-02-08 revision 31819e82c8) [x86_64-darwin19]
% bundle exec rake
(snip)

/Users/koic/src/github.com/dwaite/cookiejar/lib/cookiejar/cookie_validation.rb:48: warning:
3rd argument to Regexp.new is deprecated and will be removed in Ruby 3.3; use 2nd argument instead
```
yahonda pushed a commit to yahonda/cookiejar that referenced this pull request Mar 27, 2023
Follow up ruby/ruby#6976.

This PR suppresses the following deprecation warning.

```console
% ruby -v
ruby 3.2.1 (2023-02-08 revision 31819e82c8) [x86_64-darwin19]
% bundle exec rake
(snip)

/Users/koic/src/github.com/dwaite/cookiejar/lib/cookiejar/cookie_validation.rb:48: warning:
3rd argument to Regexp.new is deprecated and will be removed in Ruby 3.3; use 2nd argument instead
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants