Skip to content

Commit 7723553

Browse files
committed
[fix] Handle possible null path in all methods mentioned in nullpath_ok documentation
1 parent b09c541 commit 7723553

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

mfusepy.py

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1361,12 +1361,12 @@ def link(self, source, target):
13611361
if fuse_version_major == 2:
13621362

13631363
def chmod(self, path, mode):
1364-
return self.operations('chmod', path.decode(self.encoding), mode)
1364+
return self.operations('chmod', None if path is None else path.decode(self.encoding), mode)
13651365

13661366
elif fuse_version_major == 3:
13671367

13681368
def chmod(self, path, mode, fip):
1369-
return self.operations('chmod', path.decode(self.encoding), mode)
1369+
return self.operations('chmod', None if path is None else path.decode(self.encoding), mode)
13701370

13711371
def _chown(self, path, uid, gid):
13721372
# Check if any of the arguments is a -1 that has overflowed
@@ -1375,7 +1375,7 @@ def _chown(self, path, uid, gid):
13751375
if c_gid_t(gid + 1).value == 0:
13761376
gid = -1
13771377

1378-
return self.operations('chown', path.decode(self.encoding), uid, gid)
1378+
return self.operations('chown', None if path is None else path.decode(self.encoding), uid, gid)
13791379

13801380
if fuse_version_major == 2:
13811381

@@ -1390,12 +1390,12 @@ def chown(self, path, uid, gid, fip):
13901390
if fuse_version_major == 2:
13911391

13921392
def truncate(self, path, length):
1393-
return self.operations('truncate', path.decode(self.encoding), length)
1393+
return self.operations('truncate', None if path is None else path.decode(self.encoding), length)
13941394

13951395
elif fuse_version_major == 3:
13961396

13971397
def truncate(self, path, length, fip):
1398-
return self.operations('truncate', path.decode(self.encoding), length)
1398+
return self.operations('truncate', None if path is None else path.decode(self.encoding), length)
13991399

14001400
def open(self, path, fip):
14011401
fi = fip.contents
@@ -1672,7 +1672,7 @@ def _utimens(self, path, buf):
16721672
else:
16731673
times = None
16741674

1675-
return self.operations('utimens', path.decode(self.encoding), times)
1675+
return self.operations('utimens', None if path is None else path.decode(self.encoding), times)
16761676

16771677
if fuse_version_major == 2:
16781678
utimens = _utimens
@@ -1686,11 +1686,11 @@ def bmap(self, path, blocksize, idx):
16861686

16871687
def ioctl(self, path, cmd, arg, fip, flags, data):
16881688
fh = fip.contents if self.raw_fi else fip.contents.fh
1689-
return self.operations('ioctl', path.decode(self.encoding), cmd, arg, fh, flags, data)
1689+
return self.operations('ioctl', None if path is None else path.decode(self.encoding), cmd, arg, fh, flags, data)
16901690

16911691
def poll(self, path, fip, ph, reventsp):
16921692
fh = fip.contents if self.raw_fi else fip.contents.fh
1693-
return self.operations('poll', path.decode(self.encoding), fh, ph, reventsp)
1693+
return self.operations('poll', None if path is None else path.decode(self.encoding), fh, ph, reventsp)
16941694

16951695
def write_buf(self, path, buf, offset, fip):
16961696
fh = fip.contents if self.raw_fi else fip.contents.fh
@@ -1706,7 +1706,9 @@ def flock(self, path, fip, op):
17061706

17071707
def fallocate(self, path, mode, offset, size, fip):
17081708
fh = fip.contents if self.raw_fi else fip.contents.fh
1709-
return self.operations('fallocate', path.decode(self.encoding), mode, offset, size, fh)
1709+
return self.operations(
1710+
'fallocate', None if path is None else path.decode(self.encoding), mode, offset, size, fh
1711+
)
17101712

17111713

17121714
def _nullable_dummy_function(method):

0 commit comments

Comments
 (0)