मैं निम्नलिखित कोड है: जब मैं python ./pypy/pypy/translator/goal/translate.py t.py
चलानेRPython sys विधियां काम नहीं करती
import sys
def entry_point(argv):
sys.exit(1)
return 0
def target(*args):
return entry_point, None
हालांकि, मैं प्राप्त निम्न त्रुटि:
...
[translation:ERROR] Exception: unexpected prebuilt constant: <built-in function exit>
[translation:ERROR] Processing block:
[translation:ERROR] [email protected] 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.exdit को 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] [email protected] 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 के लिए सीमा बंद कर रहे हैं? ऐसा लगता है कि मेरे लिए अजीब लगता है क्योंकि बाहर निकलने और stdout सी में इतनी आसानी से उपलब्ध हैं। हालांकि, त्रुटि संदेशों की तरह दिखती है कि वे अलग-अलग चीजों के बारे में हो सकते हैं, इसलिए मैं सिर्फ गलत पेड़ को भौंकने वाला हो सकता हूं।
वर्तमान में मैं this का उपयोग कर रहा हूं ताकि यह पता लगाया जा सके कि RPython में क्या अनुमति है और अनुमति नहीं है। क्या अन्य जानकारी के लिए मैं अन्य सुलभ संदर्भों का उपयोग कर सकता हूं?
क्षमा करें, मैं आगे की मदद नहीं कर सकता, लेकिन मुझे यह इंगित करने की अनुमति देता है कि आखिरी उदाहरण गलत है जिसे आपको प्रतिस्थापित करना चाहिए: 'sys.std.write'' sys.stdout.write' द्वारा, कोई 'sys.std नहीं है पाइथन में – mouad
@mouad इसे इंगित करने के लिए धन्यवाद। मैंने इसे फिर से कोशिश की और अद्यतन त्रुटि संदेश पोस्ट किया। – math4tots