summaryrefslogtreecommitdiff
path: root/parse.y
diff options
context:
space:
mode:
Diffstat (limited to 'parse.y')
-rw-r--r--parse.y8
1 files changed, 7 insertions, 1 deletions
diff --git a/parse.y b/parse.y
index bb9e81ce18..843f14fda1 100644
--- a/parse.y
+++ b/parse.y
@@ -7931,7 +7931,13 @@ gettable_gen(struct parser_params *parser, ID id)
return NEW_FALSE();
}
else if (id == keyword__FILE__) {
- return NEW_STR(STR_NEW2(ruby_sourcefile));
+ VALUE str = rb_external_str_new_with_enc(ruby_sourcefile, strlen(ruby_sourcefile),
+ rb_filesystem_encoding());
+ if (rb_enc_str_coderange(str) != ENC_CODERANGE_7BIT &&
+ ENCODING_GET(str) == rb_usascii_encindex()) {
+ rb_enc_associate(str, rb_ascii8bit_encoding());
+ }
+ return NEW_STR(str);
}
else if (id == keyword__LINE__) {
return NEW_LIT(INT2FIX(ruby_sourceline));