Conversation
hsbt
commented
Jan 29, 2026
- Handle RB_OBJ_INFECT
- Use TypedData instead of Data_Wrap_Struct
There was a problem hiding this comment.
Pull request overview
This pull request updates the iconv extension to support Ruby 4.1 by migrating from deprecated Ruby C API functions to their modern equivalents and conditionally handling the removed OBJ_INFECT macro.
Changes:
- Migrated from
Data_Wrap_StructtoTypedData_Wrap_Structfor type-safe object wrapping - Replaced
DATA_PTRandRDATAaccess withRTYPEDDATA_DATAandrb_typeddata_is_kind_of - Added conditional compilation guards for the deprecated
OBJ_INFECTmacro
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| ext/iconv/extconf.rb | Added feature detection for RB_OBJ_INFECT to support conditional compilation |
| ext/iconv/iconv.c | Migrated to TypedData API and added conditional guards for OBJ_INFECT usage |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
ext/iconv/extconf.rb
Outdated
| raise "vasprintf is required for Ruby 1.8" | ||
| end | ||
| have_func("rb_sys_fail_str", "ruby.h") | ||
| # Check if OBJ_INFECT macro is available (removed in Ruby 3.0+) |
There was a problem hiding this comment.
The function have_func is used to check for RB_OBJ_INFECT, but OBJ_INFECT (which is what's actually used in the C code) is a macro, not a function. The have_func check will not properly detect macros. This means the conditional compilation guard in iconv.c may not work correctly, potentially causing compilation failures on Ruby versions where OBJ_INFECT has been removed. Consider using a compile-time check instead, such as try_compile with a test snippet that uses OBJ_INFECT, or checking the Ruby version directly.
9f8dba2 to
e4a2b31
Compare
* Handle RB_OBJ_INFECT * Use TypedData instead of Data_Wrap_Struct