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

drop dnf_options from P::P::Update #845

Merged
merged 1 commit into from
May 6, 2024
Merged

drop dnf_options from P::P::Update #845

merged 1 commit into from
May 6, 2024

Conversation

evgeni
Copy link
Member

@evgeni evgeni commented May 6, 2024

No description provided.

@evgeni evgeni force-pushed the no-dnf-options branch 3 times, most recently from 218353d to 481ac14 Compare May 6, 2024 14:49
@ehelms
Copy link
Member

ehelms commented May 6, 2024

Is this largely because it's unused now?

@evgeni
Copy link
Member Author

evgeni commented May 6, 2024

Is this largely because it's unused now?

And because something leaks and this fixes it.

@ehelms
Copy link
Member

ehelms commented May 6, 2024

Is this largely because it's unused now?

And because something leaks and this fixes it.

Were you able to figure out how or why? Or are we chalking this up to "foreman-maintain does some crazy meta programming crap?"

@evgeni
Copy link
Member Author

evgeni commented May 6, 2024

I think because you're passing in a global variable @dnf_options it ends up modifying that, instead of a local one

(that's why in python you never define the signature of such functions as def do(something=[]) but def do(something=None) and then do if something is None: something = [])

@evgeni
Copy link
Member Author

evgeni commented May 6, 2024

% cat /tmp/test.rb 
def update(options: [])
  options << 'nice'
  puts(options)
end

@my_fancy_options = ['lol']

update(options: @my_fancy_options)
puts(@my_fancy_options)

% ruby /tmp/test.rb
lol
nice
lol
nice

but

% cat /tmp/test.rb 
def update(options: nil)
  options |= []
  options << 'nice'
  puts(options)
end

@my_fancy_options = ['lol']

update(options: @my_fancy_options)
puts(@my_fancy_options)

% ruby /tmp/test.rb
lol
nice
lol

@evgeni evgeni merged commit 9ac8a20 into master May 6, 2024
8 checks passed
@evgeni evgeni deleted the no-dnf-options branch May 6, 2024 15:36
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.

2 participants