ruby-core@ruby-lang.org archive (unofficial mirror)
 help / color / mirror / Atom feed
From: mbrunat@volny.cz
To: ruby-core@ruby-lang.org
Subject: [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
Date: Fri, 14 Aug 2015 12:11:38 +0000	[thread overview]
Message-ID: <redmine.issue-11445.20150814121137.13cad73bee3f8275@ruby-lang.org> (raw)
In-Reply-To: redmine.issue-11445.20150814121137@ruby-lang.org

Issue #11445 has been reported by Michal Brunát.

----------------------------------------
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

* Author: Michal Brunát
* Status: Open
* 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:
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/

       reply	other threads:[~2015-08-14 11:36 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 ` mbrunat [this message]
2015-08-14 21:48 ` [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 nobu

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.issue-11445.20150814121137.13cad73bee3f8275@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).