Skip to content

Commit 221f769

Browse files
committed
os: Factor out error checking to a separate function.
1 parent 488d248 commit 221f769

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

os/os.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,11 @@
77
mkdir_ = libc.func("i", "mkdir", "si")
88

99

10+
def check_error(ret):
11+
if ret == -1:
12+
raise OSError(errno.get())
13+
14+
1015
def mkdir(name, mode=0o777):
1116
e = mkdir_(name, mode)
12-
if not e:
13-
return
14-
raise OSError(errno.get())
17+
check_error(e)

0 commit comments

Comments
 (0)