Skip to content

Commit

Permalink
Showing 2 changed files with 12 additions and 8 deletions.
2 changes: 1 addition & 1 deletion core/src/main/java/org/jruby/RubyComparable.java
Original file line number Diff line number Diff line change
@@ -145,8 +145,8 @@ private static IRubyObject callCmpMethod(ThreadContext context, IRubyObject recv

return RubyBoolean.newBoolean(runtime, cmpint(context, result, recv, other) == 0);
} catch (RaiseException e) {
cmpFailed(context);
if (e.getException().kind_of_p(context, runtime.getStandardError()).isTrue()) {
cmpFailed(context);
// clear error info resulting from failure to compare (JRUBY-3292)
runtime.getGlobalVariables().set("$!", savedError);
return returnValueOnError;
18 changes: 11 additions & 7 deletions core/src/main/java/org/jruby/RubyNumeric.java
Original file line number Diff line number Diff line change
@@ -473,14 +473,18 @@ protected final RubyArray doCoerce(ThreadContext context, IRubyObject other, boo
try {
result = coerceBody(context, other);
} catch (RaiseException e) {
RubyWarnings warnings = context.runtime.getWarnings();
warnings.warn("Numerical comparison operators will no more rescue exceptions of #coerce");
warnings.warn("in the next release. Return nil in #coerce if the coercion is impossible.");
if (err) {
coerceFailed(context, other);
if (e.getException().kind_of_p(context, runtime.getStandardError()).isTrue()) {
RubyWarnings warnings = context.runtime.getWarnings();
warnings.warn("Numerical comparison operators will no more rescue exceptions of #coerce");
warnings.warn("in the next release. Return nil in #coerce if the coercion is impossible.");
if (err) {
coerceFailed(context, other);
}
context.runtime.getGlobalVariables().set("$!", savedError); // Restore $!
return null;
} else {
throw e;
}
context.runtime.getGlobalVariables().set("$!", savedError); // Restore $!
return null;
}

if (!(result instanceof RubyArray) || ((RubyArray) result).getLength() != 2) {

0 comments on commit 1479100

Please sign in to comment.