New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Regexp's source's encoding is wrong #3014

Closed
nirvdrum opened this Issue Jun 3, 2015 · 1 comment

Comments

Projects
None yet
2 participants
@nirvdrum
Contributor

nirvdrum commented Jun 3, 2015

The docs for the Regexp class are a bit misleading, stating for the source method "Returns the original string of the pattern." However, it appears MRI updates the source to match the encoding from encoding.

Here's an example:

MRI 2.2.2:

> ruby -v -e "r = Regexp.new('Hi', nil, 'e'); p r.encoding; p r.source.encoding"
ruby 2.2.2p95 (2015-04-13 revision 50295) [x86_64-linux]
-e:1: warning: encoding option is ignored - e
#<Encoding:US-ASCII>
#<Encoding:US-ASCII>

MRI 1.9.3:

> ruby -v -e "r = Regexp.new('Hi', nil, 'e'); p r.encoding; p r.source.encoding"
ruby 1.9.3p551 (2014-11-13 revision 48407) [x86_64-linux]
-e:1: warning: encoding option is ignored - e
#<Encoding:US-ASCII>
#<Encoding:US-ASCII>

JRuby 9k:

> bin/jruby -v -e "@method = :new; r = Regexp.send(@method, 'Hi', nil, 'e'); p r.encoding; p r.source.encoding"
jruby 9.0.0.0-SNAPSHOT (2.2.2) 2015-06-03 0430387 Java HotSpot(TM) 64-Bit Server VM 25.45-b02 on 1.8.0_45-b14 +jit [linux-amd64]
-e:1: warning: encoding option is ignored - e
#<Encoding:US-ASCII>
#<Encoding:UTF-8>

JRuby 1.7.20:

> ruby -v -e "r = Regexp.new('Hi', nil, 'e'); p r.encoding; p r.source.encoding"
jruby 1.7.20 (1.9.3p551) 2015-05-04 3086e6a on Java HotSpot(TM) 64-Bit Server VM 1.8.0_45-b14 +jit [linux-amd64]
-e:1 warning: encoding option is ignored - e
#<Encoding:US-ASCII>
#<Encoding:UTF-8>

@nirvdrum nirvdrum changed the title from Regexp's source encoding is wrong to Regexp's source's encoding is wrong Jun 3, 2015

@enebo enebo added this to the JRuby 9.2.0.0 milestone May 16, 2017

@enebo

This comment has been minimized.

Member

enebo commented May 16, 2017

This is fixed in 9k and 1.7 is EOL. Resolving against 9.2.0.0 so people see it

@enebo enebo closed this May 16, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment