[ruby-core:62969] [ruby-trunk - Bug #9913] [Closed] Digest == throws TypeError when testing against nil

From: eregontp@...
Date: 2014-06-06 21:05:57 UTC
List: ruby-core #62969
Issue #9913 has been updated by Benoit Daloze.

Status changed from Open to Closed
% Done changed from 0 to 100

Applied in changeset r46368.

----------
digest.c: fix #== for non-string arguments

* ext/digest/digest.c (rb_digest_instance_equal):
  fix #== for non-string arguments. [ruby-core:62967] [Bug #9913]
* test/digest/test_digest.rb: add test for above.

----------------------------------------
Bug #9913: Digest == throws TypeError when testing against nil
https://bugs.ruby-lang.org/issues/9913#change-47064

* Author: Bryan Hockey
* Status: Closed
* Priority: Normal
* Assignee: 
* Category: lib
* Target version: 
* ruby -v: ruby 1.9.3p194 (2012-04-20 revision 35410) [x86_64-linux]
* Backport: 2.0.0: UNKNOWN, 2.1: UNKNOWN
----------------------------------------
Also present in ruby -v: jruby 1.7.10 (1.9.3p392) 2014-01-09 c4ecd6b on OpenJDK 64-Bit Server VM 1.7.0_55-b14 [linux-amd64]

To recreate: 

require 'digest'
x = Digest::SHA256.new()
x == nil
TypeError: can't convert nil into String

Workaround:
w1: use #nil?
w2: reverse rhs, lhs, e.g. if nil == some_digest



-- 
https://bugs.ruby-lang.org/

In This Thread

Prev Next