alexinbeijing / gmail.com wrote:
> Feature #12016: More informative error message when Symbol encoding is invalid
> https://bugs.ruby-lang.org/issues/12016

Calling RSTRING_PTR on any function return value directly is dangerous
because of GC.  PRI*VALUE format strings were introduced to help make
avoiding this danger easier, and the '+' modifier will call inspect for
you.

How about the following?

	rb_raise(rb_eEncodingError,
		"encoding %s is invalid for symbol :%+"PRIsVALUE,
                rb_enc_name(rb_enc_get(str)),
		str);

(also wrapping at 80 cols, some of us use big fonts)

Unsubscribe: <mailto:ruby-core-request / ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>