コード例 #1
0
def test_SetNonInheritableCache():
    cache = rposix.SetNonInheritableCache()
    fd1, fd2 = os.pipe()
    if sys.platform == 'win32':
        rposix.set_inheritable(fd1, True)
        rposix.set_inheritable(fd2, True)
    assert rposix.get_inheritable(fd1) == True
    assert rposix.get_inheritable(fd1) == True
    assert cache.cached_inheritable == -1
    cache.set_non_inheritable(fd1)
    assert cache.cached_inheritable == 1
    cache.set_non_inheritable(fd2)
    assert cache.cached_inheritable == 1
    assert rposix.get_inheritable(fd1) == False
    assert rposix.get_inheritable(fd1) == False
    os.close(fd1)
    os.close(fd2)
コード例 #2
0
        else:
            return w_value
    def fset(space, obj, w_value):
        setattr(obj, name, w_value)
    def fdel(space, obj):
        w_value = getattr(obj, name)
        if w_value is None:
            raise OperationError(space.w_AttributeError, space.newtext(name))
        setattr(obj, name, None)

    return GetSetProperty(fget, fset, fdel, cls=cls, doc=doc)


O_BINARY = getattr(os, "O_BINARY", 0)
O_APPEND = getattr(os, "O_APPEND", 0)
_open_inhcache = rposix.SetNonInheritableCache()

def _bad_mode(space):
    raise oefmt(space.w_ValueError,
                "Must have exactly one of read/write/create/append mode")

def decode_mode(space, mode):
    flags = 0
    rwa = False
    readable = False
    writable = False
    created = False
    append = False
    plus = False

    for s in mode: