私は次のコードを持っています:
import sys
def entry_point(argv):
sys.exit(1)
return 0
def target(*args):
return entry_point, None
ただし、実行するpython ./pypy/pypy/translator/goal/translate.py t.py
と、次のエラーが発生します。
...
[translation:ERROR] Exception: unexpected prebuilt constant: <built-in function exit>
[translation:ERROR] Processing block:
[translation:ERROR] block@9 is a <class 'pypy.objspace.flow.flowcontext.SpamBlock'>
[translation:ERROR] in (t:3)entry_point
[translation:ERROR] containing the following operations:
[translation:ERROR] v0 = simple_call((builtin_function_or_method exit), (1))
[translation:ERROR] --end--
実際にはエラーにはもっと多くのことがありましたが、私はこの最後の部分だけが関連していると思いました。もっと参考になると思われる場合は、コメントしてください。編集します。
実際、sys.exitをsys.stdout.writeのようなさらに単純なものに置き換えると、別のエラーが発生します。
import sys
def entry_point(argv):
sys.stdout.write('some mesg\n')
return 0
def target(*args):
return entry_point, None
私に与える:
...
[translation:ERROR] AnnotatorError: annotation of v0 degenerated to SomeObject()
[translation:ERROR] v0 = getattr((module sys), ('stdout'))
[translation:ERROR]
[translation:ERROR] In <FunctionGraph of (t:3)entry_point at 0x10d03de10>:
[translation:ERROR] Happened at file t.py line 4
[translation:ERROR]
[translation:ERROR] ==> sys.stdout.write('some mesg\n')
[translation:ERROR]
[translation:ERROR] Previous annotation:
[translation:ERROR] (none)
[translation:ERROR] Processing block:
[translation:ERROR] block@3 is a <class 'pypy.objspace.flow.flowcontext.SpamBlock'>
[translation:ERROR] in (t:3)entry_point
[translation:ERROR] containing the following operations:
[translation:ERROR] v0 = getattr((module sys), ('stdout'))
[translation:ERROR] v1 = getattr(v0, ('write'))
[translation:ERROR] v2 = simple_call(v1, ('some mesg\n'))
[translation:ERROR] --end--
sysメソッドは単にRPythonの立ち入り禁止ですか?exitとstdoutはCですぐに利用できるので、私にはちょっと奇妙に思えます。ただし、エラーメッセージは別のもののように見えるので、間違ったツリーを吠えているだけかもしれません。
現在、このガイドを使用して、RPythonで許可されているものと許可されていないものを大まかに把握しています。詳細については、他にアクセスしやすいリファレンスを使用できますか?