Skip to content

Conversation

ekohl
Copy link
Contributor

@ekohl ekohl commented Jun 23, 2022

This PR suppresses the following Psych.safe_load args warn when using Psych 3.1.0 (Ruby 2.6+).

Passing permitted_classes with the 2nd argument of Psych.safe_load is deprecated. Use keyword argument like Psych.safe_load(yaml, permitted_classes: ...) instead.

This is needed because in Psych 4 (included in Ruby 3.1) it is no longer allowed to use the non-keyword style.

An alternative to #2484

This PR suppresses the following `Psych.safe_load` args warn when using
Psych 3.1.0 (Ruby 2.6+).

    Passing permitted_classes with the 2nd argument of Psych.safe_load
    is deprecated. Use keyword argument like Psych.safe_load(yaml,
    permitted_classes: ...) instead.

This is needed because in Psych 4 (included in Ruby 3.1) it is no longer
allowed to use the non-keyword style.
@ekohl ekohl requested a review from a team as a code owner June 23, 2022 11:48
@puppetlabs-jenkins
Copy link
Collaborator

Can one of the admins verify this patch?

@ekohl
Copy link
Contributor Author

ekohl commented Jun 23, 2022

Perhaps I should have used FACT-3123 instead.

res = nil
begin
res = YAML.safe_load(output, [Symbol, Time])
res = if Gem::Version.new(Psych::VERSION) >= Gem::Version.new('3.1.0') # Ruby 2.6+
Copy link
Contributor

Choose a reason for hiding this comment

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

We used the exact fix in other places, for example bolt. 👍 from my side.

@joshcooper joshcooper merged commit 832c9b5 into puppetlabs:main Aug 9, 2022
@ekohl ekohl deleted the FACT-3102-ruby-3.1 branch August 10, 2022 12:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants