예제 #1
0
    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
예제 #2
0
    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
예제 #3
0
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
예제 #4
0
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
예제 #5
0
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)
예제 #6
0
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)
예제 #7
0
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)
예제 #8
0
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)
예제 #9
0
 def teardown_class(cls):
     if hasattr(cls, "oldlocale"):
         setlocale(LC_ALL, cls.oldlocale)
예제 #10
0
 def setup_class(cls):
     try:
         cls.oldlocale = setlocale(LC_ALL, "pl_PL.utf8")
     except LocaleError:
         py.test.skip("polish locale unsupported")
예제 #11
0
 def setup_class(cls):
     try:
         cls.oldlocale = setlocale(LC_ALL, "pl_PL.utf8")
     except LocaleError:
         py.test.skip("polish locale unsupported")
예제 #12
0
파일: test_locale.py 프로젝트: Qointum/pypy
 def setup_class(cls):
     from rpython.rlib import rlocale
     cls.oldlocale = rlocale.setlocale(rlocale.LC_ALL, None)
예제 #13
0
 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)
예제 #14
0
 def teardown_class(cls):
     if hasattr(cls, 'oldlocale'):
         from rpython.rlib import rlocale
         rlocale.setlocale(rlocale.LC_ALL, cls.oldlocale)
예제 #15
0
 def setup_class(cls):
     from rpython.rlib import rlocale
     cls.oldlocale = rlocale.setlocale(rlocale.LC_ALL, None)
예제 #16
0
파일: test_locale.py 프로젝트: Qointum/pypy
 def teardown_class(cls):
     if hasattr(cls, 'oldlocale'):
         from rpython.rlib import rlocale
         rlocale.setlocale(rlocale.LC_ALL, cls.oldlocale)
예제 #17
0
파일: test_locale.py 프로젝트: Qointum/pypy
 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)
예제 #18
0
 def teardown_class(cls):
     if hasattr(cls, "oldlocale"):
         setlocale(LC_ALL, cls.oldlocale)
예제 #19
0
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