예제 #1
0
def _fromstr(key):
    if isinstance(key, str):
        key = key.encode()
    elif not isinstance(key, bytes):
        msg = "gdbm mappings have bytes or string indices only, not {!r}"
        raise TypeError(msg.format(type(key).__name__))
    return {'dptr': ffi.new("char[]", key), 'dsize': len(key)}
예제 #2
0
def _fromstr(key):
    if isinstance(key, unicode):
        key = key.encode("ascii")
    if not isinstance(key, str):
        raise TypeError("gdbm mappings have string indices only")
    return {'dptr': ffi.new("char[]", key), 'dsize': len(key)}
예제 #3
0
def _fromstr(key):
    if isinstance(key, unicode):
        key = key.encode("ascii")
    if not isinstance(key, str):
        raise TypeError("gdbm mappings have string indices only")
    return {'dptr': ffi.new("char[]", key), 'dsize': len(key)}