def entry_point(argv): if withjit: from rpython.jit.backend.hlinfo import highleveljitinfo highleveljitinfo.sys_executable = argv[0] if hashfunc == "siphash24": from rpython.rlib import rsiphash rsiphash.enable_siphash24() #debug("entry point starting") #for arg in argv: # debug(" argv -> " + arg) if len(argv) > 2 and argv[1] == '--heapsize': # Undocumented option, handled at interp-level. # It has silently no effect with some GCs. # It works in Boehm and in the semispace or generational GCs # (but see comments in semispace.py:set_max_heap_size()). # At the moment this option exists mainly to support sandboxing. from rpython.rlib import rgc rgc.set_max_heap_size(int(argv[2])) argv = argv[:1] + argv[3:] try: try: space.startup() if rlocale.HAVE_LANGINFO: try: rlocale.setlocale(rlocale.LC_CTYPE, '') except rlocale.LocaleError: pass w_executable = space.newfilename(argv[0]) w_argv = space.newlist( [space.newfilename(s) for s in argv[1:]]) w_exitcode = space.call_function(w_entry_point, w_executable, w_argv) exitcode = space.int_w(w_exitcode) # try to pull it all in ## from pypy.interpreter import main, interactive, error ## con = interactive.PyPyConsole(space) ## con.interact() except OperationError as e: debug("OperationError:") debug(" operror-type: " + e.w_type.getname(space)) debug(" operror-value: " + space.text_w(space.str(e.get_w_value(space)))) return 1 finally: try: # the equivalent of Py_FinalizeEx if space.finish() < 0: # Value unlikely to be confused with a non-error exit status # or other special meaning (from cpython/Modules/main.c) exitcode = 120 except OperationError as e: debug("OperationError:") debug(" operror-type: " + e.w_type.getname(space)) debug(" operror-value: " + space.text_w(space.str(e.get_w_value(space)))) return 1 return exitcode
def entry_point(argv): if withjit: from rpython.jit.backend.hlinfo import highleveljitinfo highleveljitinfo.sys_executable = argv[0] #debug("entry point starting") #for arg in argv: # debug(" argv -> " + arg) if len(argv) > 2 and argv[1] == '--heapsize': # Undocumented option, handled at interp-level. # It has silently no effect with some GCs. # It works in Boehm and in the semispace or generational GCs # (but see comments in semispace.py:set_max_heap_size()). # At the moment this option exists mainly to support sandboxing. from rpython.rlib import rgc rgc.set_max_heap_size(int(argv[2])) argv = argv[:1] + argv[3:] try: try: space.startup() if rlocale.HAVE_LANGINFO: try: rlocale.setlocale(rlocale.LC_CTYPE, '') except rlocale.LocaleError: pass w_executable = space.wrap_fsdecoded(argv[0]) w_argv = space.newlist([space.wrap_fsdecoded(s) for s in argv[1:]]) w_exitcode = space.call_function(w_entry_point, w_executable, w_argv) exitcode = space.int_w(w_exitcode) # try to pull it all in ## from pypy.interpreter import main, interactive, error ## con = interactive.PyPyConsole(space) ## con.interact() except OperationError, e: debug("OperationError:") debug(" operror-type: " + e.w_type.getname(space).encode('utf-8')) debug(" operror-value: " + space.str_w(space.str(e.get_w_value(space)))) return 1 finally: try: space.finish() except OperationError, e: debug("OperationError:") debug(" operror-type: " + e.w_type.getname(space).encode('utf-8')) debug(" operror-value: " + space.str_w(space.str(e.get_w_value(space)))) return 1
def _getfilesystemencoding(space): encoding = base_encoding if rlocale.HAVE_LANGINFO: try: oldlocale = rlocale.setlocale(rlocale.LC_CTYPE, None) rlocale.setlocale(rlocale.LC_CTYPE, "") try: loc_codeset = rlocale.nl_langinfo(rlocale.CODESET) if loc_codeset: codecmod = space.getbuiltinmodule('_codecs') w_res = space.call_method(codecmod, 'lookup', space.newtext(loc_codeset)) if space.is_true(w_res): encoding = loc_codeset finally: rlocale.setlocale(rlocale.LC_CTYPE, oldlocale) except rlocale.LocaleError: pass return encoding
def _getfilesystemencoding(space): encoding = base_encoding if rlocale.HAVE_LANGINFO: try: oldlocale = rlocale.setlocale(rlocale.LC_CTYPE, None) rlocale.setlocale(rlocale.LC_CTYPE, "") try: loc_codeset = rlocale.nl_langinfo(rlocale.CODESET) if loc_codeset: codecmod = space.getbuiltinmodule('_codecs') w_res = space.call_method(codecmod, 'lookup', space.wrap(loc_codeset)) if space.is_true(w_res): encoding = loc_codeset finally: rlocale.setlocale(rlocale.LC_CTYPE, oldlocale) except rlocale.LocaleError: pass return encoding
def setlocale(space, category, w_locale=None): "(integer,string=None) -> string. Activates/queries locale processing." if space.is_none(w_locale): locale = None else: locale = space.str_w(w_locale) try: result = rlocale.setlocale(category, locale) except rlocale.LocaleError, e: raise rewrap_error(space, e)
def setlocale(space, category, w_locale=None): "(integer,string=None) -> string. Activates/queries locale processing." if space.is_none(w_locale): locale = None else: locale = space.text_w(w_locale) try: result = rlocale.setlocale(category, locale) except rlocale.LocaleError as e: raise rewrap_error(space, e) # record changes to LC_CTYPE if category in (rlocale.LC_CTYPE, rlocale.LC_ALL): _fixup_ulcase(space) return space.newtext(result)
def setlocale(space, category, w_locale=None): "(integer,string=None) -> string. Activates/queries locale processing." if space.is_none(w_locale): locale = None else: locale = space.str_w(w_locale) try: result = rlocale.setlocale(category, locale) except rlocale.LocaleError as e: raise rewrap_error(space, e) # record changes to LC_CTYPE if category in (rlocale.LC_CTYPE, rlocale.LC_ALL): _fixup_ulcase(space) return space.wrap(result)
def teardown_class(cls): if hasattr(cls, "oldlocale"): setlocale(LC_ALL, cls.oldlocale)
def setup_class(cls): try: cls.oldlocale = setlocale(LC_ALL, "pl_PL.utf8") except LocaleError: py.test.skip("polish locale unsupported")
def setup_class(cls): from rpython.rlib import rlocale cls.oldlocale = rlocale.setlocale(rlocale.LC_ALL, None)
def setlocale(self, locale): from rpython.rlib import rlocale try: rlocale.setlocale(rlocale.LC_ALL, locale) except rlocale.LocaleError: pytest.skip("%s locale unsupported" % locale)
def teardown_class(cls): if hasattr(cls, 'oldlocale'): from rpython.rlib import rlocale rlocale.setlocale(rlocale.LC_ALL, cls.oldlocale)
def setlocale(self, locale): from rpython.rlib import rlocale try: rlocale.setlocale(rlocale.LC_ALL, locale) except rlocale.LocaleError: py.test.skip("%s locale unsupported" % locale)
def primitiveCountry(interp, s_frame, w_rcvr): fullname = rlocale.setlocale(rlocale.LC_ALL, None) if "." in fullname and "_" in fullname: return interp.space.wrap_string(fullname.split(".")[0].split("_")[1]) raise PrimitiveFailedError