Skip to content

Commit 8bed308

Browse files
author
Paul Sokolovsky
committed
fcntl: Add error checking and at least TODOs about buffer return values.
1 parent 7771290 commit 8bed308

File tree

1 file changed

+18
-5
lines changed

1 file changed

+18
-5
lines changed

fcntl/fcntl.py

+18-5
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import ffi
2+
import os
23
import _libc
34

45

@@ -12,13 +13,25 @@
1213

1314
def fcntl(fd, op, arg=0):
1415
if type(arg) is int:
15-
return fcntl_l(fd, op, arg)
16+
r = fcntl_l(fd, op, arg)
17+
os.check_error(r)
18+
return r
1619
else:
17-
return fcntl_s(fd, op, arg)
20+
r = fcntl_s(fd, op, arg)
21+
os.check_error(r)
22+
# TODO: Not compliant. CPython says that arg should be immutable,
23+
# and possibly mutated buffer is returned.
24+
return r
1825

1926

20-
def ioctl(fd, op, arg=0):
27+
def ioctl(fd, op, arg=0, mut=False):
2128
if type(arg) is int:
22-
return ioctl_l(fd, op, arg)
29+
r = ioctl_l(fd, op, arg)
30+
os.check_error(r)
31+
return r
2332
else:
24-
return ioctl_s(fd, op, arg)
33+
# TODO
34+
assert mut
35+
r = ioctl_s(fd, op, arg)
36+
os.check_error(r)
37+
return r

0 commit comments

Comments
 (0)