Here is a proposed debdiff running the 2to3 step manually, since the automatic one provided by `build_py_2to3` has been deprecated.

This is probably just a temporary solution while a more general one is worked either on Debian side by reintroducing `build_py_2to3` somehow, or, more preferably, a Python3-compatible upstream release is produced.

diff -Nru python-amqplib-1.0.2/debian/changelog 
python-amqplib-1.0.2/debian/changelog
--- python-amqplib-1.0.2/debian/changelog       2024-06-06 15:09:52.000000000 
+0200
+++ python-amqplib-1.0.2/debian/changelog       2024-08-16 13:39:07.000000000 
+0200
@@ -1,3 +1,10 @@
+python-amqplib (1.0.2-5) unstable; urgency=medium
+
+  * Do the 2to3 step manually in a patch, since the automatic `build_py_2to3`
+    is deprecated. (Closes: #1077824, LP: #2075183)
+
+ -- Florent 'Skia' Jacquet <florent.jacq...@canonical.com>  Fri, 16 Aug 2024 
13:39:07 +0200
+
 python-amqplib (1.0.2-4) unstable; urgency=low
 
   [ Debian Janitor ]
diff -Nru python-amqplib-1.0.2/debian/patches/0004-2to3.patch 
python-amqplib-1.0.2/debian/patches/0004-2to3.patch
--- python-amqplib-1.0.2/debian/patches/0004-2to3.patch 1970-01-01 
01:00:00.000000000 +0100
+++ python-amqplib-1.0.2/debian/patches/0004-2to3.patch 2024-08-16 
13:33:00.000000000 +0200
@@ -0,0 +1,105 @@
+From: Florent 'Skia' Jacquet <florent.jacq...@canonical.com>
+Date: Fri, 16 Aug 2024 13:32:45 +0200
+Subject: Run 2to3 manually
+
+With the deprecation of 2to3 and the removal of `build_py_2to3`, the automatic
+translation from Python2 to Python3 at build time no longer works. This patch 
is
+a manual run of 2to3 while a more general solution is found.
+--- a/amqplib/client_0_8/connection.py
++++ b/amqplib/client_0_8/connection.py
+@@ -160,7 +160,7 @@
+         self.transport.close()
+         self.transport = None
+ 
+-        temp_list = [x for x in self.channels.values() if x is not self]
++        temp_list = [x for x in list(self.channels.values()) if x is not self]
+         for ch in temp_list:
+             ch._do_close()
+ 
+@@ -168,7 +168,7 @@
+ 
+ 
+     def _get_free_channel_id(self):
+-        for i in xrange(1, self.channel_max+1):
++        for i in range(1, self.channel_max+1):
+             if i not in self.channels:
+                 return i
+         raise AMQPException('No free channel ids, current=%d, channel_max=%d'
+--- a/amqplib/client_0_8/method_framing.py
++++ b/amqplib/client_0_8/method_framing.py
+@@ -241,7 +241,7 @@
+             # problem with the content properties, before sending the
+             # first frame
+             body = content.body
+-            if isinstance(body, unicode):
++            if isinstance(body, str):
+                 coding = content.properties.get('content_encoding', None)
+                 if coding is None:
+                     coding = content.properties['content_encoding'] = 'UTF-8'
+@@ -257,5 +257,5 @@
+             self.dest.write_frame(2, channel, payload)
+ 
+             chunk_size = self.frame_max - 8
+-            for i in xrange(0, len(body), chunk_size):
++            for i in range(0, len(body), chunk_size):
+                 self.dest.write_frame(3, channel, body[i:i+chunk_size])
+--- a/amqplib/client_0_8/serialization.py
++++ b/amqplib/client_0_8/serialization.py
+@@ -40,9 +40,9 @@
+ except:
+     # Python 2.5 and lower
+     try:
+-        from cStringIO import StringIO as BytesIO
++        from io import StringIO as BytesIO
+     except:
+-        from StringIO import StringIO as BytesIO
++        from io import StringIO as BytesIO
+ 
+ try:
+     bytes
+@@ -335,7 +335,7 @@
+ 
+         """
+         self._flushbits()
+-        if isinstance(s, unicode):
++        if isinstance(s, str):
+             s = s.encode('utf-8')
+         if len(s) > 255:
+             raise ValueError('String too long')
+@@ -351,7 +351,7 @@
+ 
+         """
+         self._flushbits()
+-        if isinstance(s, unicode):
++        if isinstance(s, str):
+             s = s.encode('utf-8')
+         self.write_long(len(s))
+         self.out.write(s)
+@@ -366,14 +366,14 @@
+         """
+         self._flushbits()
+         table_data = AMQPWriter()
+-        for k, v in d.items():
++        for k, v in list(d.items()):
+             table_data.write_shortstr(k)
+-            if isinstance(v, basestring):
+-                if isinstance(v, unicode):
++            if isinstance(v, str):
++                if isinstance(v, str):
+                     v = v.encode('utf-8')
+                 table_data.write(byte(83)) # 'S'
+                 table_data.write_longstr(v)
+-            elif isinstance(v, (int, long)):
++            elif isinstance(v, int):
+                 table_data.write(byte(73)) # 'I'
+                 table_data.write(pack('>i', v))
+             elif isinstance(v, Decimal):
+@@ -406,7 +406,7 @@
+         representing seconds since the Unix epoch.
+ 
+         """
+-        self.out.write(pack('>q', long(mktime(v.timetuple()))))
++        self.out.write(pack('>q', int(mktime(v.timetuple()))))
+ 
+ 
+ class GenericContent(object):
diff -Nru python-amqplib-1.0.2/debian/patches/series 
python-amqplib-1.0.2/debian/patches/series
--- python-amqplib-1.0.2/debian/patches/series  2024-06-06 15:09:52.000000000 
+0200
+++ python-amqplib-1.0.2/debian/patches/series  2024-08-16 13:33:45.000000000 
+0200
@@ -1,3 +1,4 @@
 0001-Use-relative-imports.patch
 0002-Fix-module-name-for-queue.patch
 0003-Fix-exception-handling-syntax.patch
+0004-2to3.patch

Reply via email to