To simplify the implementation, this makes Object#singleton_method
call the same method called by Object#method (rb_obj_method), then
check that the returned Method is defined before the superclass of the
object's singleton class. To keep the same error messages, it rescues
exceptions raised by rb_obj_method, and then raises its own exception.
Fixes [Bug #20620]
Rather than checking the class we can check the type.
This is very subtly different for String subclasses, but I think it's
OK.
We also save on checking the type again in the fast path.
https://github.com/flori/json/commit/772a0201ab
On my `JSON.dump` benchmark it shows up as 6% of runtime, compared
to 40% for `convert_UTF8_to_JSON`.
Since the vast majority of the time this function is called we
still have some buffer capacity, we might as well check that
first and skip the expensive loop etc.
With this change my profiler now report this function as 0.7%,
so almost 10x better.
https://github.com/flori/json/commit/a7206bf2db
Given that we called `rb_enc_str_asciionly_p`, if the string encoding
isn't valid UTF-8, we can't know it very cheaply by checking the
encoding and coderange that was just computed by Ruby, rather than
to do it ourselves.
Also Ruby might have already computed that earlier.
https://github.com/flori/json/commit/4b04c469d5
`PTY.spawn` with a block detaches the spawned process and leaves it
running in background even after exiting the given block. It is the
responsibility of the caller to clean up the yielded IOs and PID.
https://github.com/ruby/ruby/actions/runs/11148759246/job/30986064044#step:13:950
```
Leaked file descriptor: Reline::Test#test_tty_amibuous_width: 9 : #<File:/dev/pts/0>
Leaked file descriptor: Reline::Test#test_tty_amibuous_width: 10 : #<File:/dev/pts/0>
Leaked file descriptor: Reline::Test#test_tty_amibuous_width: 11 : #<File:/dev/pts/1>
Leaked file descriptor: Reline::Test#test_tty_amibuous_width: 12 : #<File:/dev/pts/1>
Leaked file descriptor: Reline::Test#test_tty_amibuous_width: 13 : #<File:/dev/pts/2>
Leaked file descriptor: Reline::Test#test_tty_amibuous_width: 14 : #<File:/dev/pts/2>
```
https://github.com/ruby/reline/commit/f9f90da9e4