Hi Debian (2020.05.13_19:25:05_-0700)
> Patch attached.

Whoops, missed the mode flags.
Updated patch attached.

SR
From dad0c592892b7e296dd81e22501d5d34323cdc83 Mon Sep 17 00:00:00 2001
From: Stefano Rivera <stef...@rivera.za.net>
Date: Wed, 13 May 2020 18:43:21 -0700
Subject: [PATCH] Python 3 compatibility in list_mount_points

ctypes requires byte strings for arguments and return values.

This will return unicode strings under Python 2. But that's EoL now.
---
 trashcli/list_mount_points.py | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/trashcli/list_mount_points.py b/trashcli/list_mount_points.py
index f0f9cb8..f8b1618 100644
--- a/trashcli/list_mount_points.py
+++ b/trashcli/list_mount_points.py
@@ -60,17 +60,20 @@ def _mounted_filesystems_from_getmnt() :
     libc.fopen.restype = c_void_p
     libc.fclose.argtypes = [c_void_p]
 
-    f = libc.fopen("/proc/mounts", "r")
+    f = libc.fopen(b"/proc/mounts", b"r")
     if f==None:
-        f = libc.fopen("/etc/mtab", "r")
+        f = libc.fopen(b"/etc/mtab", b"r")
         if f == None:
             raise IOError("Unable to open /proc/mounts nor /etc/mtab")
 
+    fse = sys.getfilesystemencoding()
+
     while True:
         entry = libc.getmntent(f)
         if bool(entry) == False:
             libc.fclose(f)
             break
-        yield Filesystem(entry.contents.mnt_dir,
-                         entry.contents.mnt_type,
-                         entry.contents.mnt_fsname)
+        yield Filesystem(
+            entry.contents.mnt_dir.decode(fse, 'surrogateescape'),
+            entry.contents.mnt_type.decode('ascii'),
+            entry.contents.mnt_fsname.decode(fse, 'surrogateescape'))
-- 
2.26.2

Reply via email to