ruby-core@ruby-lang.org archive (unofficial mirror)
 help / color / mirror / Atom feed
From: nobu@ruby-lang.org
To: ruby-core@ruby-lang.org
Subject: [ruby-core:70393] [Ruby trunk - Bug #11445] [Rejected] Ruby 1.9.3 - StringIO clone method creates new instance but somehow connected with the original instance
Date: Fri, 14 Aug 2015 21:48:47 +0000	[thread overview]
Message-ID: <redmine.journal-53794.20150814214846.98f332e467119fda@ruby-lang.org> (raw)
In-Reply-To: redmine.issue-11445.20150814121137@ruby-lang.org

Issue #11445 has been updated by Nobuyoshi Nakada.

Description updated
Status changed from Open to Rejected

1.9 has finished.

----------------------------------------
Bug #11445: Ruby 1.9.3 - StringIO clone method creates new instance but somehow connected with the original instance
https://bugs.ruby-lang.org/issues/11445#change-53794

* Author: Michal Brunát
* Status: Rejected
* Priority: Normal
* Assignee: 
* ruby -v: ruby 1.9.3p551 (2014-11-13 revision 48407) [x86_64-linux]
* Backport: 1.9.3: UNKNOWN
----------------------------------------
In Ruby 1.9.3 cloned `StringIO` instance has influence on close state of original instance:

~~~ruby
require 'stringio'

sio1 = StringIO.new( 'abc' )
sio2 = sio1.clone

sio2.read
sio1.pos  # => 3, expected 0

sio2.close
sio1.closed?  # => true, expected false
~~~

If `File` is used instead of `StringIO`, close state is not shared between instances (position is).

This behaviour has changed in Ruby 2.0.0 (cloned `StringIO` instance does not close original instance).

It matters what definition for `IO` clone is, whether to share attributes (e.g. `pos`) and/or state (`closed?`) but the later is acting differently in 1.9.3 for `StringIO` and `File`.




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

      parent reply	other threads:[~2015-08-14 21:13 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <redmine.issue-11445.20150814121137@ruby-lang.org>
2015-08-14 12:11 ` [ruby-core:70389] [Ruby trunk - Bug #11445] [Open] Ruby 1.9.3 - StringIO clone method creates new instance but somehow connected with the original instance mbrunat
2015-08-14 21:48 ` nobu [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.ruby-lang.org/en/community/mailing-lists/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=redmine.journal-53794.20150814214846.98f332e467119fda@ruby-lang.org \
    --to=ruby-core@ruby-lang.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).