• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python rffi.charpsize2str函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中pypy.rpython.lltypesystem.rffi.charpsize2str函数的典型用法代码示例。如果您正苦于以下问题:Python charpsize2str函数的具体用法?Python charpsize2str怎么用?Python charpsize2str使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了charpsize2str函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: detect_floatformat

def detect_floatformat():
    from pypy.rpython.lltypesystem import rffi, lltype
    buf = lltype.malloc(rffi.CCHARP.TO, 8, flavor='raw')
    rffi.cast(rffi.DOUBLEP, buf)[0] = 9006104071832581.0
    packed = rffi.charpsize2str(buf, 8)
    if packed == "\x43\x3f\xff\x01\x02\x03\x04\x05":
        double_format = 'IEEE, big-endian'
    elif packed == "\x05\x04\x03\x02\x01\xff\x3f\x43":
        double_format = 'IEEE, little-endian'
    else:
        double_format = 'unknown'
    lltype.free(buf, flavor='raw')
    #
    buf = lltype.malloc(rffi.CCHARP.TO, 4, flavor='raw')
    rffi.cast(rffi.FLOATP, buf)[0] = rarithmetic.r_singlefloat(16711938.0)
    packed = rffi.charpsize2str(buf, 4)
    if packed == "\x4b\x7f\x01\x02":
        float_format = 'IEEE, big-endian'
    elif packed == "\x02\x01\x7f\x4b":
        float_format = 'IEEE, little-endian'
    else:
        float_format = 'unknown'
    lltype.free(buf, flavor='raw')

    return double_format, float_format
开发者ID:gorakhargosh,项目名称:pypy,代码行数:25,代码来源:floattype.py


示例2: _decode_certificate

def _decode_certificate(space, certificate, verbose=False):
    w_retval = space.newdict()

    w_peer = _create_tuple_for_X509_NAME(
        space, libssl_X509_get_subject_name(certificate))
    space.setitem(w_retval, space.wrap("subject"), w_peer)

    if verbose:
        w_issuer = _create_tuple_for_X509_NAME(
            space, libssl_X509_get_issuer_name(certificate))
        space.setitem(w_retval, space.wrap("issuer"), w_issuer)

        space.setitem(w_retval, space.wrap("version"),
                      space.wrap(libssl_X509_get_version(certificate)))

    biobuf = libssl_BIO_new(libssl_BIO_s_mem())
    try:

        if verbose:
            libssl_BIO_reset(biobuf)
            serialNumber = libssl_X509_get_serialNumber(certificate)
            libssl_i2a_ASN1_INTEGER(biobuf, serialNumber)
            # should not exceed 20 octets, 160 bits, so buf is big enough
            with lltype.scoped_alloc(rffi.CCHARP.TO, 100) as buf:
                length = libssl_BIO_gets(biobuf, buf, 99)
                if length < 0:
                    raise _ssl_seterror(space, None, length)

                w_serial = space.wrap(rffi.charpsize2str(buf, length))
            space.setitem(w_retval, space.wrap("serialNumber"), w_serial)

            libssl_BIO_reset(biobuf)
            notBefore = libssl_X509_get_notBefore(certificate)
            libssl_ASN1_TIME_print(biobuf, notBefore)
            with lltype.scoped_alloc(rffi.CCHARP.TO, 100) as buf:
                length = libssl_BIO_gets(biobuf, buf, 99)
                if length < 0:
                    raise _ssl_seterror(space, None, length)
                w_date = space.wrap(rffi.charpsize2str(buf, length))
            space.setitem(w_retval, space.wrap("notBefore"), w_date)

        libssl_BIO_reset(biobuf)
        notAfter = libssl_X509_get_notAfter(certificate)
        libssl_ASN1_TIME_print(biobuf, notAfter)
        with lltype.scoped_alloc(rffi.CCHARP.TO, 100) as buf:
            length = libssl_BIO_gets(biobuf, buf, 99)
            if length < 0:
                raise _ssl_seterror(space, None, length)
            w_date = space.wrap(rffi.charpsize2str(buf, length))
        space.setitem(w_retval, space.wrap("notAfter"), w_date)
    finally:
        libssl_BIO_free(biobuf)

    # Now look for subjectAltName
    w_alt_names = _get_peer_alt_names(space, certificate)
    if w_alt_names is not space.w_None:
        space.setitem(w_retval, space.wrap("subjectAltName"), w_alt_names)

    return w_retval
开发者ID:gorakhargosh,项目名称:pypy,代码行数:59,代码来源:interp_ssl.py


示例3: recv_bytes

    def recv_bytes(self, space, maxlength=PY_SSIZE_T_MAX):
        self._check_readable(space)
        if maxlength < 0:
            raise OperationError(space.w_ValueError, space.wrap("maxlength < 0"))

        res, newbuf = self.do_recv_string(space, self.BUFFER_SIZE, maxlength)
        res = intmask(res)  # XXX why?
        try:
            if newbuf:
                return space.wrap(rffi.charpsize2str(newbuf, res))
            else:
                return space.wrap(rffi.charpsize2str(self.buffer, res))
        finally:
            if newbuf:
                rffi.free_charp(newbuf)
开发者ID:gorakhargosh,项目名称:pypy,代码行数:15,代码来源:interp_connection.py


示例4: recv_bytes_into

    def recv_bytes_into(self, space, w_buffer, offset=0):
        rwbuffer = space.rwbuffer_w(w_buffer)
        length = rwbuffer.getlength()

        res, newbuf = self.do_recv_string(space, length - offset, PY_SSIZE_T_MAX)
        res = intmask(res)  # XXX why?
        try:
            if newbuf:
                raise BufferTooShort(space, space.wrap(rffi.charpsize2str(newbuf, res)))
            rwbuffer.setslice(offset, rffi.charpsize2str(self.buffer, res))
        finally:
            if newbuf:
                rffi.free_charp(newbuf)

        return space.wrap(res)
开发者ID:gorakhargosh,项目名称:pypy,代码行数:15,代码来源:interp_connection.py


示例5: _create_tuple_for_attribute

def _create_tuple_for_attribute(space, name, value):
    with lltype.scoped_alloc(rffi.CCHARP.TO, X509_NAME_MAXLEN) as buf:
        length = libssl_OBJ_obj2txt(buf, X509_NAME_MAXLEN, name, 0)
        if length < 0:
            raise _ssl_seterror(space, None, 0)
        w_name = space.wrap(rffi.charpsize2str(buf, length))

    with lltype.scoped_alloc(rffi.CCHARPP.TO, 1) as buf_ptr:
        length = libssl_ASN1_STRING_to_UTF8(buf_ptr, value)
        if length < 0:
            raise _ssl_seterror(space, None, 0)
        w_value = space.wrap(rffi.charpsize2str(buf_ptr[0], length))
        w_value = space.call_method(w_value, "decode", space.wrap("utf-8"))

    return space.newtuple([w_name, w_value])
开发者ID:gorakhargosh,项目名称:pypy,代码行数:15,代码来源:interp_ssl.py


示例6: peer_certificate

    def peer_certificate(self, der=False):
        """peer_certificate([der=False]) -> certificate

        Returns the certificate for the peer.  If no certificate was provided,
        returns None.  If a certificate was provided, but not validated, returns
        an empty dictionary.  Otherwise returns a dict containing information
        about the peer certificate.

        If the optional argument is True, returns a DER-encoded copy of the
        peer certificate, or None if no certificate was provided.  This will
        return the certificate even if it wasn't validated."""
        if not self.peer_cert:
            return self.space.w_None

        if der:
            # return cert in DER-encoded format
            with lltype.scoped_alloc(rffi.CCHARPP.TO, 1) as buf_ptr:
                buf_ptr[0] = lltype.nullptr(rffi.CCHARP.TO)
                length = libssl_i2d_X509(self.peer_cert, buf_ptr)
                if length < 0:
                    raise _ssl_seterror(self.space, self, length)
                try:
                    # this is actually an immutable bytes sequence
                    return self.space.wrap(rffi.charpsize2str(buf_ptr[0],
                                                              length))
                finally:
                    libssl_OPENSSL_free(buf_ptr[0])
        else:
            verification = libssl_SSL_CTX_get_verify_mode(
                libssl_SSL_get_SSL_CTX(self.ssl))
            if not verification & SSL_VERIFY_PEER:
                return self.space.newdict()
            else:
                return _decode_certificate(self.space, self.peer_cert)
开发者ID:MichaelBlume,项目名称:pypy,代码行数:34,代码来源:interp_ssl.py


示例7: encodeex

def encodeex(encodebuf, unicodedata, errors="strict", errorcb=None, namecb=None, ignore_error=0):
    inleft = len(unicodedata)
    inbuf = rffi.get_nonmoving_unicodebuffer(unicodedata)
    try:
        if pypy_cjk_enc_init(encodebuf, inbuf, inleft) < 0:
            raise MemoryError
        if ignore_error == 0:
            flags = MBENC_FLUSH | MBENC_RESET
        else:
            flags = 0
        while True:
            r = pypy_cjk_enc_chunk(encodebuf, flags)
            if r == 0 or r == ignore_error:
                break
            multibytecodec_encerror(encodebuf, r, errors, errorcb, namecb, unicodedata)
        while flags & MBENC_RESET:
            r = pypy_cjk_enc_reset(encodebuf)
            if r == 0:
                break
            multibytecodec_encerror(encodebuf, r, errors, errorcb, namecb, unicodedata)
        src = pypy_cjk_enc_outbuf(encodebuf)
        length = pypy_cjk_enc_outlen(encodebuf)
        return rffi.charpsize2str(src, length)
    #
    finally:
        rffi.free_nonmoving_unicodebuffer(unicodedata, inbuf)
开发者ID:junion,项目名称:butlerbot-unstable,代码行数:26,代码来源:c_codecs.py


示例8: File_read

def File_read(vm):
    (self, rsize_o),_ = vm.decode_args(mand="!", opt="I", self_of=File)
    assert isinstance(self, File)
    _check_open(vm, self)
    
    flockfile(self.filep)
    fsize = os.fstat(fileno(self.filep)).st_size
    if rsize_o is None:
        rsize = fsize
    else:
        assert isinstance(rsize_o, Con_Int)
        rsize = rsize_o.v
        if rsize < 0:
            vm.raise_helper("File_Exception", \
              [Con_String(vm, "Can not read less than 0 bytes from file.")])
        elif rsize > fsize:
            rsize = fsize

    if objectmodel.we_are_translated():
        with lltype.scoped_alloc(rffi.CCHARP.TO, rsize) as buf:
            r = fread(buf, 1, rsize, self.filep)
            if r < rffi.r_size_t(rsize) and ferror(self.filep) != 0:
                vm.raise_helper("File_Exception", [Con_String(vm, "Read error.")])
            s = rffi.charpsize2str(buf, rarithmetic.intmask(r))
    else:
        # rffi.charpsize2str is so slow (taking minutes for big strings) that it's worth bypassing
        # it when things are run untranslated.
        s = os.read(fileno(self.filep), rsize)
    funlockfile(self.filep)

    return Con_String(vm, s)
开发者ID:cfbolz,项目名称:converge,代码行数:31,代码来源:Con_POSIX_File.py


示例9: ioctl

def ioctl(space, w_fd, op, w_arg=0, mutate_flag=True):
    """ioctl(fd, opt[, arg[, mutate_flag]])

    Perform the requested operation on file descriptor fd.  The operation is
    defined by opt and is operating system dependent.  Typically these codes
    are retrieved from the fcntl or termios library modules.

    The argument arg is optional, and defaults to 0; it may be an int or a
    buffer containing character data (most likely a string or an array).

    If the argument is a mutable buffer (such as an array) and if the
    mutate_flag argument (which is only allowed in this case) is true then the
    buffer is (in effect) passed to the operating system and changes made by
    the OS will be reflected in the contents of the buffer after the call has
    returned.  The return value is the integer returned by the ioctl system
    call.

    If the argument is a mutable buffer and the mutable_flag argument is not
    passed or is false, the behavior is as if a string had been passed.  This
    behavior will change in future releases of Python.

    If the argument is an immutable buffer (most likely a string) then a copy
    of the buffer is passed to the operating system and the return value is a
    string of the same length containing whatever the operating system put in
    the buffer.  The length of the arg buffer in this case is not allowed to
    exceed 1024 bytes.

    If the arg given is an integer or if none is specified, the result value
    is an integer corresponding to the return value of the ioctl call in the
    C code."""
    fd = _conv_descriptor(space, w_fd)
    # Python turns number > sys.maxint into long, we need the signed C value
    op = rffi.cast(rffi.INT, op)

    IOCTL_BUFSZ = 1024
    
    if space.is_w(space.type(w_arg), space.w_int):
        arg = space.int_w(w_arg)
        rv = ioctl_int(fd, op, arg)
        if rv < 0:
            raise OperationError(space.w_IOError,
                space.wrap(_get_error_msg()))
        return space.wrap(rv)
    elif space.is_w(space.type(w_arg), space.w_str): # immutable
        arg = space.str_w(w_arg)
        if len(arg) > IOCTL_BUFSZ:
            raise OperationError(space.w_ValueError,
                space.wrap("ioctl string arg too long"))
    
        ll_arg = rffi.str2charp(arg)
        rv = ioctl_str(fd, op, ll_arg)
        arg = rffi.charpsize2str(ll_arg, len(arg))
        lltype.free(ll_arg, flavor='raw')
        if rv < 0:
            raise OperationError(space.w_IOError,
                space.wrap(_get_error_msg()))
        return space.wrap(arg)
    else:
        raise OperationError(space.w_TypeError,
                space.wrap("an integer or a buffer required"))
开发者ID:antoine1fr,项目名称:pygirl,代码行数:60,代码来源:interp_fcntl.py


示例10: ioctl

def ioctl(space, w_fd, op, w_arg=0, mutate_flag=-1):
    """ioctl(fd, opt[, arg[, mutate_flag]])

    Perform the requested operation on file descriptor fd.  The operation is
    defined by opt and is operating system dependent.  Typically these codes
    are retrieved from the fcntl or termios library modules.
    """
    # removed the largish docstring because it is not in sync with the
    # documentation any more (even in CPython's docstring is out of date)

    # XXX this function's interface is a mess.
    # We try to emulate the behavior of Python >= 2.5 w.r.t. mutate_flag

    fd = space.c_filedescriptor_w(w_fd)
    op = rffi.cast(rffi.INT, op)        # C long => C int

    if mutate_flag != 0:
        try:
            rwbuffer = space.rwbuffer_w(w_arg)
        except OperationError, e:
            if not e.match(space, space.w_TypeError):
                raise
            if mutate_flag > 0:
                raise
        else:
            arg = rwbuffer.as_str()
            ll_arg = rffi.str2charp(arg)
            rv = ioctl_str(fd, op, ll_arg)
            arg = rffi.charpsize2str(ll_arg, len(arg))
            lltype.free(ll_arg, flavor='raw')
            if rv < 0:
                raise _get_error(space, "ioctl")
            rwbuffer.setslice(0, arg)
            return space.wrap(rv)
开发者ID:Debug-Orz,项目名称:Sypy,代码行数:34,代码来源:interp_fcntl.py


示例11: llimpl_FormatError

    def llimpl_FormatError(code):
        "Return a message corresponding to the given Windows error code."
        buf = lltype.malloc(rffi.CCHARPP.TO, 1, flavor='raw')

        try:
            msglen = FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER |
                                   FORMAT_MESSAGE_FROM_SYSTEM,
                                   None,
                                   rffi.cast(DWORD, code),
                                   DEFAULT_LANGUAGE,
                                   rffi.cast(rffi.CCHARP, buf),
                                   0, None)

            if msglen <= 2:   # includes the case msglen < 0
                return fake_FormatError(code)

            # FormatMessage always appends \r\n.
            buflen = intmask(msglen - 2)
            assert buflen > 0

            result = rffi.charpsize2str(buf[0], buflen)
            LocalFree(rffi.cast(rffi.VOIDP, buf[0]))
        finally:
            lltype.free(buf, flavor='raw')

        return result
开发者ID:ParitoshThapliyal59,项目名称:pypy,代码行数:26,代码来源:rwin32.py


示例12: Array_to_str

def Array_to_str(vm):
    (self,),_ = vm.decode_args("!", self_of=Array)
    assert isinstance(self, Array)

    data = rffi.charpsize2str(self.data, self.num_entries * self.type_size)
    objectmodel.keepalive_until_here(self)
    return Con_String(vm, data)
开发者ID:lucciano,项目名称:converge,代码行数:7,代码来源:Con_Array.py


示例13: load_resource

def load_resource(filename,resname,resid,reslang):
    """Load the named resource from the given file.

    The filename and resource name must be ascii strings, and the resid and
    reslang must be integers.
    """
    l_handle = k32_LoadLibraryExA(filename,0,LOAD_LIBRARY_AS_DATAFILE)
    if not l_handle:
        raise WindowsError(rwin32.GetLastError(),"LoadLibraryExW failed")
    try:
        r_handle = k32_FindResourceExA(l_handle,resname,resid,reslang)
        if not r_handle:
            raise WindowsError(rwin32.GetLastError(),"FindResourceExA failed")
        r_size = k32_SizeofResource(l_handle,r_handle)
        if not r_size:
            raise WindowsError(rwin32.GetLastError(),"SizeofResource failed")
        r_info = k32_LoadResource(l_handle,r_handle)
        if not r_info:
            raise WindowsError(rwin32.GetLastError(),"LoadResource failed")
        r_ptr = k32_LockResource(r_info)
        if not r_ptr:
            raise WindowsError(rwin32.GetLastError(),"LockResource failed")
        return rffi.charpsize2str(r_ptr,r_size)
    finally:
        if not k32_FreeLibrary(l_handle):
            raise WindowsError(rwin32.GetLastError(),"FreeLibrary failed")
开发者ID:RafeKettler,项目名称:esky,代码行数:26,代码来源:pypy_winres.py


示例14: convert_from_regdata

def convert_from_regdata(space, buf, buflen, typ):
    if typ == rwinreg.REG_DWORD:
        if not buflen:
            return space.wrap(0)
        d = rffi.cast(rwin32.LPDWORD, buf)[0]
        return space.wrap(d)

    elif typ == rwinreg.REG_SZ or typ == rwinreg.REG_EXPAND_SZ:
        if not buflen:
            return space.wrap("")
        s = rffi.charp2strn(rffi.cast(rffi.CCHARP, buf), buflen)
        return space.wrap(s)

    elif typ == rwinreg.REG_MULTI_SZ:
        if not buflen:
            return space.newlist([])
        i = 0
        l = []
        while i < buflen and buf[i]:
            s = []
            while i < buflen and buf[i] != '\0':
                s.append(buf[i])
                i += 1
            if len(s) == 0:
                break
            s = ''.join(s)
            l.append(space.wrap(s))
            i += 1
        return space.newlist(l)

    else: # REG_BINARY and all other types
        return space.wrap(rffi.charpsize2str(buf, buflen))
开发者ID:Debug-Orz,项目名称:Sypy,代码行数:32,代码来源:interp_winreg.py


示例15: encode

def encode(codec, unicodedata, errors="strict", errorcb=None, namecb=None):
    inleft = len(unicodedata)
    inbuf = rffi.get_nonmoving_unicodebuffer(unicodedata)
    try:
        encodebuf = pypy_cjk_enc_init(codec, inbuf, inleft)
        if not encodebuf:
            raise MemoryError
        try:
            while True:
                r = pypy_cjk_enc_chunk(encodebuf)
                if r == 0:
                    break
                multibytecodec_encerror(encodebuf, r, errors,
                                        codec, errorcb, namecb, unicodedata)
            while True:
                r = pypy_cjk_enc_reset(encodebuf)
                if r == 0:
                    break
                multibytecodec_encerror(encodebuf, r, errors,
                                        codec, errorcb, namecb, unicodedata)
            src = pypy_cjk_enc_outbuf(encodebuf)
            length = pypy_cjk_enc_outlen(encodebuf)
            return rffi.charpsize2str(src, length)
        #
        finally:
            pypy_cjk_enc_free(encodebuf)
    #
    finally:
        rffi.free_nonmoving_unicodebuffer(unicodedata, inbuf)
开发者ID:ieure,项目名称:pypy,代码行数:29,代码来源:c_codecs.py


示例16: Array_serialize

def Array_serialize(vm):
    (self,),_ = vm.decode_args("!", self_of=Array)
    assert isinstance(self, Array)

    data = rffi.charpsize2str(self.data, self.num_entries * self.type_size)
    objectmodel.keepalive_until_here(self) # XXX I don't really understand why this is needed
    return Con_String(vm, data)
开发者ID:lucciano,项目名称:converge,代码行数:7,代码来源:Con_Array.py


示例17: mk_mod

def mk_mod(vm, bc, mod_off):
    mod_size = read_word(bc, mod_off + BC_MOD_SIZE)
    assert mod_off >= 0 and mod_size >= 0

    mod_bc = rffi.ptradd(bc, mod_off)

    name = _extract_sstr(mod_bc, BC_MOD_NAME, BC_MOD_NAME_SIZE)
    id_ = _extract_sstr(mod_bc, BC_MOD_ID, BC_MOD_ID_SIZE)
    src_path = _extract_sstr(mod_bc, BC_MOD_SRC_PATH, BC_MOD_SRC_PATH_SIZE)

    imps = []
    j = read_word(mod_bc, BC_MOD_IMPORTS)
    for k in range(read_word(mod_bc, BC_MOD_NUM_IMPORTS)):
        assert j > 0
        imp_size = read_word(mod_bc, j)
        assert imp_size > 0
        j += INTSIZE
        imps.append(rffi.charpsize2str(rffi.ptradd(mod_bc, j), imp_size))
        j += align(imp_size)
        j += INTSIZE + align(read_word(mod_bc, j))

    num_vars = read_word(mod_bc, BC_MOD_NUM_TL_VARS_MAP)
    tlvars_map = {}
    j = read_word(mod_bc, BC_MOD_TL_VARS_MAP)
    for k in range(num_vars):
        assert j > 0
        var_num = read_word(mod_bc, j)
        j += INTSIZE
        tlvar_size = read_word(mod_bc, j)
        assert tlvar_size > 0
        j += INTSIZE
        n = rffi.charpsize2str(rffi.ptradd(mod_bc, j), tlvar_size)
        tlvars_map[n] = var_num
        j += align(tlvar_size)

    num_consts = read_word(mod_bc, BC_MOD_NUM_CONSTANTS)

    mod = Builtins.new_bc_con_module(vm, mod_bc, name, id_, src_path, imps, tlvars_map, num_consts)
    init_func_off = read_word(mod_bc, BC_MOD_INSTRUCTIONS)
    pc = BC_PC(mod, init_func_off)
    max_stack_size = 512 # XXX!
    mod.init_func = Builtins.Con_Func(vm, Builtins.Con_String(vm, "$$init$$"), False, pc, \
      max_stack_size, 0, num_vars, mod, None)
    
    return mod
开发者ID:cfbolz,项目名称:converge,代码行数:45,代码来源:Bytecode.py


示例18: _digest

 def _digest(self, space):
     with lltype.scoped_alloc(ropenssl.EVP_MD_CTX.TO) as ctx:
         with self.lock:
             ropenssl.EVP_MD_CTX_copy(ctx, self.ctx)
         digest_size = self.digest_size
         with lltype.scoped_alloc(rffi.CCHARP.TO, digest_size) as digest:
             ropenssl.EVP_DigestFinal(ctx, digest, None)
             ropenssl.EVP_MD_CTX_cleanup(ctx)
             return rffi.charpsize2str(digest, digest_size)
开发者ID:Debug-Orz,项目名称:Sypy,代码行数:9,代码来源:interp_hashlib.py


示例19: Array_get_slice

def Array_get_slice(vm):
    mod = vm.get_funcs_mod()
    (self, i_o, j_o),_ = vm.decode_args("!", opt="ii", self_of=Array)
    assert isinstance(self, Array)

    i, j = translate_slice_idx_objs(vm, i_o, j_o, self.num_entries)
    # This does a double allocation, so isn't very efficient. It is pleasingly simple though.
    data = rffi.charpsize2str(rffi.ptradd(self.data, i * self.type_size), int((j - i) * self.type_size))
    objectmodel.keepalive_until_here(self)
    return Array(vm, mod.get_defn(vm, "Array"), self.type_name, Con_String(vm, data))
开发者ID:lucciano,项目名称:converge,代码行数:10,代码来源:Con_Array.py


示例20: PyUnicode_DecodeUTF8

def PyUnicode_DecodeUTF8(space, s, size, errors):
    """Create a Unicode object by decoding size bytes of the UTF-8 encoded string
    s. Return NULL if an exception was raised by the codec.
    """
    w_str = space.wrap(rffi.charpsize2str(s, size))
    if errors:
        w_errors = space.wrap(rffi.charp2str(errors))
    else:
        w_errors = space.w_None
    return space.call_method(w_str, 'decode', space.wrap("utf-8"), w_errors)
开发者ID:ieure,项目名称:pypy,代码行数:10,代码来源:unicodeobject.py



注:本文中的pypy.rpython.lltypesystem.rffi.charpsize2str函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python rffi.free_charp函数代码示例发布时间:2022-05-27
下一篇:
Python rffi.charp2str函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap