[ruby-core:67062] [ruby-trunk - Bug #10623] rb_hash_delete() can return Qundef in 2.2-rc1

From: ko1@...
Date: 2014-12-23 08:57:32 UTC
List: ruby-core #67062
Issue #10623 has been updated by Koichi Sasada.


At Comment#3, Nobu said that we still need a function which returns no such entry.

We have three possibility:

(a) reutrn Qundef when no entry (current rb_hash_delete())
(b) return nil when no entry
(c) return passed block results or nil when no entry (previous rb_hash_delete())

So my recommendation is:

(1) Implement (a) with other name (ex: rb_hash_delete_key())
(2) Implement (b) named rb_hash_delete() using (1)
(3) Implement (c) for Hash#delete with (1).

@tmm1: is it okay?


----------------------------------------
Bug #10623: rb_hash_delete() can return Qundef in 2.2-rc1
https://bugs.ruby-lang.org/issues/10623#change-50580

* Author: Aman Gupta
* Status: Open
* Priority: Normal
* Assignee: 
* Category: 
* Target version: current: 2.2.0
* ruby -v: ruby 2.2.0dev [x86_64-darwin14]
* Backport: 2.0.0: UNKNOWN, 2.1: UNKNOWN
----------------------------------------
The behavior of rb_hash_delete() has changed from 2.1. Before, it would always return Qnil or VALUE. Now it can also return Qundef, which is breaking the posix-spawn gem's usage:

https://github.com/rtomayko/posix-spawn/blob/master/ext/posix-spawn.c#L242-L258

It also appears RTEST(Qundef) returns true, which causes a segfault in posix-spawn gem here:

https://github.com/rtomayko/posix-spawn/blob/master/ext/posix-spawn.c#L425

I think we should revert back to original behavior before 2.2.0 is released.



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

In This Thread

Prev Next