Dear maintainer,
attached the debdiff for my NMU for starpy (versioned as 
1.0.1.0.git.20151124-2.1)

Cheers,
        Moritz

diff -Nru starpy-1.0.1.0.git.20151124/debian/changelog starpy-1.0.1.0.git.20151124/debian/changelog
--- starpy-1.0.1.0.git.20151124/debian/changelog	2017-08-01 22:59:50.000000000 +0200
+++ starpy-1.0.1.0.git.20151124/debian/changelog	2020-03-09 22:40:05.000000000 +0100
@@ -1,3 +1,10 @@
+starpy (1.0.1.0.git.20151124-2.1) unstable; urgency=medium
+
+  * Non-maintainer upload.
+  * Cherrypick upstream commit to fix Python 3 compat (Closes: #938567)
+
+ -- Moritz Muehlenhoff <j...@debian.org>  Mon, 09 Mar 2020 22:40:05 +0100
+
 starpy (1.0.1.0.git.20151124-2) unstable; urgency=medium
 
   * Depend on python-setuptools (Closes: #867672)
diff -Nru starpy-1.0.1.0.git.20151124/debian/control starpy-1.0.1.0.git.20151124/debian/control
--- starpy-1.0.1.0.git.20151124/debian/control	2017-08-01 22:45:45.000000000 +0200
+++ starpy-1.0.1.0.git.20151124/debian/control	2020-03-09 22:40:05.000000000 +0100
@@ -5,19 +5,19 @@
 # Add Paul Belanger as an uploaded, for now.
 Uploaders: Tzafrir Cohen <tzaf...@debian.org>, Paul Belanger <paul.belan...@polybeacon.com>
 Build-Depends: debhelper (>= 10),
- python,
+ python3,
  dh-python,
- python-setuptools,
- python-twisted-core
+ python3-setuptools,
+ python3-twisted
 X-Python-Version: >= 2.4
 Standards-Version: 3.9.8
 Homepage: https://github.com/asterisk/starpy
 Vcs-Git: https://anonscm.debian.org/cgit/pkg-voip/starpy.git
 Vcs-Browser: https://anonscm.debian.org/cgit/pkg-voip/starpy.git
 
-Package: python-starpy
+Package: python3-starpy
 Architecture: all
-Depends: python-twisted-core, ${misc:Depends}, ${python:Depends}
+Depends: python3-twisted, ${misc:Depends}, ${python3:Depends}
 Recommends: asterisk
 Description: Asterisk (AMI) protocols for Twisted Python
  A Twisted Python protocol that provides access to the Asterisk PBX's Manager
diff -Nru starpy-1.0.1.0.git.20151124/debian/patches/add-support-for-python-3.patch starpy-1.0.1.0.git.20151124/debian/patches/add-support-for-python-3.patch
--- starpy-1.0.1.0.git.20151124/debian/patches/add-support-for-python-3.patch	1970-01-01 01:00:00.000000000 +0100
+++ starpy-1.0.1.0.git.20151124/debian/patches/add-support-for-python-3.patch	2020-03-09 22:38:37.000000000 +0100
@@ -0,0 +1,267 @@
+From 7e43a8bafddd9e746dadf3ed4ec28fc79542dc25 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Rodrigo=20Ram=C3=ADrez=20Norambuena?= <a...@rodrigoramirez.com>
+Date: Sat, 1 Oct 2016 14:24:14 -0300
+Subject: [PATCH] Add support code for Python 3
+
+Change-Id: I9ccd5a15be6e4129a5e0ce0bf1a5a4ff26998bac
+---
+ starpy/fastagi.py | 19 ++++++++++---------
+ starpy/manager.py | 44 +++++++++++++++++++++++++++++---------------
+ tox.ini           |  2 +-
+ 3 files changed, 40 insertions(+), 25 deletions(-)
+
+diff --git a/starpy/fastagi.py b/starpy/fastagi.py
+index 7a9b32e..7e26284 100644
+--- a/starpy/fastagi.py
++++ b/starpy/fastagi.py
+@@ -127,7 +127,7 @@ def lineReceived(self, line):
+                 try:
+                     key, value = line.split(':', 1)
+                     value = value[1:].rstrip('\n').rstrip('\r')
+-                except ValueError, err:
++                except ValueError as err:
+                     log.error("""Invalid variable line: %r""", line)
+                 else:
+                     self.variables[key.lower()] = value
+@@ -135,7 +135,7 @@ def lineReceived(self, line):
+         else:
+             try:
+                 df = self.pendingMessages.pop(0)
+-            except IndexError, err:
++            except IndexError as err:
+                 log.warn("Line received without pending deferred: %r", line)
+             else:
+                 if line.startswith('200'):
+@@ -148,7 +148,7 @@ def lineReceived(self, line):
+                     try:
+                         errCode, line = line.split(' ', 1)
+                         errCode = int(errCode)
+-                    except ValueError, err:
++                    except ValueError as err:
+                         errCode = 500
+                     df.errback(error.AGICommandFailure(errCode, line))
+ 
+@@ -166,7 +166,7 @@ def checkFailure(self, result, failure='-1'):
+         # result code may have trailing information...
+         try:
+             resultInt, line = result.split(' ', 1)
+-        except ValueError, err:
++        except ValueError as err:
+             resultInt = result
+         if resultInt.strip() == failure:
+             raise error.AGICommandFailure(FAILURE_CODE, result)
+@@ -176,7 +176,7 @@ def resultAsInt(self, result):
+         """(Internal) Convert result to an integer value"""
+         try:
+             return int(result.strip())
+-        except ValueError, err:
++        except ValueError as err:
+             raise error.AGICommandFailure(FAILURE_CODE, result)
+ 
+     def secondResultItem(self, result):
+@@ -188,7 +188,7 @@ def resultPlusTimeoutFlag(self, resultLine):
+         try:
+             digits, timeout = resultLine.split(' ', 1)
+             return digits.strip(), True
+-        except ValueError, err:
++        except ValueError as err:
+             return resultLine.strip(), False
+ 
+     def dateAsSeconds(self, date):
+@@ -207,7 +207,7 @@ def onRecordingComplete(self, resultLine):
+         """
+         try:
+             digit, exitType, endposStuff = resultLine.split(' ', 2)
+-        except ValueError, err:
++        except ValueError as err:
+             pass
+         else:
+             digit = int(digit)
+@@ -226,7 +226,7 @@ def onStreamingComplete(self, resultLine, skipMS=0):
+         """
+         try:
+             digit, endposStuff = resultLine.split(' ', 1)
+-        except ValueError, err:
++        except ValueError as err:
+             pass
+         else:
+             digit = int(digit)
+@@ -472,7 +472,8 @@ def getOption(self, filename, escapeDigits, timeout=None):
+             timeout *= 1000
+             command += ' %s' % (timeout,)
+ 
+-        def charFirst((c, position)):
++        def charFirst(values):
++            (c, position) = values
+             if not c:  # returns 0 on timeout
+                 c = ''
+             else:
+diff --git a/starpy/manager.py b/starpy/manager.py
+index a564b3a..6876f74 100644
+--- a/starpy/manager.py
++++ b/starpy/manager.py
+@@ -22,6 +22,7 @@
+ Module defines a standard Python logging module log 'AMI'
+ """
+ 
++import sys
+ from twisted.internet import protocol, reactor, defer
+ from twisted.protocols import basic
+ from twisted.internet import error as tw_error
+@@ -33,6 +34,14 @@
+ 
+ log = logging.getLogger('AMI')
+ 
++if sys.version_info[0] < 3:
++    def string_types(value):
++        return isinstance(value, (str, unicode, type(None)))  # noqa
++else:
++    def string_types(value):
++        return isinstance(value, (str, type(None)))
++
++
+ class deferredErrorResp(defer.Deferred):
+     """A subclass of defer.Deferred that adds a registerError method
+     to handle function callback when an Error response happens"""
+@@ -118,7 +127,7 @@ def registerEvent(self, event, function):
+         """
+         log.debug('Registering function %s to handle events of type %r',
+                   function, event)
+-        if isinstance(event, (str, unicode, type(None))):
++        if string_types(event):
+             event = (event,)
+         for ev in event:
+             self.eventTypeCallbacks.setdefault(ev, []).append(function)
+@@ -134,24 +143,24 @@ def deregisterEvent(self, event, function=None):
+         """
+         log.debug('Deregistering handler %s for events of type %r',
+                   function, event)
+-        if isinstance(event, (str, unicode, type(None))):
++        if string_types(event):
+             event = (event,)
+         success = True
+         for ev in event:
+             try:
+                 set = self.eventTypeCallbacks[ev]
+-            except KeyError, err:
++            except KeyError as err:
+                 success = False
+             else:
+                 try:
+                     while function in set:
+                         set.remove(function)
+-                except (ValueError, KeyError), err:
++                except (ValueError, KeyError) as err:
+                     success = False
+                 if not set or function is None:
+                     try:
+                         del self.eventTypeCallbacks[ev]
+-                    except KeyError, err:
++                    except KeyError as err:
+                         success = False
+         return success
+ 
+@@ -209,7 +218,7 @@ def connectionLost(self, reason):
+             try:
+                 callable(tw_error.ConnectionDone(
+                          "FastAGI connection terminated"))
+-            except Exception, err:
++            except Exception as err:
+                 log.error("Failure during connectionLost for callable %s: %s",
+                           callable, err)
+         self.actionIDCallbacks.clear()
+@@ -223,6 +232,9 @@ def dispatchIncoming(self):
+         message = {}
+         while self.messageCache:
+             line = self.messageCache.pop(0)
++
++            if type(line) is bytes:
++                line = line.decode('utf-8')
+             line = line.strip()
+             if line:
+                 if line.endswith(self.END_DATA):
+@@ -239,7 +251,7 @@ def dispatchIncoming(self):
+                     else:
+                         try:
+                             key, value = line.split(':', 1)
+-                        except ValueError, err:
++                        except ValueError as err:
+                             # XXX data-safety issues, what prevents the
+                             # VERSION_PREFIX from showing up in a data-set?
+                             log.warn("Improperly formatted line received and "
+@@ -253,7 +265,7 @@ def dispatchIncoming(self):
+             if callback:
+                 try:
+                     callback(message)
+-                except Exception, err:
++                except Exception as err:
+                     # XXX log failure here...
+                     pass
+         # otherwise is a monitor message or something we didn't send...
+@@ -265,13 +277,13 @@ def dispatchEvent(self, event):
+         for key in (event['event'], None):
+             try:
+                 handlers = self.eventTypeCallbacks[key]
+-            except KeyError, err:
++            except KeyError as err:
+                 pass
+             else:
+                 for handler in handlers:
+                     try:
+                         handler(self, event)
+-                    except Exception, err:
++                    except Exception as err:
+                         # would like the getException code here...
+                         log.error(
+                             'Exception in event handler %s on event %s: %s',
+@@ -316,7 +328,7 @@ def cleanup(self, result, actionid):
+         """Cleanup callbacks on completion"""
+         try:
+             del self.actionIDCallbacks[actionid]
+-        except KeyError, err:
++        except KeyError as err:
+             pass
+         return result
+ 
+@@ -335,7 +347,8 @@ def sendMessage(self, message, responseCallback=None):
+                 self.actionIDCallbacks[actionid] = responseCallback
+             log.debug("""MSG OUT: %s""", message)
+             for item in message:
+-                self.sendLine('%s: %s' % (str(item[0].lower()), str(item[1])))
++                line = ('%s: %s' % (str(item[0].lower()), str(item[1])))
++                self.sendLine(line.encode('utf-8'))
+         else:
+             message = dict([(k.lower(), v) for (k, v) in message.items()])
+             if 'actionid' not in message:
+@@ -344,8 +357,9 @@ def sendMessage(self, message, responseCallback=None):
+                 self.actionIDCallbacks[message['actionid']] = responseCallback
+             log.debug("""MSG OUT: %s""", message)
+             for key, value in message.items():
+-                self.sendLine('%s: %s' % (str(key.lower()), str(value)))
+-        self.sendLine('')
++                line = ('%s: %s' % (str(key.lower()), str(value)))
++                self.sendLine(line.encode('utf-8'))
++        self.sendLine(''.encode('utf-8'))
+         if type(message) == list:
+             return actionid
+         else:
+@@ -630,7 +644,7 @@ def listCommands(self):
+         def removeActionId(message):
+             try:
+                 del message['actionid']
+-            except KeyError, err:
++            except KeyError as err:
+                 pass
+             return message
+ 
+diff --git a/tox.ini b/tox.ini
+index a74bf6d..a6c1ede 100644
+--- a/tox.ini
++++ b/tox.ini
+@@ -1,5 +1,5 @@
+ [tox]
+-envlist = py26,py27,pep8
++envlist = py26,py27,py32,py33,py34,p35,pep8
+ 
+ [testenv]
+ deps = -r{toxinidir}/tools/pip-requires
diff -Nru starpy-1.0.1.0.git.20151124/debian/patches/series starpy-1.0.1.0.git.20151124/debian/patches/series
--- starpy-1.0.1.0.git.20151124/debian/patches/series	2016-07-09 23:11:50.000000000 +0200
+++ starpy-1.0.1.0.git.20151124/debian/patches/series	2020-03-09 22:39:10.000000000 +0100
@@ -1,2 +1,3 @@
 no-examples-module.patch
 privacy-breach-logo.patch
+add-support-for-python-3.patch
diff -Nru starpy-1.0.1.0.git.20151124/debian/rules starpy-1.0.1.0.git.20151124/debian/rules
--- starpy-1.0.1.0.git.20151124/debian/rules	2016-07-09 20:27:50.000000000 +0200
+++ starpy-1.0.1.0.git.20151124/debian/rules	2020-03-09 22:40:05.000000000 +0100
@@ -8,7 +8,7 @@
 URL := https://github.com/downloads/asterisk-org/starpy/starpy-$(UPVERSION).tar.gz
 
 %:
-	dh $@ --with python2
+	dh $@ --with python3 --buildsystem=pybuild
 
 print-version:
 	@@echo "Debian version:          $(DEBVERSION)"

Reply via email to