Exemple #1
0
from rpython.rlib import rposix
from rpython.rlib.rarithmetic import intmask

from pypy.interpreter.error import OperationError
from pypy.interpreter.gateway import unwrap_spec

from rpython.rlib import rlocale
from pypy.module.exceptions.interp_exceptions import _new_exception, W_Exception
from rpython.rtyper.lltypesystem import lltype, rffi

W_Error = _new_exception('Error', W_Exception, 'locale error')

import sys


def make_error(space, msg):
    return OperationError(space.gettypeobject(W_Error.typedef),
                          space.wrap(msg))


def rewrap_error(space, e):
    return OperationError(space.gettypeobject(W_Error.typedef),
                          space.wrap(e.message))


@unwrap_spec(category=int)
def setlocale(space, category, w_locale=None):
    "(integer,string=None) -> string. Activates/queries locale processing."

    if space.is_none(w_locale):
        locale = None
Exemple #2
0
from rpython.rlib import rposix
from rpython.rlib.rarithmetic import intmask

from pypy.interpreter.error import OperationError
from pypy.interpreter.gateway import unwrap_spec

from rpython.rlib import rlocale
from pypy.module.exceptions.interp_exceptions import _new_exception, W_Exception
from rpython.rtyper.lltypesystem import lltype, rffi

W_Error = _new_exception('Error', W_Exception, 'locale error')

import sys

def make_error(space, msg):
    return OperationError(space.gettypeobject(W_Error.typedef), space.wrap(msg))

def rewrap_error(space, e):
    return OperationError(space.gettypeobject(W_Error.typedef),
                          space.wrap(e.message))

def _fixup_ulcase(space):
    stringmod = space.call_function(
        space.getattr(space.getbuiltinmodule('__builtin__'),
                      space.wrap('__import__')), space.wrap('string'))
    # create uppercase map string
    ul = []
    for c in xrange(256):
        if rlocale.isupper(c):
            ul.append(chr(c))
    space.setattr(stringmod, space.wrap('uppercase'), space.wrap(''.join(ul)))
Exemple #3
0
from rpython.rlib import jit
from rpython.rlib.rarithmetic import ovfcheck
from rpython.rtyper.lltypesystem import rffi, lltype

from pypy.interpreter.error import OperationError, oefmt
from pypy.interpreter.gateway import unwrap_spec, appdef
from pypy.interpreter.typedef import GetSetProperty
from pypy.objspace.std.typeobject import W_TypeObject
from pypy.objspace.std.objspace import StdObjSpace
from pypy.module.micronumpy import constants as NPY
from pypy.module.exceptions.interp_exceptions import _new_exception, W_UserWarning

W_VisibleDeprecationWarning = _new_exception(
    'VisibleDeprecationWarning', W_UserWarning, """Visible deprecation warning.

    By default, python will not show deprecation warnings, so this class
    can be used when a very visible warning is helpful, for example because
    the usage is most likely a user bug.

    """)


def issequence_w(space, w_obj):
    from pypy.module.micronumpy.base import W_NDimArray
    return (space.isinstance_w(w_obj, space.w_tuple)
            or space.isinstance_w(w_obj, space.w_list)
            or space.isinstance_w(w_obj, space.w_buffer)
            or isinstance(w_obj, W_NDimArray))


def index_w(space, w_obj):
    try:
        costate = self.costate
        w_result = self.space.call_args(self.w_func, self.args)
        costate.w_tempval = w_result

class _ResumeThunk(AbstractThunk):
    def __init__(self, space, costate, w_frame):
        self.space = space
        self.costate = costate
        self.w_frame = w_frame

    def call(self):
        w_result = resume_frame(self.space, self.w_frame)
        # costate.w_tempval = w_result #XXX?


W_CoroutineExit = _new_exception('CoroutineExit', W_SystemExit,
                        """Coroutine killed manually.""")

# Should be moved to interp_stackless.py if it's ever implemented... Currently
# used by pypy/lib/stackless.py.
W_TaskletExit = _new_exception('TaskletExit', W_SystemExit,
            """Tasklet killed manually.""")

class AppCoroutine(Coroutine): # XXX, StacklessFlags):

    def __init__(self, space, state=None):
        self.space = space
        if state is None:
            state = AppCoroutine._get_state(space)
        Coroutine.__init__(self, state)
        self.flags = 0
        self.newsubctx()
Exemple #5
0
from rpython.rlib import jit
from rpython.rlib.rarithmetic import ovfcheck
from rpython.rtyper.lltypesystem import rffi, lltype

from pypy.interpreter.error import OperationError, oefmt
from pypy.interpreter.gateway import unwrap_spec, appdef
from pypy.interpreter.typedef import GetSetProperty
from pypy.objspace.std.typeobject import W_TypeObject
from pypy.objspace.std.objspace import StdObjSpace
from pypy.module.micronumpy import constants as NPY
from pypy.module.exceptions.interp_exceptions import _new_exception, W_UserWarning

W_VisibleDeprecationWarning = _new_exception('VisibleDeprecationWarning', W_UserWarning,
    """Visible deprecation warning.

    By default, python will not show deprecation warnings, so this class
    can be used when a very visible warning is helpful, for example because
    the usage is most likely a user bug.

    """)


def issequence_w(space, w_obj):
    from pypy.module.micronumpy.base import W_NDimArray
    return (space.isinstance_w(w_obj, space.w_tuple) or
           space.isinstance_w(w_obj, space.w_list) or
           space.isinstance_w(w_obj, space.w_buffer) or
           isinstance(w_obj, W_NDimArray))


def index_w(space, w_obj):
    try: