diff options
author | Yuce Tekol <yucetekol@gmail.com> | 2019-05-05 08:30:12 +0300 |
---|---|---|
committer | Yuce Tekol <yucetekol@gmail.com> | 2019-05-05 08:30:12 +0300 |
commit | 9d214c788740b8c5042a186a390fc72c78c012d0 (patch) | |
tree | 314672c20e4c244a42280d328e6e492b38aaf265 /openbsd | |
parent | f75c37e149a11625bac395117c7c354e364e154a (diff) | |
parent | aefef1875c0d367e720c4b68919210bb34d755bc (diff) | |
download | pyopenbsd-9d214c788740b8c5042a186a390fc72c78c012d0.tar.gz |
Merge branch 'master' of gitea.cs:yuce/pyopenbsd
Diffstat (limited to 'openbsd')
-rw-r--r-- | openbsd/__init__.py | 12 | ||||
-rw-r--r-- | openbsd/openbsd_builder.py | 2 |
2 files changed, 3 insertions, 11 deletions
diff --git a/openbsd/__init__.py b/openbsd/__init__.py index 1aab185..a688661 100644 --- a/openbsd/__init__.py +++ b/openbsd/__init__.py @@ -1,10 +1,10 @@ import sys +import os from cffi import FFI from ._openbsd import lib as _lib __all__ = ["pledge", "unveil"] - _ffi = FFI() @@ -14,7 +14,7 @@ def pledge(promises=None, execpromises=None): ret = _lib.pledge(promises, execpromises) if ret < 0: errno = _ffi.errno - raise OSError(errno, _decode(_ffi.string(_lib.strerror(errno), 256))) + raise OSError(errno, os.strerror(errno)) def unveil(path=None, permissions=None): @@ -23,7 +23,7 @@ def unveil(path=None, permissions=None): ret = _lib.unveil(path, permissions) if ret < 0: errno = _ffi.errno - raise OSError(errno, _decode(_ffi.string(_lib.strerror(errno), 256))) + raise OSError(errno, os.strerror(errno)) if isinstance(b"openbsd", str): @@ -32,9 +32,6 @@ if isinstance(b"openbsd", str): if isinstance(text, unicode): return text.encode("ascii") return text - - def _decode(text): - return text else: # Python 3 def _encode(text): @@ -42,7 +39,4 @@ else: return text.encode("ascii") return text - def _decode(text): - return text.decode("ascii") - diff --git a/openbsd/openbsd_builder.py b/openbsd/openbsd_builder.py index a8720c1..7778796 100644 --- a/openbsd/openbsd_builder.py +++ b/openbsd/openbsd_builder.py @@ -5,13 +5,11 @@ ffibuilder = FFI() ffibuilder.cdef(''' int pledge(const char *promises, const char *execpromises); int unveil(const char *path, const char *permissions); - char *strerror(int errnum); ''') ffibuilder.set_source("openbsd._openbsd", """ #include <unistd.h> - #include <string.h> """) if __name__ == "__main__": |