Skip to content

Conversation

@hsbt
Copy link
Member

@hsbt hsbt commented Jan 29, 2026

  • Handle RB_OBJ_INFECT
  • Use TypedData instead of Data_Wrap_Struct

Copilot AI review requested due to automatic review settings January 29, 2026 05:33
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

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_Struct to TypedData_Wrap_Struct for type-safe object wrapping
  • Replaced DATA_PTR and RDATA access with RTYPEDDATA_DATA and rb_typeddata_is_kind_of
  • Added conditional compilation guards for the deprecated OBJ_INFECT macro

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.

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+)
Copy link

Copilot AI Jan 29, 2026

Choose a reason for hiding this comment

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

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.

Copilot uses AI. Check for mistakes.
@hsbt hsbt force-pushed the ruby-4-1 branch 3 times, most recently from 9f8dba2 to e4a2b31 Compare January 29, 2026 06:21
* Handle RB_OBJ_INFECT
* Use TypedData instead of Data_Wrap_Struct
@hsbt hsbt merged commit 569c42b into master Jan 29, 2026
80 checks passed
@hsbt hsbt deleted the ruby-4-1 branch January 29, 2026 07:09
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