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

Respect Regexp.compile method signature #9351

Merged
merged 1 commit into from
Jun 18, 2024

Conversation

ekohl
Copy link
Contributor

@ekohl ekohl commented May 18, 2024

As far as I can tell, Regexp.compile has never accepted a third parameter to Regexp.compile until Ruby 3.2. There it actually is a timeout parameter. In older versions it was discarded as an invalid input. It's unclear to me if this parameter ever worked in the first place.

This PR attemps to still make it work as it was originally intended, but it's unclear what the original goal even was. Perhaps it's better to make an incompatible change to drop the third parameter and instead enhance the flags parameter to support N as a value.

@ekohl ekohl requested a review from a team as a code owner May 18, 2024 16:44
@puppetlabs-jenkins
Copy link
Collaborator

Can one of the admins verify this patch?

@joshcooper
Copy link
Contributor

I believe Regexp.compile accepted a third argument in Ruby 1.8, but in 1.9 it was changed to always ignore it ruby/ruby@98e6f9a I'm thinking we should do something similar:

if encoding
  Puppet.warn_once(
    'deprecations', 'regsubst_function_encoding',
    _("The regsubst() function's encoding argument has been ignored since Ruby 1.9 and will be removed in a future release")
  )
end

@ekohl
Copy link
Contributor Author

ekohl commented May 28, 2024

So something like this?

@joshcooper
Copy link
Contributor

Something changed with GH Windows runners (see #9371) causing the test failures. Could you rebase on main?

@joshcooper joshcooper added the bug Something isn't working label Jun 13, 2024
Since Ruby 1.9 the encoding argument to Regexp.compile has been ignored
and has been removed since. Starting Ruby 3.2 there is a new third
positional argument for the timeout.

This PR deprecates the old method with encoding and stops passing the
argument, making it a dead parameter.
@ekohl
Copy link
Contributor Author

ekohl commented Jun 15, 2024

Trivial rebase done.

@ekohl
Copy link
Contributor Author

ekohl commented Jun 17, 2024

It's green now.

Copy link
Contributor

@joshcooper joshcooper left a comment

Choose a reason for hiding this comment

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

Thanks @ekohl!

@joshcooper joshcooper merged commit 94d40bc into puppetlabs:main Jun 18, 2024
9 checks passed
@ekohl ekohl deleted the ruby-3.3-regexp-compat branch June 18, 2024 01:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants