Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: jruby/jruby
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 26664476024b
Choose a base ref
...
head repository: jruby/jruby
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 342268d2cecc
Choose a head ref
  • 2 commits
  • 2 files changed
  • 2 contributors

Commits on Jan 21, 2018

  1. Fix Symbol#inspect of UTF_16/UTF_32

    Stop to append byte before inspect string.
    For example, when an encoding of `symbolBytes` is UTF_16LE, "a" is
    `[0x61, 0x00]`. If we append `":"` (0x3A) to `symbolBytes` before
    inspect it, bytes are `[0x3A, 0x61, 0x00]` with UTF_16LE encoding.
    This is not what we want to get. This commit chnages the order of
    inspecting and appending to avoid this.
    
    Ref: https://github.com/ruby/ruby/blob/v2_5_0/string.c#L10402
    yui-knk committed Jan 21, 2018
    Copy the full SHA
    f4381eb View commit details

Commits on Jan 22, 2018

  1. Merge pull request #4994 from yui-knk/fix_test_ascii_incomat_inspect

    Fix `Symbol#inspect` of UTF_16/UTF_32
    enebo authored Jan 22, 2018
    Copy the full SHA
    342268d View commit details
Showing with 8 additions and 14 deletions.
  1. +8 −13 core/src/main/java/org/jruby/RubySymbol.java
  2. +0 −1 test/mri/excludes/TestSymbol.rb
21 changes: 8 additions & 13 deletions core/src/main/java/org/jruby/RubySymbol.java
Original file line number Diff line number Diff line change
@@ -256,27 +256,22 @@ public IRubyObject inspect(ThreadContext context) {
}

final RubyString inspect(final Ruby runtime) {
ByteList result = new ByteList(symbolBytes.getRealSize() + 1);
result.setEncoding(symbolBytes.getEncoding());
result.append((byte)':');
result.append(symbolBytes);

// TODO: 1.9 rb_enc_symname_p
Encoding resenc = runtime.getDefaultInternalEncoding();
if (resenc == null) resenc = runtime.getDefaultExternalEncoding();

RubyString str = RubyString.newString(runtime, result);
RubyString str = RubyString.newString(runtime, symbolBytes);

if (isPrintable() && (resenc.equals(symbolBytes.getEncoding()) || str.isAsciiOnly()) && isSymbolName19(symbol)) {
return str;
if (!(isPrintable() && (resenc.equals(symbolBytes.getEncoding()) || str.isAsciiOnly()) && isSymbolName19(symbol))) {
str = str.inspect(runtime);
}

str = str.inspect(runtime);
ByteList bytes = str.getByteList();
bytes.set(0, ':');
bytes.set(1, '"');
ByteList result = new ByteList(str.getByteList().getRealSize() + 1);
result.setEncoding(str.getEncoding());
result.append((byte)':');
result.append(str.getBytes());

return str;
return RubyString.newString(runtime, result);
}

@Deprecated
1 change: 0 additions & 1 deletion test/mri/excludes/TestSymbol.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
exclude :test_ascii_incomat_inspect, "needs investigation"
exclude :test_inspect, "needs investigation"
exclude :test_to_proc_arg, "we have plans to do different caching here, see 69662ab8cd1616a2ee076488226a473648fc6267"
exclude :test_to_proc_binding, "needs investigation #4303"