Project

General

Profile

Actions

Bug #14247

closed

Thread#fetch raise KeyError without key and receiver

Added by znz (Kazuhiro NISHIYAMA) over 6 years ago. Updated over 6 years ago.

Status:
Closed
Target version:
-
ruby -v:
ruby 2.6.0dev (2017-12-27 trunk 61494) [x86_64-linux]
[ruby-core:84508]

Description

I found this by message without Did you mean?.

expected:

% ruby -e 'th=Thread.current;th[:foo]=1;th.fetch(:fooo)'
Traceback (most recent call last):
        1: from -e:1:in `<main>'
-e:1:in `fetch': key not found: "fooo" (KeyError)
Did you mean?  :foo

actual:

% ruby -e 'th=Thread.current;th[:foo]=1;th.fetch(:fooo)'
Traceback (most recent call last):
        1: from -e:1:in `<main>'
-e:1:in `fetch': key not found: fooo (KeyError)

Files

Thread-KeyError.diff (870 Bytes) Thread-KeyError.diff znz (Kazuhiro NISHIYAMA), 12/27/2017 12:05 PM
0001-Fix-KeyError-key-receiver-of-Thread-fetch.patch (1.22 KB) 0001-Fix-KeyError-key-receiver-of-Thread-fetch.patch znz (Kazuhiro NISHIYAMA), 12/27/2017 01:54 PM

Updated by nobu (Nobuyoshi Nakada) over 6 years ago

The given key is :fooo symbol, so the message should be :fooo but not "fooo".
Use "%+"PRIsVALUE instead of "\"%"PRIsVALUE"\"" for inspection.

Updated by znz (Kazuhiro NISHIYAMA) over 6 years ago

Update patch.

% ruby -e 'th=Thread.current;th[:foo]=1;th.fetch(:fooo)'
Traceback (most recent call last):
        1: from -e:1:in `<main>'
-e:1:in `fetch': key not found: :fooo (KeyError)
Did you mean?  :foo
% ruby -e 'th=Thread.current;th[:foo]=1;th.fetch("fooo")'
Traceback (most recent call last):
        1: from -e:1:in `<main>'
-e:1:in `fetch': key not found: "fooo" (KeyError)
Did you mean?  :foo

Updated by shevegen (Robert A. Heiler) over 6 years ago

Indeed. I actually had to look twice to see the error. :)

Actions #4

Updated by Anonymous over 6 years ago

  • Status changed from Assigned to Closed

Applied in changeset trunk|r61507.


Fix KeyError#{key,receiver} of Thread#fetch

[ruby-core:84508] [Bug #14247]

Actions #5

Updated by nagachika (Tomoyuki Chikanaga) over 6 years ago

  • Backport changed from 2.3: UNKNOWN, 2.4: UNKNOWN, 2.5: UNKNOWN to 2.3: DONTNEED, 2.4: DONTNEED, 2.5: REQUIRED

Updated by naruse (Yui NARUSE) over 6 years ago

  • Backport changed from 2.3: DONTNEED, 2.4: DONTNEED, 2.5: REQUIRED to 2.3: DONTNEED, 2.4: DONTNEED, 2.5: DONE

ruby_2_5 r61583 merged revision(s) 61507.

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0