From b9ce844109a988af303e44dc1ec584b375a3637a Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Piotr=20Ma=C5=9Blanka?= <piotr.maslanka@henrietta.com.pl>
Date: Fri, 18 Oct 2024 17:59:11 +0200
Subject: [PATCH] fixes #3

---
 coolamqp/objects.py   | 5 +++--
 tests/test_objects.py | 2 +-
 2 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/coolamqp/objects.py b/coolamqp/objects.py
index 22fd796..c68621c 100644
--- a/coolamqp/objects.py
+++ b/coolamqp/objects.py
@@ -27,6 +27,8 @@ def toutf8(q):
 
 
 def tobytes(q):
+    if isinstance(q, memoryview):
+        return q.tobytes()
     return q.encode('utf-8') if isinstance(q, six.text_type) else q
 
 
@@ -287,8 +289,7 @@ class Queue(object):
         if name is None:
             self.name = None
         else:
-            name = uuid.uuid4().hex if not name else name
-            self.name = tobytes(name)
+            self.name = tobytes(uuid.uuid4().hex if not name else name)
 
         self.durable = durable
         self.exchange = exchange
diff --git a/tests/test_objects.py b/tests/test_objects.py
index b7fa700..bb562c0 100644
--- a/tests/test_objects.py
+++ b/tests/test_objects.py
@@ -26,7 +26,7 @@ class TestObjects(unittest.TestCase):
         with warnings.catch_warnings(record=True) as w:
             Queue('test', auto_delete=True, exclusive=True)
             Queue(auto_delete=True, exclusive=False)
-        self.assertEqual(len(w), 2)
+        self.assertEqual(len(w), 2 if sys.version.startswith('3') else 1)
         self.assertTrue(issubclass(w[0].category, UserWarning))
         self.assertTrue(issubclass(w[1].category, DeprecationWarning))
 
-- 
GitLab