Skip to content

Add missing definitions for IO and system standard libraries (find, pathname, pty, stringio, timeout, zlib) - #3171

Open
zonuexe wants to merge 1 commit into
ruby:masterfrom
zonuexe:fix/stdlib-missing-io-system
Open

zonuexe wants to merge 1 commit into
ruby:masterfrom
zonuexe:fix/stdlib-missing-io-system

Conversation

@zonuexe

@zonuexe zonuexe commented Sep 26, 2026 •

Copy link
Copy Markdown
Contributor

Add missing methods, classes, and constants for find, pathname, pty, stringio, timeout, and zlib.

Note: pstore has been excluded as it is in ALUMNI_STDLIBS and planned to be removed from the rbs repo.

Changes

Ruby Method Change C function
Find.prune Add singleton method prune https://github.com/ruby/ruby/blob/v4.0.7/lib/find.rb#L86-L92
Find::VERSION Add constant VERSION https://github.com/ruby/ruby/blob/v4.0.7/lib/find.rb#L4-L6
Pathname#empty? Add method empty? returning bool https://github.com/ruby/ruby/blob/v4.0.7/ext/pathname/pathname.c#L1228-L1236
Pathname.glob Add singleton method glob https://github.com/ruby/ruby/blob/v4.0.7/ext/pathname/pathname.c#L1238-L1248
Pathname#glob Add method glob returning Array[Pathname] or Enumerator https://github.com/ruby/ruby/blob/v4.0.7/ext/pathname/pathname.c#L1250-L1262
PTY::ChildExited Add exception class inheriting RuntimeError https://github.com/ruby/ruby/blob/v4.0.7/ext/pty/pty.c
PTY::ChildExited#status Add method status returning Process::Status https://github.com/ruby/ruby/blob/v4.0.7/ext/pty/pty.c
StringIO#length Add alias of size returning Integer https://github.com/ruby/stringio/blob/master/ext/stringio/stringio.c
StringIO::MAX_LENGTH Add constant MAX_LENGTH https://github.com/ruby/stringio/blob/master/ext/stringio/stringio.c
StringIO::VERSION Add constant VERSION https://github.com/ruby/stringio/blob/master/ext/stringio/stringio.c
Timeout::Error.handle_timeout Add singleton method handle_timeout https://github.com/ruby/timeout/blob/master/lib/timeout.rb
Zlib::InProgressError Add exception class inheriting Zlib::Error https://github.com/ruby/zlib/blob/master/ext/zlib/zlib.c

Comment thread test/stdlib/Find_test.rb Outdated
library "find"

def test_version
assert_instance_of String, Find::VERSION

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Please use assert_const_type for testing constant types.

Comment thread test/stdlib/PStore_test.rb Outdated
Comment on lines +17 to +28
def test_transaction
Dir.mktmpdir do |dir|
file = File.join(dir, "test.pstore")
store = PStore.new(file)
store.transaction do
store[:key] = "val"
end
store.transaction(true) do
assert_equal "val", store[:key]
end
end
end

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Please use assert_send_type to test the type of method.

Comment thread test/stdlib/PTY_test.rb Outdated
Comment on lines +16 to +20
def test_open
PTY.open do |master, slave|
assert_instance_of IO, master
assert_instance_of File, slave
end

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Please use assert_const_type to test constants.

Comment thread test/stdlib/PTY_test.rb
assert_send_type "(*String command) { ([ ::IO, ::IO, ::Integer ]) -> ::Integer } -> nil",
PTY, :getpty, "echo" do |r, w, pid| 1 end
def test_child_exited
assert_equal RuntimeError, PTY::ChildExited.superclass

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Please use assert_const_type to test constants.

Comment on lines +12 to 15
def test_constants
assert_instance_of String, StringIO::VERSION
assert_instance_of Integer, StringIO::MAX_LENGTH
end

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Please use assert_const_type to test constants.

Comment on lines +17 to 21
def test_length
s = StringIO.new("hello")
assert_equal 5, s.length
assert_equal s.size, s.length
end

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Please use assert_send_type to test the method's type.

assert_instance_of Timeout::ExitException, exc
:ok
end
assert_equal :ok, res

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Please use assert_send_type to test the method's type.

Comment thread test/stdlib/Zlib_test.rb
end

def test_in_progress_error
assert_equal Zlib::Error, Zlib::InProgressError.superclass

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Please use assert_const_type for testing constant types.


def test_handle_timeout
res = Timeout::Error.handle_timeout("msg") do |exc|
assert_instance_of Timeout::ExitException, exc

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Please use assert_const_type for testing constant types.

Comment thread test/stdlib/Timeout_test.rb Outdated
testing "singleton(::Timeout)"

def test_version
assert_instance_of String, Timeout::VERSION

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Please use assert_const_type for testing constant types.

…athname, pty, stringio, timeout, zlib)

Add missing methods, classes, and constants for `find`, `pathname`, `pty`, `stringio`, `timeout`, and `zlib`.

Note: `pstore` has been excluded as it is in `ALUMNI_STDLIBS` and planned to be removed from the rbs repo.

| Ruby Method | Change | C function |
|---|---|---|
| `Find.prune` | Add singleton method `prune` | https://github.com/ruby/ruby/blob/v4.0.7/lib/find.rb#L86-L92 |
| `Find::VERSION` | Add constant `VERSION` | https://github.com/ruby/ruby/blob/v4.0.7/lib/find.rb#L4-L6 |
| `Pathname#empty?` | Add method `empty?` returning `bool` | https://github.com/ruby/ruby/blob/v4.0.7/ext/pathname/pathname.c#L1228-L1236 |
| `Pathname.glob` | Add singleton method `glob` | https://github.com/ruby/ruby/blob/v4.0.7/ext/pathname/pathname.c#L1238-L1248 |
| `Pathname#glob` | Add method `glob` returning `Array[Pathname]` or `Enumerator` | https://github.com/ruby/ruby/blob/v4.0.7/ext/pathname/pathname.c#L1250-L1262 |
| `PTY::ChildExited` | Add exception class inheriting `RuntimeError` | https://github.com/ruby/ruby/blob/v4.0.7/ext/pty/pty.c |
| `PTY::ChildExited#status` | Add method `status` returning `Process::Status` | https://github.com/ruby/ruby/blob/v4.0.7/ext/pty/pty.c |
| `StringIO#length` | Add alias of `size` returning `Integer` | https://github.com/ruby/stringio/blob/master/ext/stringio/stringio.c |
| `StringIO::MAX_LENGTH` | Add constant `MAX_LENGTH` | https://github.com/ruby/stringio/blob/master/ext/stringio/stringio.c |
| `StringIO::VERSION` | Add constant `VERSION` | https://github.com/ruby/stringio/blob/master/ext/stringio/stringio.c |
| `Timeout::Error.handle_timeout` | Add singleton method `handle_timeout` | https://github.com/ruby/timeout/blob/master/lib/timeout.rb |
| `Zlib::InProgressError` | Add exception class inheriting `Zlib::Error` | https://github.com/ruby/zlib/blob/master/ext/zlib/zlib.c |
@zonuexe
zonuexe force-pushed the fix/stdlib-missing-io-system branch from 9ef5832 to 3e5819f Compare September 27, 2026 07:35
@zonuexe zonuexe changed the title Add missing definitions for IO and system standard libraries Add missing definitions for IO and system standard libraries (find, pathname, pty, stringio, timeout, zlib) Sep 27, 2026
@zonuexe

zonuexe commented Sep 27, 2026

Copy link
Copy Markdown
Contributor Author

Following the feedback on other PRs regarding ALUMNI_STDLIBS, I have excluded pstore from this PR (I will submit a separate PR to ruby/pstore).
Also updated constant assertions in test files to use assert_const_type.

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