Skip to content

Fix File.open Ruby 3.2 regression in FileSystem::Uniquefile#450

Open
JonasVerhofste wants to merge 1 commit into
OpenVoxProject:mainfrom
JonasVerhofste:main
Open

Fix File.open Ruby 3.2 regression in FileSystem::Uniquefile#450
JonasVerhofste wants to merge 1 commit into
OpenVoxProject:mainfrom
JonasVerhofste:main

Conversation

@JonasVerhofste
Copy link
Copy Markdown
Contributor

Short description

Ruby 3.2 changed the method call of File.open() such that it always requires perm as an argument if you want to pass other opts. It also started requiring opts to be splatted, instead of passed as a hash.

I didn't go through the whole codebase to see if there are other places where this regression (can) happen(s). I just ran into this one when working on an older internal provider that uses Puppet::FileSystem::Uniquefile.new() directly (not through the open_tmp() method).

Old method definition:

open(filename, mode="r" [, opt]) → file
open(filename [, mode [, perm]] [, opt]) → file
open(filename, mode="r" [, opt]) {|file| block } → obj
open(filename [, mode [, perm]] [, opt]) {|file| block } → obj

New method definition:

open(path, mode = 'r', perm = 0666, **opts) → file
open(path, mode = 'r', perm = 0666, **opts) {|f| ... } → object

Checklist

I have:

Ruby 3.2 changed the method call of File.open() such that it always
requires `perm` as an argument if you want to pass other `opts`.
It also started requiring opts to be splatted, instead of passed as a hash.

Old method definition:
```
open(filename, mode="r" [, opt]) → file
open(filename [, mode [, perm]] [, opt]) → file
open(filename, mode="r" [, opt]) {|file| block } → obj
open(filename [, mode [, perm]] [, opt]) {|file| block } → obj
```

New method definition:
```
open(path, mode = 'r', perm = 0666, **opts) → file
open(path, mode = 'r', perm = 0666, **opts) {|f| ... } → object
```

Signed-off-by: Jonas Verhofsté <jonas@verhofste.tech>
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.

1 participant