зеркало из https://github.com/github/ruby.git
* enumerator.c (enumerator_init_copy): prohibit cloning of
generators since Fibers cannot be copied. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14404 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
Родитель
0d49e43be2
Коммит
8fa21bc05f
|
@ -1,3 +1,8 @@
|
|||
Fri Dec 21 14:58:27 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||
|
||||
* enumerator.c (enumerator_init_copy): prohibit cloning of
|
||||
generators since Fibers cannot be copied.
|
||||
|
||||
Fri Dec 21 14:46:07 2007 Tanaka Akira <akr@fsij.org>
|
||||
|
||||
* io.c (Init_IO): define IO::BINARY even if O_BINARY is not exist.
|
||||
|
|
12
enumerator.c
12
enumerator.c
|
@ -285,14 +285,20 @@ enumerator_initialize(int argc, VALUE *argv, VALUE obj)
|
|||
static VALUE
|
||||
enumerator_init_copy(VALUE obj, VALUE orig)
|
||||
{
|
||||
struct enumerator *ptr0 = enumerator_ptr(orig);
|
||||
struct enumerator *ptr1 = enumerator_ptr(obj);
|
||||
struct enumerator *ptr0, *ptr1;
|
||||
|
||||
ptr0 = enumerator_ptr(orig);
|
||||
if (ptr1->fib) {
|
||||
/* Fibers cannot be copied */
|
||||
rb_raise(rb_eTypeError, "can't copy execution context");
|
||||
}
|
||||
ptr1 = enumerator_ptr(obj);
|
||||
|
||||
ptr1->method = ptr0->method;
|
||||
ptr1->proc = ptr0->proc;
|
||||
ptr1->iter = ptr0->iter;
|
||||
ptr1->args = ptr0->args;
|
||||
ptr1->fib = ptr0->fib;
|
||||
ptr1->fib = 0;
|
||||
|
||||
return obj;
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче