# Frozen IO object causes RuntimeError with inspect and fileno

**URL:** <https://www.ruby-forum.com/t/frozen-io-object-causes-runtimeerror-with-inspect-and-fileno/231491>\
**Category:** Development\
**Created:** [August 11, 2014, 4:54pm UTC](https://www.ruby-forum.com/t/frozen-io-object-causes-runtimeerror-with-inspect-and-fileno/231491 "2014-08-11T16:54:35Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![addis\_a](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/c4cdca/32.png) [@addis\_a](https://www.ruby-forum.com/u/addis_a)\
**Post date:** [August 11, 2014, 4:54pm UTC](https://www.ruby-forum.com/t/frozen-io-object-causes-runtimeerror-with-inspect-and-fileno/231491/1 "2014-08-11T16:54:35Z")

</div>

Issue #9865 has been updated by Tomoyuki C…

Backport changed from 2.0.0: REQUIRED, 2.1: REQUIRED to 2.0.0: REQUIRED,  
2.1: DONE

r46151 and r46165 (partially) were backported into `ruby_2_1` branch at  
r47140.

* * *

Bug #9865: frozen IO object causes RuntimeError with inspect and fileno

> **[Bug #9865: frozen IO object causes RuntimeError with inspect and fileno -...](https://bugs.ruby-lang.org/issues/9865#change-48284)**
>
> Redmine

- Author: Akira T.
- Status: Closed
- Priority: Normal
- Assignee:
- Category:
- Target version:
- ruby -v: ruby 2.2.0dev (2014-05-27 trunk 46150) [x86\_64-linux]
- Backport: 2.0.0: REQUIRED, 2.1: DONE

* * *

IO object を freeze すると、inspect や fileno が RuntimeError になるんですが、  
これはよろしくないんじゃないかと思います。

```auto
% ./ruby -e 'f = open("."); f.freeze; p f'
-e:1:in `inspect': can't modify frozen File (RuntimeError)
  from -e:1:in `p'
  from -e:1:in `<main>'
% ./ruby -e 'f = open("."); f.freeze; p f.fileno'
-e:1:in `fileno': can't modify frozen File (RuntimeError)
  from -e:1:in `<main>'
% ./ruby -v
ruby 2.2.0dev (2014-05-27 trunk 46150) [x86_64-linux]

```

あるいは、なにか理由がありましたっけ?
