[#46309] [ruby-trunk - Bug #2154][Assigned] filesystem encoding of UNIX — "usa (Usaku NAKAMURA)" <usa@...>

13 messages 2012/10/29
[#46310] Re: [ruby-trunk - Bug #2154][Assigned] filesystem encoding of UNIX — Tanaka Akira <akr@...> 2012/10/29

2012年10月29日 10:31 usa (Usaku NAKAMURA) <usa@garbagecollect.jp>:

[#46366] Re: [ruby-trunk - Bug #2154][Assigned] filesystem encoding of UNIX — "U.Nakamura" <usa@...> 2012/11/02

こんにちは、なかむら(う)です。

[#46375] Re: [ruby-trunk - Bug #2154][Assigned] filesystem encoding of UNIX — KOSAKI Motohiro <kosaki.motohiro@...> 2012/11/02

>> とくに指定しなければ、default external は locale から設定されるので、

[ruby-dev:46249] [Backport93 - Backport #5586] Time.at(Marshal.load(Marshal.dump(Time.now))).to_s raise TypeError

From: "dafiku (dafi harisy)" <dafi@...>
Date: 2012-10-23 05:31:27 UTC
List: ruby-dev #46249
Issue #5586 has been updated by dafiku (dafi harisy).


Everlastingly, an issue with the intention of I am passionate in this vicinity. I be inflicted with looked for in rank of this feature for the last numerous hours. Your locate is greatly valued.
http://www.yourhousecontents.com/
http://www.electroscanogram.com/
http://www.videophototravel.info/
http://www.supershinelaundry.com/
http://www.ywor.info/
http://www.bicity.info/
http://www.ubidyne.info/
----------------------------------------
Backport #5586: Time.at(Marshal.load(Marshal.dump(Time.now))).to_s raise TypeError
https://bugs.ruby-lang.org/issues/5586#change-31322

Author: nagachika (Tomoyuki Chikanaga)
Status: Closed
Priority: Normal
Assignee: 
Category: 
Target version: 


以下のコードが TypeError を発生させます。なお 1.9.2-p312 でも発生しました。

Time.at(Marshal.load(Marshal.dump(Time.now))).to_s
# => TypeError: false can't be coerced into Fixnum

Time オブジェクトを Marshal.dump -> load すると TIME_SET_FIXOFF() で
struct time_object の gmt と vtm.utc_offset がセットされるのですが
それを Time.at に渡すと gmt だけコピーされて vtm.utc_offset が (VALUE)0 = Qfalse のままだからのようです。

どこが根本的な原因なのかよくわかりませんが、以下のパッチで例外はおきなくなりました。
るりまの Time.at(time) のページ( http://rurema.clear-code.com/1.9.3/method/Time/s/at.html )を見ると
「生成された Time オブジェクトのタイムゾーンは地方時となります。」とあるので TIME_GMT_COPY() 自体が
不要なのかもしれないと思いますがどうでしょう。

diff --git a/time.c b/time.c
index 3e50c7c..96b717b 100644
--- a/time.c
+++ b/time.c
@@ -1820,7 +1820,10 @@ struct time_object {
      (tobj)->vtm.utc_offset = (off), \
      (tobj)->vtm.zone = NULL)
 
-#define TIME_COPY_GMT(tobj1, tobj2) ((tobj1)->gmt = (tobj2)->gmt)
+#define TIME_COPY_GMT(tobj1, tobj2) \
+    ((tobj1)->gmt = (tobj2)->gmt, \
+     (tobj1)->vtm.utc_offset = (tobj2)->vtm.utc_offset, \
+     (tobj1)->vtm.zone = (tobj2)->vtm.zone)
 
 static VALUE time_get_tm(VALUE, struct time_object *);
 #define MAKE_TM(time, tobj) \



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

In This Thread

Prev Next