More informative error message when Symbol encoding is invalid
When a symbol literal is invalid in the source file's encoding, an
EncodingError exception is raised, with the following message:
invalid encoding symbol. This patches the interpreter so a more informative message is generated, similar to:
encoding UTF-8 is invalid for symbol :"\xC7".
Here is where this originated from: https://github.com/whitequark/parser/issues/252
Updated by normalperson (Eric Wong) over 4 years ago
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
How about the following?
rb_raise(rb_eEncodingError, "encoding %s is invalid for symbol :%+"PRIsVALUE,
(also wrapping at 80 cols, some of us use big fonts)
Updated by nobu (Nobuyoshi Nakada) over 4 years ago
- Status changed from Open to Closed
Applied in changeset r53650.
symbol.c: more informative error message
- symbol.c (sym_check_asciionly): more informative error message with the encoding name and the inspected content. [ruby-core:73398] [Feature #12016]