diff options
author | Yuce Tekol <yucetekol@gmail.com> | 2019-05-03 13:01:24 +0300 |
---|---|---|
committer | Yuce Tekol <yucetekol@gmail.com> | 2019-05-03 13:01:24 +0300 |
commit | 40df1261b2c161a5e4fddd599d5d77bd0ebec930 (patch) | |
tree | 8481a2f03c0d06deb1d85aea89a08bcf88ab24a1 | |
parent | 968d5d7b886f894d4df08eef09d0fc21539f60fc (diff) | |
download | pyopenbsd-40df1261b2c161a5e4fddd599d5d77bd0ebec930.tar.gz |
simplify error strings
-rw-r--r-- | openbsd/__init__.py | 11 |
1 files changed, 3 insertions, 8 deletions
diff --git a/openbsd/__init__.py b/openbsd/__init__.py index 1aab185..e321f61 100644 --- a/openbsd/__init__.py +++ b/openbsd/__init__.py @@ -1,5 +1,6 @@ import sys +import os from cffi import FFI from ._openbsd import lib as _lib @@ -14,7 +15,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 +24,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 +33,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 +40,4 @@ else: return text.encode("ascii") return text - def _decode(text): - return text.decode("ascii") - |