IronPython 2.7

標準ライブラリは使えないと思っていたもののかなり対応が進んでいるらしい、expat 以外は。
正直かなりのじゃじゃ馬で文法レベルの互換と捉えることにした。普通は exec したりしないし sys.exc_traceback に触れたりもしない、それは知ってる。

file を勝手に閉じてくれない

file の実装かオブジェクトの寿命に違いがあるらしい。
これはそもそも書き方が良くないので with なりで open() したら明示的に閉じることで解決した。

unicode is str

なんだよコレ

IronPython 2.7 (2.7.0.40) on .NET 4.0.30319.1
Type "help", "copyright", "credits" or "license" for more information.
>>> unicode
<type 'str'>
>>> u''
''
>>> unicode is str
True

インデントと改行で SyntaxError

なんだよコレ

IronPython 2.7 (2.7.0.40) on .NET 4.0.30319.1
Type "help", "copyright", "credits" or "license" for more information.
>>> exec "if 1:\n  1\n "
  File "<string>", line 3

    ^
IndentationError: unindent does not match any outer indentation level
>>> exec "\n\r\n1"
  File "<string>", line 2


    ^
SyntaxError: unexpected token '\r'

types.FrameType が .f_globals is .f_locals -> True なときがある

なんだよコレ

"""
>>> import sys
>>> def foo(): notfound
>>> try:
...     foo()
... except:
...     tb = sys.exc_traceback
...     while tb is not None:
...         print tb.tb_frame.f_code.co_name, tb.tb_frame.f_globals is tb.tb_frame.f_locals
...         tb = tb.tb_next
...     del tb
<module> True
foo False
"""
import doctest
doctest.testmod()
**********************************************************************
File "test.py", line 4, in __main__
Failed example:
    try:
        foo()
    except:
        tb = sys.exc_traceback
        while tb is not None:
            print tb.tb_frame.f_code.co_name, tb.tb_frame.f_globals is tb.tb_frame.f_locals
            tb = tb.tb_next
        del tb
Expected:
    <module> True
    foo False
Got:
    <module> True
    foo True
**********************************************************************
1 items had failures:
   1 of   3 in __main__
***Test Failed*** 1 failures.

compile で死ぬ

http://ironpython.codeplex.com/workitem/28182
治ってないです

IronPython 2.7 (2.7.0.40) on .NET 4.0.30319.1
Type "help", "copyright", "credits" or "license" for more information.
>>> import __future__
>>> compile('', '<string>', 'exec', __future__.print_function.compiler_flag)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ValueError: unrecognized flags