Skip to content

Introduce IO.new(..., path:) and promote File#path to IO#path.#6867

Merged
ioquatix merged 6 commits intoruby:masterfrom
ioquatix:io-new-path
Dec 8, 2022
Merged

Introduce IO.new(..., path:) and promote File#path to IO#path.#6867
ioquatix merged 6 commits intoruby:masterfrom
ioquatix:io-new-path

Conversation

@ioquatix
Copy link
Copy Markdown
Member

@ioquatix ioquatix commented Dec 6, 2022

The current semantics for File#path are at best difficult to deal with.

  • Can raise an error.
  • Makes it difficult for things that mock IO, e.g. GZip wrappers have to conditionally detect and add #path.

I've chosen to make this behave more like an attribute in IO#path which should ultimately be compatible with existing code except it can no longer raise an exception in normal usage.

https://bugs.ruby-lang.org/issues/19036

@ioquatix ioquatix requested a review from nobu December 6, 2022 07:58
@headius
Copy link
Copy Markdown
Contributor

headius commented Dec 6, 2022

Looks good to me but shouldn't rb_file_path remain as an alias for rb_io_path?

@headius
Copy link
Copy Markdown
Contributor

headius commented Dec 8, 2022

Looks good to me but shouldn't rb_file_path remain as an alias for rb_io_path?

rb_file_path is not in any of the public header files, so it is not part of the public API and does not need to remain.

@ioquatix
Copy link
Copy Markdown
Member Author

ioquatix commented Dec 8, 2022

I'm going to merge this as is, but:

  • Should we introduce IO#path=?
  • Should we introduce IO#dup(..., path:)?

@ioquatix ioquatix merged commit 6fd5d2d into ruby:master Dec 8, 2022
@ioquatix ioquatix deleted the io-new-path branch December 8, 2022 05:19
headius added a commit to headius/jruby that referenced this pull request Jun 19, 2024
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