From: Stefano Rivera <stefanor@debian.org>
Date: Mon, 8 Feb 2021 17:17:00 -0800
Subject: Support trio < 0.15

trio.hazmat was renamed to trio.lowlevel in 0.15. Support older
versions.

Forwarded: not-needed
---
 src/internal.pxi       | 10 ++++++++--
 src/pyfuse3.pyx        | 10 ++++++++--
 src/pyfuse3_asyncio.py |  1 +
 3 files changed, 17 insertions(+), 4 deletions(-)

diff --git a/src/internal.pxi b/src/internal.pxi
index e4cfabb..8eeda19 100644
--- a/src/internal.pxi
+++ b/src/internal.pxi
@@ -215,7 +215,10 @@ async def _wait_fuse_readable():
                 log.debug('FUSE session exit flag set while waiting for FUSE fd '
                           'to become readable.')
                 return False
-            await trio.lowlevel.wait_readable(session_fd)
+            if trio.__version__ < '0.15':
+                await trio.hazmat.wait_readable(session_fd)
+            else:
+                await trio.lowlevel.wait_readable(session_fd)
             #log.debug('%s: fuse fd readable, unparking next task.', name)
     except trio.ClosedResourceError:
         log.debug('FUSE fd about to be closed.')
@@ -231,7 +234,10 @@ async def _session_loop(nursery, int min_tasks, int max_tasks):
     cdef int res
     cdef fuse_buf buf
 
-    name = trio.lowlevel.current_task().name
+    if trio.__version__ < '0.15':
+        name = trio.hazmat.current_task().name
+    else:
+        name = trio.lowlevel.current_task().name
 
     buf.mem = NULL
     buf.size = 0
diff --git a/src/pyfuse3.pyx b/src/pyfuse3.pyx
index b1742c0..3d911b4 100644
--- a/src/pyfuse3.pyx
+++ b/src/pyfuse3.pyx
@@ -767,7 +767,10 @@ async def main(int min_tasks=1, int max_tasks=99):
         raise RuntimeError('Need to call init() before main()')
 
     global trio_token
-    trio_token = trio.lowlevel.current_trio_token()
+    if trio.__version__ < '0.15':
+        trio_token = trio.hazmat.current_trio_token()
+    else:
+        trio_token = trio.lowlevel.current_trio_token()
 
     try:
         async with trio.open_nursery() as nursery:
@@ -793,7 +796,10 @@ def terminate():
     '''
 
     fuse_session_exit(session)
-    trio.lowlevel.notify_closing(session_fd)
+    if trio.__version__ < '0.15':
+        trio.hazmat.notify_closing(session_fd)
+    else:
+        trio.lowlevel.notify_closing(session_fd)
 
 
 def close(unmount=True):
diff --git a/src/pyfuse3_asyncio.py b/src/pyfuse3_asyncio.py
index 3a5fb12..dc758ce 100644
--- a/src/pyfuse3_asyncio.py
+++ b/src/pyfuse3_asyncio.py
@@ -22,6 +22,7 @@ def enable():
     '''Switch pyfuse3 to asyncio mode.'''
 
     fake_trio = sys.modules['pyfuse3_asyncio']
+    fake_trio.__version__ = '0.15'
     fake_trio.lowlevel = fake_trio
     fake_trio.from_thread = fake_trio
     pyfuse3.trio = fake_trio
